From b103e5d2302a5d4a887f00607f38c44154952b45 2011-05-12 21:33:46 From: MinRK Date: 2011-05-12 21:33:46 Subject: [PATCH] disable string macros --- diff --git a/IPython/config/loader.py b/IPython/config/loader.py index db10c6c..1415338 100644 --- a/IPython/config/loader.py +++ b/IPython/config/loader.py @@ -405,11 +405,7 @@ class KeyValueConfigLoader(CommandLineConfigLoader): if macro is None: raise ValueError("Unrecognized argument: %r"%item) macro = macros[m] - if isinstance(macro, basestring): - # macro is simply a 'Class.trait=value' string - exec_str = 'self.config.' + macro - exec exec_str in locals(), globals() - elif isinstance(macro, (dict, Configurable)): + if isinstance(macro, (dict, Configurable)): # update self.config with Config: self.config.update(macros[m]) else: diff --git a/IPython/config/tests/test_application.py b/IPython/config/tests/test_application.py index 95d1d28..458cf66 100644 --- a/IPython/config/tests/test_application.py +++ b/IPython/config/tests/test_application.py @@ -57,7 +57,7 @@ class MyApp(Application): shortnames = dict(i='Foo.i',j='Foo.j',name='Foo.name', enabled='Bar.enabled', log_level='MyApp.log_level') - macros = dict(enable='Bar.enabled=True', disable='Bar.enabled=False') + macros = dict(enable={'Bar': {'enabled' : True}}, disable={'Bar': {'enabled' : False}}) macro_help = dict( enable="""Enable bar""", diff --git a/docs/examples/core/appconfig.py b/docs/examples/core/appconfig.py index ad23b30..b09ed61 100644 --- a/docs/examples/core/appconfig.py +++ b/docs/examples/core/appconfig.py @@ -44,29 +44,29 @@ class Foo(Configurable): """ - i = Int(0, config=True, shortname='i', help="The integer i.") - j = Int(1, config=True, shortname='j', help="The integer j.") - name = Unicode(u'Brian', config=True, shortname='name', help="First name.") + i = Int(0, config=True, help="The integer i.") + j = Int(1, config=True, help="The integer j.") + name = Unicode(u'Brian', config=True, help="First name.") class Bar(Configurable): - enabled = Bool(True, config=True, shortname="enabled", help="Enable bar.") + enabled = Bool(True, config=True, help="Enable bar.") class MyApp(Application): app_name = Unicode(u'myapp') - running = Bool(False, config=True, shortname="running", + running = Bool(False, config=True, help="Is the app running?") classes = List([Bar, Foo]) - config_file = Unicode(u'', config=True, shortname="config_file", + config_file = Unicode(u'', config=True, help="Load this config file") - shortnames = dict(i='Foo.i',j='Foo.j',name='Foo.name', + shortnames = dict(i='Foo.i',j='Foo.j',name='Foo.name', running='MyApp.running', enabled='Bar.enabled') - macros = dict(enable='Bar.enabled=True', disable='Bar.enabled=False') + macros = dict(enable={'Bar': {'enabled' : True}}, disable={'Bar': {'enabled' : False}}) macro_help = dict( enable="""Set Bar.enabled to True""", disable="""Set Bar.enabled to False""" @@ -91,6 +91,7 @@ def main(): app.init_bar() print "app.config:" print app.config + print app.bar.enabled if __name__ == "__main__":