@@ -35,12 +35,12 @@ def _compile(input_path):
35
35
infile = self .storage .path (input_path )
36
36
except NotImplementedError :
37
37
infile = finders .find (input_path )
38
- outfile = self .output_path (infile , compiler .output_extension )
38
+ outfile = compiler .output_path (infile , compiler .output_extension )
39
39
outdated = compiler .is_outdated (infile , outfile )
40
40
compiler .compile_file (infile , outfile ,
41
41
outdated = outdated , force = force )
42
42
43
- return self .output_path (input_path , compiler .output_extension )
43
+ return compiler .output_path (input_path , compiler .output_extension )
44
44
else :
45
45
return input_path
46
46
@@ -53,10 +53,6 @@ def _compile(input_path):
53
53
with futures .ThreadPoolExecutor (max_workers = multiprocessing .cpu_count ()) as executor :
54
54
return list (executor .map (_compile , paths ))
55
55
56
- def output_path (self , path , extension ):
57
- path = os .path .splitext (path )
58
- return '.' .join ((path [0 ], extension ))
59
-
60
56
61
57
class CompilerBase (object ):
62
58
def __init__ (self , verbose , storage ):
@@ -78,6 +74,10 @@ def read_file(self, path):
78
74
file .close ()
79
75
return content
80
76
77
+ def output_path (self , path , extension ):
78
+ path = os .path .splitext (path )
79
+ return '.' .join ((path [0 ], extension ))
80
+
81
81
def is_outdated (self , infile , outfile ):
82
82
if not self .storage .exists (outfile ):
83
83
return True
@@ -111,6 +111,7 @@ def execute_command(self, command, cwd=None, stdout_captured=None):
111
111
else :
112
112
argument_list .extend (flattening_arg )
113
113
114
+ stdout = None
114
115
try :
115
116
# We always catch stdout in a file, but we may not have a use for it.
116
117
temp_file_container = cwd or os .path .dirname (stdout_captured or "" ) or os .getcwd ()
@@ -135,7 +136,8 @@ def execute_command(self, command, cwd=None, stdout_captured=None):
135
136
raise CompilerError (e )
136
137
finally :
137
138
# Decide what to do with captured stdout.
138
- if stdout_captured :
139
- os .rename (stdout .name , os .path .join (cwd or os .curdir , stdout_captured ))
140
- else :
141
- os .remove (stdout .name )
139
+ if stdout :
140
+ if stdout_captured :
141
+ os .rename (stdout .name , os .path .join (cwd or os .curdir , stdout_captured ))
142
+ else :
143
+ os .remove (stdout .name )
0 commit comments