def build(self): """build the scripts and return a string""" if not self.embed: mkdir_recursive(self.output_directory) # get list of script files in build order self.build_order = remove_dups( reduce(lambda a, b: a + glob.glob(b), self.build_targets, [])) self.build_order_output = [self.out_path_of(t) for (t) in self.build_order] self.path_mapping = dict(zip( self.build_order, self.build_order_output)) self.compiled_scripts = {} exceptions, values = partition( lambda x: isinstance(x, Exception), [self.compile_and_process(target) for target in self.build_order]) self.compiled_scripts.update(dict(values)) saneExceptions, insaneExceptions = partition( lambda x: isinstance(x, TaskExecutionException), exceptions) if len(insaneExceptions) != 0: raise insaneExceptions[0] if len(exceptions) != 0: raise TaskExecutionException( "Precompiler Errors (%s):" % type(self).__name__, "\n".join([ x.header + "\n " + x.message.replace("\n", "\n ") for x in exceptions])) return self.collect_output()