<s> import os , sys , time <EOL> from subprocess import Popen <EOL> from struct import pack <EOL> def clean ( dir = "<STR_LIT>" ) : <EOL> for root , dirs , files in os . walk ( dir ) : <EOL> for name in files : <EOL> os . remove ( os . path . join ( root , name ) ) <EOL> def locate ( src_file , dir = "<STR_LIT>" ) : <EOL> for root , dirs , files in os . walk ( dir ) : <EOL> for name in files : <EOL> if src_file == name : <EOL> return root <EOL> return None <EOL> def build ( name ) : <EOL> location = locate ( "<STR_LIT>" % name ) <EOL> if location : <EOL> input = os . path . normpath ( os . path . join ( location , name ) ) <EOL> output = os . path . normpath ( os . path . join ( "<STR_LIT>" , name ) ) <EOL> p = Popen ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" % output , "<STR_LIT>" % input ] ) <EOL> p . wait ( ) <EOL> xmit ( name ) <EOL> else : <EOL> print "<STR_LIT>" % name <EOL> def xmit_dump_ruby ( data , length = <NUM_LIT:16> ) : <EOL> dump = "<STR_LIT>" <EOL> for i in xrange ( <NUM_LIT:0> , len ( data ) , length ) : <EOL> bytes = data [ i : i + length ] <EOL> hex = "<STR_LIT>" % ( '<STR_LIT>' . join ( [ "<STR_LIT>" % ord ( x ) for x in bytes ] ) ) <EOL> if i + length <= len ( data ) : <EOL> hex += "<STR_LIT>" <EOL> dump += "<STR_LIT>" % ( hex ) <EOL> print dump <EOL> def xmit_offset ( data , name , value , match_offset = <NUM_LIT:0> ) : <EOL> offset = data . find ( value ) ; <EOL> if offset != - <NUM_LIT:1> : <EOL> print "<STR_LIT>" % ( name , offset + match_offset ) <EOL> def xmit ( name , dump_ruby = True ) : <EOL> bin = os . path . normpath ( os . path . join ( "<STR_LIT>" , "<STR_LIT>" % name ) ) <EOL> f = open ( bin , '<STR_LIT:rb>' ) <EOL> data = f . read ( ) <EOL> print "<STR_LIT>" % ( name , len ( data ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , "<STR_LIT>" ) <EOL> xmit_offset ( data , "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , "<STR_LIT>" ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , pack ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> xmit_offset ( data , "<STR_LIT>" , "<STR_LIT>" ) <EOL> xmit_offset ( data , "<STR_LIT>" , "<STR_LIT>" ) <EOL> if ( name . find ( "<STR_LIT>" ) >= <NUM_LIT:0> ) : <EOL> null_count = data . count ( "<STR_LIT:\x00>" ) <EOL> if ( null_count > <NUM_LIT:0> ) : <EOL> print "<STR_LIT>" % ( null_count ) <EOL> if dump_ruby : <EOL> xmit_dump_ruby ( data ) <EOL> def main ( argv = None ) : <EOL> if not argv : <EOL> argv = sys . argv <EOL> try : <EOL> if len ( argv ) == <NUM_LIT:1> : <EOL> print "<STR_LIT>" <EOL> else : <EOL> print "<STR_LIT>" % ( time . asctime ( time . localtime ( ) ) ) <EOL> if argv [ <NUM_LIT:1> ] == "<STR_LIT>" : <EOL> clean ( ) <EOL> elif argv [ <NUM_LIT:1> ] == "<STR_LIT:all>" : <EOL> for root , dirs , files in os . walk ( "<STR_LIT>" ) : <EOL> for name in files : <EOL> build ( name [ : - <NUM_LIT:4> ] ) <EOL> for root , dirs , files in os . walk ( "<STR_LIT>" ) : <EOL> for name in files : <EOL> build ( name [ : - <NUM_LIT:4> ] ) <EOL> for root , dirs , files in os . walk ( "<STR_LIT>" ) : <EOL> for name in files : <EOL> build ( name [ : - <NUM_LIT:4> ] ) <EOL> for root , dirs , files in os . walk ( "<STR_LIT>" ) : <EOL> for name in files : <EOL> build ( name [ : - <NUM_LIT:4> ] ) <EOL> for root , dirs , files in os . walk ( "<STR_LIT>" ) : <EOL> for name in files : <EOL> build ( name [ : - <NUM_LIT:4> ] ) <EOL> for root , dirs , files in os . walk ( "<STR_LIT>" ) : <EOL> for name in files : <EOL> build ( name [ : - <NUM_LIT:4> ] ) <EOL> else : <EOL> build ( argv [ <NUM_LIT:1> ] ) <EOL> except Exception , e : <EOL> print "<STR_LIT>" , e <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
