#NEWLINE# def materialize( self ) : #NEWLINE# #INDENT# 'Convert a collection of commands into a full Python code definition' #NEWLINE# main_commands = [ ] #NEWLINE# body_commands = [ ] #NEWLINE# main_end = None #NEWLINE# main = None #NEWLINE# for cmd in self . commands : #NEWLINE# #INDENT# if ( main_end is not None ) : #NEWLINE# #INDENT# if cmd . is_main_end ( main_end ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# main = MainMethod ( self , main_commands , end_offset = main_end , verbosity = self . verbosity ) #NEWLINE# #UNINDENT# except IgnoreBlock : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# main_end = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# main_commands . append ( cmd ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if cmd . is_main_start ( ) : #NEWLINE# #INDENT# if ( main is not None ) : #NEWLINE# #INDENT# print ( 'Found duplicate main block... replacing previous main' ) #NEWLINE# #UNINDENT# main_end = cmd . operation . target #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# body_commands . append ( cmd ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . body = StaticBlock ( self , body_commands ) #NEWLINE# if ( main is None ) : #NEWLINE# #INDENT# if self . verbosity : #NEWLINE# #INDENT# print ( 'Adding default main method...' ) #NEWLINE# #UNINDENT# main = MainMethod ( self , [ ] , verbosity = self . verbosity ) #NEWLINE# #UNINDENT# self . methods . append ( main ) #NEWLINE# self . body . materialize ( ) #NEWLINE# for method in self . methods : #NEWLINE# #INDENT# method . materialize ( ) #NEWLINE# #UNINDENT# for klass in self . classes : #NEWLINE# #INDENT# klass . materialize ( )