<s> import sys <EOL> try : <EOL> from xmlrpclib import Binary <EOL> except ImportError : <EOL> from xmlrpc . client import Binary <EOL> basestring = str <EOL> from remoteserver import RemoteServer <EOL> class Arguments ( object ) : <EOL> def argument_should_be ( self , argument , expected , binary = False ) : <EOL> if binary : <EOL> argument = self . _handle_binary ( argument ) <EOL> expected = eval ( expected ) <EOL> assert argument == expected , '<STR_LIT>' % ( argument , expected ) <EOL> def _handle_binary ( self , arg , required = True ) : <EOL> if isinstance ( arg , list ) : <EOL> return self . _handle_binary_in_list ( arg ) <EOL> if isinstance ( arg , dict ) : <EOL> return self . _handle_binary_in_dict ( arg ) <EOL> assert isinstance ( arg , Binary ) or not required , '<STR_LIT>' <EOL> return arg . data if isinstance ( arg , Binary ) else arg <EOL> def _handle_binary_in_list ( self , arg ) : <EOL> assert any ( isinstance ( a , Binary ) for a in arg ) , '<STR_LIT>' <EOL> return [ self . _handle_binary ( a , required = False ) for a in arg ] <EOL> def _handle_binary_in_dict ( self , arg ) : <EOL> assert any ( isinstance ( key , Binary ) or isinstance ( value , Binary ) <EOL> for key , value in arg . items ( ) ) , '<STR_LIT>' <EOL> return dict ( ( self . _handle_binary ( key , required = False ) , <EOL> self . _handle_binary ( value , required = False ) ) <EOL> for key , value in arg . items ( ) ) <EOL> def kwarg_should_be ( self , ** kwargs ) : <EOL> self . argument_should_be ( ** kwargs ) <EOL> def no_arguments ( self ) : <EOL> return self . _format_args ( ) <EOL> def one_argument ( self , arg ) : <EOL> return self . _format_args ( arg ) <EOL> def two_arguments ( self , arg1 , arg2 ) : <EOL> return self . _format_args ( arg1 , arg2 ) <EOL> def five_arguments ( self , arg1 , arg2 , arg3 , arg4 , arg5 ) : <EOL> return self . _format_args ( arg1 , arg2 , arg3 , arg4 , arg5 ) <EOL> def arguments_with_default_values ( self , arg1 , arg2 = <NUM_LIT:2> , arg3 = '<STR_LIT:3>' ) : <EOL> return self . _format_args ( arg1 , arg2 , arg3 ) <EOL> def varargs ( self , * args ) : <EOL> return self . _format_args ( * args ) <EOL> def required_defaults_and_varargs ( self , req , default = '<STR_LIT>' , * varargs ) : <EOL> return self . _format_args ( req , default , * varargs ) <EOL> def kwargs ( self , ** kwargs ) : <EOL> return self . _format_args ( ** kwargs ) <EOL> def args_and_kwargs ( self , arg1 = '<STR_LIT>' , arg2 = '<STR_LIT>' , ** kwargs ) : <EOL> return self . _format_args ( arg1 , arg2 , ** kwargs ) <EOL> def varargs_and_kwargs ( self , * varargs , ** kwargs ) : <EOL> return self . _format_args ( * varargs , ** kwargs ) <EOL> def args_varargs_and_kwargs ( self , arg1 = '<STR_LIT>' , arg2 = '<STR_LIT>' , <EOL> * varargs , ** kwargs ) : <EOL> return self . _format_args ( arg1 , arg2 , * varargs , ** kwargs ) <EOL> def _format_args ( self , * args , ** kwargs ) : <EOL> args += tuple ( '<STR_LIT>' % ( k , self . _type ( v ) ) <EOL> for k , v in sorted ( kwargs . items ( ) ) ) <EOL> return '<STR_LIT:U+002CU+0020>' . join ( self . _type ( a ) for a in args ) <EOL> def _type ( self , arg ) : <EOL> if not isinstance ( arg , basestring ) : <EOL> return '<STR_LIT>' % ( arg , type ( arg ) . __name__ ) <EOL> return arg <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> RemoteServer ( Arguments ( ) , * sys . argv [ <NUM_LIT:1> : ] ) </s>
