 import inspect <EOL> class MissingArgs ( Exception ) : <EOL> def __init__ ( self , missing ) : <EOL> self . missing = missing <EOL> def __str__ ( self ) : <EOL> if len ( self . missing ) == <NUM_LIT:1> : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return ( "<STR_LIT>" % <EOL> dict ( num = len ( self . missing ) ) ) 
 def validate_args ( fn , * args , ** kwargs ) : 
 import inspect <EOL> class MissingArgs ( Exception ) : <EOL> def __init__ ( self , missing ) : <EOL> self . missing = missing <EOL> def __str__ ( self ) : <EOL> if len ( self . missing ) == <NUM_LIT:1> : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return ( "<STR_LIT>" % <EOL> dict ( num = len ( self . missing ) ) ) <EOL> def validate_args ( fn , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> argspec = inspect . getargspec ( fn ) <EOL> num_defaults = len ( argspec . defaults or [ ] ) <EOL> required_args = argspec . args [ : len ( argspec . args ) - num_defaults ] <EOL> def isbound ( method ) : <EOL> return getattr ( method , '<STR_LIT>' , None ) is not None <EOL> if isbound ( fn ) : <EOL> required_args . pop ( <NUM_LIT:0> ) <EOL> missing = [ arg for arg in required_args if arg not in kwargs ] <EOL> missing = missing [ len ( args ) : ] <EOL> if missing : <EOL> raise MissingArgs ( missing ) </s>
