<s> from __future__ import absolute_import <EOL> from __future__ import print_function <EOL> import re <EOL> import sys <EOL> import os <EOL> def getRamId ( oid , sid ) : <EOL> if <NUM_LIT:0> <= sid and sid <= <NUM_LIT> : <EOL> return <NUM_LIT:0> <EOL> if <NUM_LIT:32> <= sid and sid <= <NUM_LIT> : <EOL> return <NUM_LIT:1> <EOL> if <NUM_LIT:64> <= sid and sid <= <NUM_LIT> : <EOL> return <NUM_LIT:2> <EOL> if <NUM_LIT> <= sid and sid <= <NUM_LIT> : <EOL> return <NUM_LIT:3> <EOL> def getRamSubId ( oid , sid ) : <EOL> if <NUM_LIT:0> <= sid and sid <= <NUM_LIT> : <EOL> return sid <EOL> if <NUM_LIT:32> <= sid and sid <= <NUM_LIT> : <EOL> return sid - <NUM_LIT:32> <EOL> if <NUM_LIT:64> <= sid and sid <= <NUM_LIT> : <EOL> return sid - <NUM_LIT:64> <EOL> if <NUM_LIT> <= sid and sid <= <NUM_LIT> : <EOL> return sid - <NUM_LIT> <EOL> def getChannelId ( oid , sid ) : <EOL> return oid <EOL> def getChannelSubId ( oid , sid ) : <EOL> return sid <EOL> def getRegisterId ( oid , sid ) : <EOL> return oid <EOL> def getRegisterSubId ( oid , sid ) : <EOL> return sid <EOL> def main ( ) : <EOL> f = open ( sys . argv [ <NUM_LIT:1> ] , '<STR_LIT:r>' ) <EOL> lines = f . readlines ( ) <EOL> output = [ ] <EOL> p_thread = re . compile ( '<STR_LIT>' ) <EOL> p_thread_id = re . compile ( '<STR_LIT>' ) <EOL> p_object_id = re . compile ( '<STR_LIT>' ) <EOL> p_width = re . compile ( '<STR_LIT>' ) <EOL> p_depth = re . compile ( '<STR_LIT>' ) <EOL> p_indexwidth = re . compile ( '<STR_LIT>' ) <EOL> p_logdepth = re . compile ( '<STR_LIT>' ) <EOL> p_sub_id = re . compile ( '<STR_LIT>' ) <EOL> module_name = None <EOL> thread_name = None <EOL> thread_id = None <EOL> object_id = None <EOL> sub_id = None <EOL> width = None <EOL> indexwidth = None <EOL> depth = None <EOL> mode = False <EOL> sub_id_num = None <EOL> sub_id_base = None <EOL> buffer = [ ] <EOL> print ( "<STR_LIT>" ) <EOL> for line in lines : <EOL> if not mode : <EOL> m = p_thread . match ( line ) <EOL> if m : <EOL> thread_name = re . match ( '<STR_LIT>' , m . group ( <NUM_LIT:2> ) ) . group ( <NUM_LIT:1> ) <EOL> module_name = re . search ( '<STR_LIT>' , line ) . group ( <NUM_LIT:1> ) <EOL> mode = True <EOL> buffer = [ ] <EOL> buffer . append ( line ) <EOL> continue <EOL> else : <EOL> m = p_thread_id . match ( line ) <EOL> if m : <EOL> tid_str = m . group ( <NUM_LIT:2> ) [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> thread_id = re . match ( '<STR_LIT>' , tid_str ) . group ( <NUM_LIT:2> ) <EOL> buffer . append ( line ) <EOL> continue <EOL> m = p_object_id . match ( line ) <EOL> if m : <EOL> oid_str = m . group ( <NUM_LIT:2> ) [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> object_id = re . match ( '<STR_LIT>' , oid_str ) . group ( <NUM_LIT:2> ) <EOL> buffer . append ( line ) <EOL> continue <EOL> m = p_width . match ( line ) <EOL> if m : <EOL> width_str = m . group ( <NUM_LIT:2> ) <EOL> width = re . match ( '<STR_LIT>' , width_str ) . group ( <NUM_LIT:1> ) <EOL> buffer . append ( line ) <EOL> continue <EOL> m = p_depth . match ( line ) <EOL> if m : <EOL> depth_str = m . group ( <NUM_LIT:2> ) <EOL> depth = re . match ( '<STR_LIT>' , depth_str ) . group ( <NUM_LIT:1> ) <EOL> buffer . append ( line ) <EOL> continue <EOL> m = p_indexwidth . match ( line ) <EOL> if m : <EOL> indexwidth_str = m . group ( <NUM_LIT:2> ) <EOL> indexwidth = re . match ( '<STR_LIT>' , indexwidth_str ) . group ( <NUM_LIT:1> ) <EOL> buffer . append ( line ) <EOL> continue <EOL> m = p_logdepth . match ( line ) <EOL> if m : <EOL> logdepth_str = m . group ( <NUM_LIT:2> ) <EOL> logdepth = re . match ( '<STR_LIT>' , logdepth_str ) . group ( <NUM_LIT:1> ) <EOL> buffer . append ( line ) <EOL> continue <EOL> m = p_sub_id . match ( line ) <EOL> if m : <EOL> sid_str = m . group ( <NUM_LIT:2> ) <EOL> sub_id_m = re . search ( '<STR_LIT>' , sid_str ) <EOL> sub_id = sub_id_m . group ( <NUM_LIT:0> ) <EOL> sub_id_num = sub_id_m . group ( <NUM_LIT:2> ) <EOL> sub_id_base = ( <NUM_LIT:10> if sub_id_m . group ( <NUM_LIT:1> ) . count ( "<STR_LIT>" ) > <NUM_LIT:0> else <EOL> <NUM_LIT:16> if sub_id_m . group ( <NUM_LIT:1> ) . count ( "<STR_LIT>" ) > <NUM_LIT:0> else <EOL> <NUM_LIT:2> if sub_id_m . group ( <NUM_LIT:1> ) . count ( "<STR_LIT>" ) > <NUM_LIT:0> else <EOL> <NUM_LIT:10> ) <EOL> buffer . append ( line ) <EOL> continue <EOL> if mode : <EOL> print ( "<STR_LIT>" % module_name ) <EOL> print ( "<STR_LIT>" % '<STR_LIT>' . join ( ( thread_name [ : - <NUM_LIT:1> ] , '<STR_LIT:_>' , thread_id , '<STR_LIT:">' ) ) ) <EOL> print ( "<STR_LIT>" % thread_id ) <EOL> if module_name . count ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" % getRamId ( int ( object_id ) , int ( sub_id_num , sub_id_base ) ) ) <EOL> if module_name . count ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" % getChannelId ( int ( object_id ) , int ( sub_id_num , sub_id_base ) ) ) <EOL> if module_name . count ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" % getRegisterId ( int ( object_id ) , int ( sub_id_num , sub_id_base ) ) ) <EOL> if module_name . count ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" % getRamSubId ( int ( object_id ) , int ( sub_id_num , sub_id_base ) ) ) <EOL> if module_name . count ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" % '<STR_LIT:0>' ) <EOL> if module_name . count ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" % '<STR_LIT:0>' ) <EOL> print ( "<STR_LIT>" % indexwidth ) <EOL> print ( "<STR_LIT>" % width ) <EOL> print ( "<STR_LIT>" % thread_name ) <EOL> print ( '<STR_LIT>' . join ( buffer [ <NUM_LIT:1> : ] ) ) <EOL> mode = False <EOL> print ( line , end = '<STR_LIT>' ) <EOL> main ( ) </s>
