[IPython-dev] Add new commandline option from profile

Arnaud Gardelein arnaud@oscopy....
Mon Jun 4 14:30:09 CDT 2012


> What is your *actual* goal here, because I doubt that it is to
> configure a transient object in your config file that will be deleted
> immediately and not importable, which would be the case if defined in
> a config file.
I should had started from here... I'm working on oscopy ( oscopy.org ,
latest features in experimental branch and -dev mailing list for doc).
It started as a pure python app and became some time ago yet another
ipython-based app during 0.10 era.
After making the transition to 0.11, now I want to restore the support
of commandline arguments that it had before the Switch (eg. batch,
interactive, quiet...) before adding others.

> If your goal is to make a particular class of yours configurable, you
> can set its options in this way, and then the only thing you need to
> do is pass the IPython instance's config object to your constructor:
> 
> ipython --Foo.bar=True
> In [1]: from IPython.config.configurable import Configurable
> In [2]: from IPython.utils.traitlets import Bool

> In [3]: class Foo(Configurable):
>    ...:     bar = Bool(False, config=True)

> In [4]: foo = Foo(config=get_ipython().config)

> In [5]: foo.bar
> Out[5]: True
> 
Now I understand that processing of the configurable options shall be
performed not from profile but from the app. I'm not sure of my
understanding, does this means that at time of args processing it is not
mandatory to have ipython's config loader is aware of the Foo class?
What I want to do is to add options to ipython when invoked with oscopy
profile and those options appear when doing 'ipython --profile=ioscopy
--help' as --term-title or --nosep do.
Is there a way to define aliases of --Foo.bar=True as -bar? I had a look
at IPython/core/{interactiveshell,alias,application}.py without success,
where are the manually defined flags? To define some for oscopy, shall
BaseIPythonApplication be derived?

Arnaud.






More information about the IPython-dev mailing list