<br><br><div class="gmail_quote">On Mon, Jun 4, 2012 at 12:30 PM, Arnaud Gardelein <span dir="ltr"><<a href="mailto:arnaud@oscopy.org" target="_blank">arnaud@oscopy.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">> What is your *actual* goal here, because I doubt that it is to<br>
> configure a transient object in your config file that will be deleted<br>
> immediately and not importable, which would be the case if defined in<br>
> a config file.<br>
</div>I should had started from here... I'm working on oscopy ( <a href="http://oscopy.org" target="_blank">oscopy.org</a> ,<br>
latest features in experimental branch and -dev mailing list for doc).<br>
It started as a pure python app and became some time ago yet another<br>
ipython-based app during 0.10 era.<br>
After making the transition to 0.11, now I want to restore the support<br>
of commandline arguments that it had before the Switch (eg. batch,<br>
interactive, quiet...) before adding others.<br>
<div class="im"><br>
> If your goal is to make a particular class of yours configurable, you<br>
> can set its options in this way, and then the only thing you need to<br>
> do is pass the IPython instance's config object to your constructor:<br>
><br>
> ipython --Foo.bar=True<br>
> In [1]: from IPython.config.configurable import Configurable<br>
> In [2]: from IPython.utils.traitlets import Bool<br>
<br>
> In [3]: class Foo(Configurable):<br>
>    ...:     bar = Bool(False, config=True)<br>
<br>
> In [4]: foo = Foo(config=get_ipython().config)<br>
<br>
> In [5]: foo.bar<br>
> Out[5]: True<br>
><br>
</div>Now I understand that processing of the configurable options shall be<br>
performed not from profile but from the app. I'm not sure of my<br>
understanding, does this means that at time of args processing it is not<br>
mandatory to have ipython's config loader is aware of the Foo class?<br></blockquote><div><br></div><div>Correct, the config object is just a dict-like object, so:</div><div><br></div><div>config.Class.trait = foo</div>

<div><br></div><div>gives something very similar to:</div><div><br></div><div>{ 'Class' : {'trait' : foo } }</div><div><br></div><div>There is no checking on the config object.  The way the config system works is we pass this object to the constructors of Configurables, and that is where values, etc. are extracted based on class names, and validated with traitlets.</div>

<div><br></div><div>For this reason, you can pass config for Foo at the command-line, and then import (or even define) the Foo class at a later point.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


What I want to do is to add options to ipython when invoked with oscopy<br>
profile and those options appear when doing 'ipython --profile=ioscopy<br>
--help' as --term-title or --nosep do. </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is there a way to define aliases of --Foo.bar=True as -bar?</blockquote><div><br></div><div>No, this is not possible.  Command-line args have been fully processed by the time the config files are known.  It is impossible for profiles to affect the Application's parsing of the command-line.  The only thing you can do if you want to piggy-back on IPython's command-line args is to use the full --Class.trait=foo form, which is passed entirely without validation.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> I had a look<br>
at IPython/core/{interactiveshell,alias,application}.py without success,<br>
where are the manually defined flags? To define some for oscopy, shall<br>
BaseIPythonApplication be derived?<br></blockquote><div><br></div><div>If you wanted to create your own entry point (ipython-oscopy), this would be how you would go about it.  But any such subclassing will have no effect on how the command `ipython` starts or parses args.</div>

<div><br></div><div>-MinRK</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
Arnaud.<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</div></div></blockquote></div><br>