<s> import sys <EOL> import binascii <EOL> import Trace <EOL> import BinaryCodec <EOL> from optparse import OptionParser <EOL> def parseCommandLine ( args ) : <EOL> parser = OptionParser ( usage = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , help = "<STR_LIT>" ) <EOL> options , args = parser . parse_args ( args ) <EOL> return options , args <EOL> options , args = parseCommandLine ( sys . argv [ <NUM_LIT:1> : ] ) <EOL> if not args : <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> trace = Trace . Trace ( ) <EOL> reader = BinaryCodec . Reader ( trace , open ( args [ <NUM_LIT:0> ] , "<STR_LIT:rb>" ) ) <EOL> if options . tokens : <EOL> version = reader . file . read ( <NUM_LIT:4> ) <EOL> print "<STR_LIT>" , version <EOL> if not version . startswith ( "<STR_LIT>" ) : <EOL> reader . file . seek ( <NUM_LIT:0> ) <EOL> while <NUM_LIT:1> : <EOL> tokenStart = reader . file . tell ( ) <EOL> token = BinaryCodec . Token . read ( reader . file ) <EOL> tokenEnd = reader . file . tell ( ) <EOL> if not token : <EOL> break <EOL> reader . file . seek ( tokenStart ) <EOL> tokenData = reader . file . read ( tokenEnd - tokenStart ) <EOL> reader . file . seek ( tokenEnd ) <EOL> tokenData = binascii . hexlify ( tokenData ) <EOL> print "<STR_LIT>" % tokenStart , <EOL> for i in range ( <NUM_LIT:0> , len ( tokenData ) , <NUM_LIT:2> ) : <EOL> print tokenData [ i : i + <NUM_LIT:2> ] , <EOL> print <EOL> print "<STR_LIT>" , token <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> reader . load ( ) <EOL> for event in trace . events : <EOL> for array in event . modifiedArrays : <EOL> for value in event . values . values ( ) : <EOL> if isinstance ( value , Trace . Array ) and value . id == array . id : <EOL> break <EOL> else : <EOL> print "<STR_LIT>" % ( event . seq , event . time , array . id , array ) <EOL> print "<STR_LIT>" % ( event . seq , event . time , event . name , "<STR_LIT:U+002CU+0020>" . join ( [ "<STR_LIT>" % ( k , v ) for k , v in event . values . items ( ) if k ] ) ) , <EOL> if None in event . values : <EOL> print "<STR_LIT>" , event . values [ None ] <EOL> else : <EOL> print </s>
