<s> import os <EOL> import sys <EOL> if sys . version_info [ <NUM_LIT:0> ] > <NUM_LIT:2> : <EOL> long = int <EOL> basestring = str <EOL> ROBOT_LISTENER_API_VERSION = '<STR_LIT:2>' <EOL> OUTFILE = open ( os . path . join ( os . getenv ( '<STR_LIT>' ) , '<STR_LIT>' ) , '<STR_LIT:w>' ) <EOL> START = '<STR_LIT>' <EOL> END = START + '<STR_LIT>' <EOL> SUITE = '<STR_LIT>' <EOL> TEST = '<STR_LIT>' <EOL> KW = '<STR_LIT>' <EOL> EXPECTED_TYPES = { '<STR_LIT>' : ( int , long ) , '<STR_LIT>' : list , '<STR_LIT:args>' : list , <EOL> '<STR_LIT>' : list , '<STR_LIT>' : dict , '<STR_LIT>' : list , <EOL> '<STR_LIT>' : list , '<STR_LIT>' : int } <EOL> def start_suite ( name , attrs ) : <EOL> _verify_attrs ( '<STR_LIT>' , attrs , START + SUITE ) <EOL> def end_suite ( name , attrs ) : <EOL> _verify_attrs ( '<STR_LIT>' , attrs , END + SUITE + '<STR_LIT>' ) <EOL> def start_test ( name , attrs ) : <EOL> _verify_attrs ( '<STR_LIT>' , attrs , START + TEST ) <EOL> def end_test ( name , attrs ) : <EOL> _verify_attrs ( '<STR_LIT>' , attrs , END + TEST + '<STR_LIT:message>' ) <EOL> def start_keyword ( name , attrs ) : <EOL> _verify_attrs ( '<STR_LIT>' , attrs , START + KW ) <EOL> _verify_name ( name , ** attrs ) <EOL> def end_keyword ( name , attrs ) : <EOL> _verify_attrs ( '<STR_LIT>' , attrs , END + KW ) <EOL> _verify_name ( name , ** attrs ) <EOL> def _verify_attrs ( method_name , attrs , names ) : <EOL> names = names . split ( ) <EOL> OUTFILE . write ( method_name + '<STR_LIT:\n>' ) <EOL> if len ( names ) != len ( attrs ) : <EOL> OUTFILE . write ( '<STR_LIT>' ) <EOL> OUTFILE . write ( '<STR_LIT>' % ( names , attrs . keys ( ) ) ) <EOL> return <EOL> for name in names : <EOL> value = attrs [ name ] <EOL> exp_type = EXPECTED_TYPES . get ( name , basestring ) <EOL> if isinstance ( value , exp_type ) : <EOL> OUTFILE . write ( '<STR_LIT>' % ( name , _format ( value ) ) ) <EOL> else : <EOL> OUTFILE . write ( '<STR_LIT>' <EOL> % ( name , value , exp_type , type ( value ) ) ) <EOL> def _format ( value ) : <EOL> if isinstance ( value , basestring ) : <EOL> return value <EOL> if isinstance ( value , ( int , long ) ) : <EOL> return str ( value ) <EOL> if isinstance ( value , list ) : <EOL> return '<STR_LIT>' % '<STR_LIT:U+002CU+0020>' . join ( _format ( item ) for item in value ) <EOL> if isinstance ( value , dict ) : <EOL> return '<STR_LIT>' % '<STR_LIT:U+002CU+0020>' . join ( '<STR_LIT>' % ( _format ( k ) , _format ( v ) ) <EOL> for k , v in value . items ( ) ) <EOL> raise ValueError ( value ) <EOL> def _verify_name ( name , kwname = None , libname = None , ** ignored ) : <EOL> if libname : <EOL> if name != '<STR_LIT>' % ( libname , kwname ) : <EOL> OUTFILE . write ( "<STR_LIT>" % ( name , libname , kwname ) ) <EOL> else : <EOL> if name != kwname : <EOL> OUTFILE . write ( "<STR_LIT>" % ( name , kwname ) ) <EOL> if libname != '<STR_LIT>' : <EOL> OUTFILE . write ( "<STR_LIT>" % libname ) <EOL> def close ( ) : <EOL> OUTFILE . close ( ) </s>
