@@ -164,24 +164,6 @@ def get_source(self, source_path):
164164 with open (self .get_full_source_path (source_path )) as source :
165165 return source .read ()
166166
167- def write_output (self , output , source_path ):
168- """ Write the compiled output to a file.
169-
170- :param output: compiled code
171- :type output: str
172- :param source_path: relative path to a source file
173- :type source_path: str
174-
175- """
176- output_path = self .get_full_output_path (source_path )
177- output_dir = os .path .dirname (output_path )
178- if not os .path .exists (output_dir ):
179- os .makedirs (output_dir )
180-
181- compiled_file = open (output_path , "w+" )
182- compiled_file .write (output )
183- compiled_file .close ()
184-
185167 def compile (self , source_path , from_management = False ):
186168 """ Compile the given source path and return relative path to the compiled file.
187169 Raise ValueError is the source file type is not supported.
@@ -198,18 +180,19 @@ def compile(self, source_path, from_management=False):
198180 raise ValueError ("'{0}' file type is not supported by '{1}'" .format (
199181 source_path , self .__class__ .__name__
200182 ))
183+
184+ compliled_path = self .get_output_path (source_path )
185+
201186 if self .should_compile (source_path , from_management = from_management ):
202187
203- compiled = self .compile_file (source_path )
204- compiled = self .postprocess (compiled , source_path )
205- self .write_output (compiled , source_path )
188+ compliled_path = self .compile_file (source_path )
206189
207190 if self .supports_dependencies :
208191 self .update_dependencies (source_path , self .find_dependencies (source_path ))
209192
210193 logging .info ("Compiled: '{0}'" .format (source_path ))
211194
212- return self . get_output_path ( source_path )
195+ return compliled_path
213196
214197 def compile_lazy (self , source_path ):
215198 """ Return a lazy object which, when translated to string, compiles the specified source path and returns
@@ -226,7 +209,7 @@ def compile_lazy(self, source_path):
226209 compile_lazy = functional .lazy (compile_lazy , six .text_type )
227210
228211 def compile_file (self , source_path ):
229- """ Compile the source file. Return the compiled code .
212+ """ Compile the source file. Return the relative path to compiled file .
230213 May raise a StaticCompilationError if something goes wrong with compilation.
231214
232215 :param source_path: path to the source file
@@ -247,18 +230,6 @@ def compile_source(self, source):
247230 """
248231 raise NotImplementedError
249232
250- # noinspection PyMethodMayBeStatic,PyUnusedLocal
251- def postprocess (self , compiled , source_path ):
252- """ Post-process the compiled code.
253-
254- :param compiled: compiled code
255- :type compiled: str
256- :param source_path: relative path to a source file
257- :type source_path: str
258- :returns: str
259- """
260- return compiled
261-
262233 def find_dependencies (self , source_path ):
263234 """ Find the dependencies for the given source file.
264235
0 commit comments