From 61ad038ba23fbcccd50591b5b62bf5b2c0a00239 2012-09-12 13:00:09 From: Takafumi Arakaki Date: 2012-09-12 13:00:09 Subject: [PATCH] Add new decorator magic_arguments.defaults --- diff --git a/IPython/core/magic_arguments.py b/IPython/core/magic_arguments.py index 3a9cca9..ec539f8 100644 --- a/IPython/core/magic_arguments.py +++ b/IPython/core/magic_arguments.py @@ -191,6 +191,24 @@ class argument(ArgDecorator): return None +class defaults(ArgDecorator): + """ Store arguments and keywords to pass to set_defaults(). + + Instances also serve to decorate command methods. + """ + def __init__(self, *args, **kwds): + self.args = args + self.kwds = kwds + + def add_to_parser(self, parser, group): + """ Add this object's information to the parser. + """ + if group is not None: + parser = group + parser.set_defaults(*self.args, **self.kwds) + return None + + class argument_group(ArgDecorator): """ Store arguments and keywords to pass to add_argument_group().