@@ -21,15 +21,15 @@ def get_r_command():
21
21
if "NIPYPE_NO_R" in os .environ :
22
22
return None
23
23
r_cmd = os .getenv ("RCMD" , default = "R" )
24
-
24
+
25
25
return r_cmd if which (r_cmd ) else None
26
26
27
27
28
28
no_r = get_r_command () is None
29
29
30
30
31
31
class RInputSpec (CommandLineInputSpec ):
32
- """ Basic expected inputs to R interface """
32
+ """Basic expected inputs to R interface"""
33
33
34
34
script = traits .Str (
35
35
argstr = '-e "%s"' , desc = "R code to run" , mandatory = True , position = - 1
@@ -39,7 +39,7 @@ class RInputSpec(CommandLineInputSpec):
39
39
script_file = File (
40
40
"pyscript.R" , usedefault = True , desc = "Name of file to write R code to"
41
41
)
42
-
42
+
43
43
44
44
class RCommand (CommandLine ):
45
45
"""Interface that runs R code
@@ -69,7 +69,7 @@ def set_default_r_cmd(self, r_cmd):
69
69
"""Set the default R command line for R classes.
70
70
71
71
This method is used to set values for all R
72
- subclasses.
72
+ subclasses.
73
73
"""
74
74
self ._cmd = r_cmd
75
75
@@ -95,17 +95,19 @@ def _format_arg(self, name, trait_spec, value):
95
95
return super (RCommand , self )._format_arg (name , trait_spec , value )
96
96
97
97
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."""
99
99
if not self .inputs .rfile :
100
100
# 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
+ )
106
108
# escape " and $
107
- script = script .replace ('"' ,'\\ "' )
108
- script = script .replace ('$' , ' \\ $' )
109
+ script = script .replace ('"' , '\\ "' )
110
+ script = script .replace ("$" , " \\ $" )
109
111
else :
110
112
script_path = os .path .join (os .getcwd (), self .inputs .script_file )
111
113
with open (script_path , "wt" ) as rfile :
0 commit comments