<s> import os <EOL> import re <EOL> def get ( filename ) : <EOL> for path in [ "<STR_LIT:..>" , "<STR_LIT:.>" ] : <EOL> filepath = os . path . join ( path , filename ) <EOL> if os . path . exists ( filepath ) : <EOL> with open ( filepath ) as infile : <EOL> code = infile . read ( ) <EOL> comment = '<STR_LIT>' % filename <EOL> return comment + code <EOL> return '<STR_LIT>' % filename <EOL> code = """<STR_LIT>""" <EOL> re_include = re . compile ( '<STR_LIT>' ) <EOL> includes = [ ] <EOL> def replace ( match ) : <EOL> filename = match . group ( "<STR_LIT:filename>" ) <EOL> if filename not in includes : <EOL> includes . append ( filename ) <EOL> text = get ( filename ) <EOL> text += '<STR_LIT>' % filename <EOL> return text <EOL> return '<STR_LIT>' <EOL> while re . search ( re_include , code ) : <EOL> code = re . sub ( re_include , replace , code ) <EOL> print ( code ) </s>
