<s> import argparse <EOL> from inspect import getargspec <EOL> from functools import partial <EOL> test_args = None <EOL> def supply_args ( func ) : <EOL> args , _ , _ , defaults = getargspec ( func ) <EOL> parser = argparse . ArgumentParser ( ) <EOL> defaults = defaults or [ ] <EOL> keyword_names = args [ - len ( defaults ) : ] if defaults else [ ] <EOL> keywords = { k : v for k , v in zip ( keyword_names , defaults ) } <EOL> args = args [ : - len ( keyword_names ) ] if keywords else args <EOL> for arg in args : <EOL> parser . add_argument ( arg ) <EOL> for keyword , value in keywords . iteritems ( ) : <EOL> parser . add_argument ( '<STR_LIT>' + keyword , default = value ) <EOL> kwargs , extras = parser . parse_known_args ( test_args ) <EOL> kwargs = vars ( kwargs ) <EOL> combined_args = [ kwargs [ k ] for k in args + keyword_names ] + extras <EOL> return partial ( func , * combined_args ) </s>
