<s> import sys <EOL> import os <EOL> import string <EOL> def main ( svn_rev = None , outfile = None , build_dir = None ) : <EOL> distpath = '<STR_LIT>' <EOL> if build_dir : <EOL> distpath = '<STR_LIT>' % build_dir <EOL> else : <EOL> distpath = '<STR_LIT>' <EOL> if outfile : <EOL> fp = open ( outfile , '<STR_LIT:w>' ) <EOL> else : <EOL> fp = sys . stdout <EOL> os . chdir ( os . path . dirname ( __file__ ) ) <EOL> topfile = open ( "<STR_LIT>" , "<STR_LIT:r>" ) <EOL> toptext = topfile . read ( ) <EOL> topfile . close ( ) <EOL> fp . write ( toptext ) <EOL> svn_revision = svn_rev <EOL> fp . write ( '<STR_LIT>' % svn_revision ) <EOL> fp . write ( '<STR_LIT>' ) <EOL> fp . write ( '<STR_LIT>' ) <EOL> fp . write ( '<STR_LIT>' % distpath ) <EOL> fp . write ( '<STR_LIT>' % ( distpath , svn_revision ) ) <EOL> headerfile = open ( "<STR_LIT>" , "<STR_LIT:r>" ) <EOL> headertext = headerfile . read ( ) <EOL> headerfile . close ( ) <EOL> fp . write ( headertext ) <EOL> for path , dirs , files in os . walk ( distpath ) : <EOL> realpath = string . replace ( path , distpath , "<STR_LIT>" ) <EOL> fp . write ( '<STR_LIT>' % realpath ) <EOL> for bfffile in files : <EOL> filepath = os . path . join ( os . path . abspath ( path ) , bfffile ) <EOL> fp . write ( '<STR_LIT>' % filepath ) <EOL> midfile = open ( "<STR_LIT>" , "<STR_LIT:r>" ) <EOL> midtext = midfile . read ( ) <EOL> midfile . close ( ) <EOL> fp . write ( midtext ) <EOL> dirlist = [ ] <EOL> for path , dirs , files in os . walk ( distpath ) : <EOL> realpath = string . replace ( path , distpath , "<STR_LIT>" ) <EOL> for bfffile in files : <EOL> fp . write ( '<STR_LIT>' % ( realpath , bfffile ) ) <EOL> fileext = os . path . splitext ( bfffile ) [ <NUM_LIT:1> ] [ <NUM_LIT:1> : ] . strip ( ) <EOL> if fileext == "<STR_LIT>" : <EOL> fp . write ( '<STR_LIT>' % ( realpath , bfffile ) ) <EOL> dirlist . append ( realpath ) <EOL> dirlist . reverse ( ) <EOL> for bffdir in dirlist : <EOL> realdir = string . replace ( bffdir , "<STR_LIT:..>" , "<STR_LIT>" ) <EOL> fp . write ( '<STR_LIT>' % realdir ) <EOL> footerfile = open ( "<STR_LIT>" , "<STR_LIT:r>" ) <EOL> footertext = footerfile . read ( ) <EOL> footerfile . close ( ) <EOL> fp . write ( footertext ) <EOL> fp . close ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
