@@ -21,15 +21,15 @@ def get_r_command():
2121 if "NIPYPE_NO_R" in os .environ :
2222 return None
2323 r_cmd = os .getenv ("RCMD" , default = "R" )
24-
24+
2525 return r_cmd if which (r_cmd ) else None
2626
2727
2828no_r = get_r_command () is None
2929
3030
3131class RInputSpec (CommandLineInputSpec ):
32- """ Basic expected inputs to R interface """
32+ """Basic expected inputs to R interface"""
3333
3434 script = traits .Str (
3535 argstr = '-e "%s"' , desc = "R code to run" , mandatory = True , position = - 1
@@ -39,7 +39,7 @@ class RInputSpec(CommandLineInputSpec):
3939 script_file = File (
4040 "pyscript.R" , usedefault = True , desc = "Name of file to write R code to"
4141 )
42-
42+
4343
4444class RCommand (CommandLine ):
4545 """Interface that runs R code
@@ -69,7 +69,7 @@ def set_default_r_cmd(self, r_cmd):
6969 """Set the default R command line for R classes.
7070
7171 This method is used to set values for all R
72- subclasses.
72+ subclasses.
7373 """
7474 self ._cmd = r_cmd
7575
@@ -95,17 +95,19 @@ def _format_arg(self, name, trait_spec, value):
9595 return super (RCommand , self )._format_arg (name , trait_spec , value )
9696
9797 def _gen_r_command (self , argstr , script_lines ):
98- """ Generates commands and, if rfile specified, writes it to disk."""
98+ """Generates commands and, if rfile specified, writes it to disk."""
9999 if not self .inputs .rfile :
100100 # replace newlines with ;, strip comments
101- script = "; " .join ([
102- line
103- for line in script_lines .split ("\n " )
104- if not line .strip ().startswith ("#" )
105- ])
101+ script = "; " .join (
102+ [
103+ line
104+ for line in script_lines .split ("\n " )
105+ if not line .strip ().startswith ("#" )
106+ ]
107+ )
106108 # escape " and $
107- script = script .replace ('"' ,'\\ "' )
108- script = script .replace ('$' , ' \\ $' )
109+ script = script .replace ('"' , '\\ "' )
110+ script = script .replace ("$" , " \\ $" )
109111 else :
110112 script_path = os .path .join (os .getcwd (), self .inputs .script_file )
111113 with open (script_path , "wt" ) as rfile :
0 commit comments