<s> from commands import getoutput <EOL> from argparse import ArgumentParser <EOL> from os import system <EOL> import sys <EOL> """<STR_LIT>""" <EOL> def check ( ) : <EOL> """<STR_LIT>""" <EOL> found = True <EOL> if getoutput ( "<STR_LIT>" ) == '<STR_LIT>' : <EOL> found = False <EOL> elif getoutput ( "<STR_LIT>" ) == '<STR_LIT>' : <EOL> found = False <EOL> return found <EOL> def get_output ( inf , arch = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> output = '<STR_LIT>' <EOL> if '<STR_LIT>' in inf : <EOL> tmp = getoutput ( "<STR_LIT>" % ( arch , inf ) ) <EOL> if '<STR_LIT:error>' in tmp : <EOL> print '<STR_LIT>' , tmp <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> inf = inf . replace ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> tmp = getoutput ( "<STR_LIT>" % inf ) <EOL> opcodes = '<STR_LIT>' <EOL> for line in tmp . split ( '<STR_LIT:\n>' ) [ <NUM_LIT:7> : ] : <EOL> tmp = line . split ( '<STR_LIT::>' , <NUM_LIT:1> ) <EOL> if len ( tmp ) > <NUM_LIT:1> and len ( tmp [ <NUM_LIT:1> ] ) > <NUM_LIT:0> : tmp = tmp [ <NUM_LIT:1> ] <EOL> else : continue <EOL> tmp = '<STR_LIT>' . join ( tmp ) . split ( '<STR_LIT:\t>' ) <EOL> if len ( tmp ) > <NUM_LIT:1> : tmp = tmp [ <NUM_LIT:1> ] . strip ( ) . replace ( '<STR_LIT:U+0020>' , '<STR_LIT>' ) <EOL> if '<STR_LIT:<>' in tmp : continue <EOL> opcodes += tmp <EOL> return opcodes <EOL> def encode ( lbyte ) : <EOL> """<STR_LIT>""" <EOL> formatted_lbyte = '<STR_LIT>' . join ( [ "<STR_LIT>" + lbyte [ idx ] + lbyte [ idx + <NUM_LIT:1> ] for idx in range ( <NUM_LIT:0> , len ( lbyte ) - <NUM_LIT:1> , <NUM_LIT:2> ) ] ) <EOL> return formatted_lbyte <EOL> def format_output ( dmp , width = <NUM_LIT:8> ) : <EOL> """<STR_LIT>""" <EOL> dmp = dmp . split ( '<STR_LIT>' ) [ <NUM_LIT:1> : ] <EOL> return '<STR_LIT>' + '<STR_LIT>' . join ( [ '<STR_LIT>' . join ( dmp [ i : i + width ] ) for i in range ( <NUM_LIT:0> , len ( dmp ) , width ) ] ) <EOL> def compile_instruction ( instruction , arch = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> with open ( '<STR_LIT>' , '<STR_LIT>' ) as f : <EOL> f . write ( instruction . decode ( '<STR_LIT>' ) + '<STR_LIT:\n>' ) <EOL> ops = encode ( get_output ( '<STR_LIT>' , arch ) ) <EOL> system ( '<STR_LIT>' ) <EOL> return ops <EOL> def run ( options ) : <EOL> """<STR_LIT>""" <EOL> if options . inf : <EOL> dmp = encode ( get_output ( options . inf , options . arch ) ) <EOL> elif options . instruction : <EOL> dmp = compile_instruction ( options . instruction , options . arch ) <EOL> print '<STR_LIT>' , format_output ( dmp ) <EOL> if options . output : <EOL> with open ( options . output , '<STR_LIT:w>' ) as f : <EOL> f . write ( format_output ( dmp ) ) <EOL> def arguments ( ) : <EOL> """<STR_LIT>""" <EOL> parser = ArgumentParser ( ) <EOL> parser . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' , metavar = '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , default = '<STR_LIT>' ) <EOL> if len ( sys . argv ) < <NUM_LIT:2> : <EOL> parser . print_help ( ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> return parser . parse_args ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> if not check ( ) : <EOL> print '<STR_LIT>' <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> run ( arguments ( ) ) </s>
