Note
This documentation is for a development version of IPython. There may be significant differences from the latest stable release (1.2.1).
A simple configuration system.
Inheritance diagram:
Bases: exceptions.Exception
Bases: argparse.ArgumentParser
Simple argparse subclass that prints help to stdout by default.
Bases: IPython.utils.traitlets.HasTraits
Proxy object for exposing methods on configurable containers
Exposes:
construct the value from the initial one
after applying any insert / extend / update changes
like list.extend, but for the front
return JSONable dict form of my data
Currently update as dict or set, extend, prepend as lists, and inserts as list of tuples.
Bases: dict
An attribute based dict that can do smart merges.
merge another config object into this one
Bases: object
A object for loading configurations from just about anywhere.
The resulting configuration is packaged as a Config.
Notes
A ConfigLoader does one thing: load a config from a source (file, command line arguments) and returns the data as a Config object. There are lots of things that ConfigLoader does not do. It does not implement complex logic for finding config files. It does not handle default values or merge multiple configs. These things need to be handled elsewhere.
A base class for config loaders.
Examples
>>> cl = ConfigLoader()
>>> config = cl.load_config()
>>> config
{}
Bases: IPython.config.loader.ConfigLoader
A base class for file based configurations.
As we add more file based config loaders, the common logic should go here.
Build a config loader for a filename and path.
Parameters: | filename : str
path : str, list, tuple
|
---|
Bases: IPython.config.loader.FileConfigLoader
A Json file loader for config
Load the config from a file and return it as a Config object.
Bases: IPython.config.loader.FileConfigLoader
A config loader for pure python files.
This is responsible for locating a Python config file by filename and path, then executing it to construct a Config object.
Load the config from a file and return it as a Config object.
Bases: IPython.config.loader.ConfigLoader
A config loader for command line arguments.
As we add more command line based loaders, the common logic should go here.
Bases: IPython.config.loader.CommandLineConfigLoader
A config loader that loads key value pairs from the command line.
This allows command line options to be gives in the following form:
ipython --profile="foo" --InteractiveShell.autocall=False
Create a key value pair config loader.
Parameters: | argv : list
aliases : dict
flags : dict
|
---|---|
Returns: | config : Config
|
Examples
>>> from IPython.config.loader import KeyValueConfigLoader
>>> cl = KeyValueConfigLoader()
>>> d = cl.load_config(["--A.name='brian'","--B.number=0"])
>>> sorted(d.items())
[('A', {'name': 'brian'}), ('B', {'number': 0})]
Parse the configuration and generate the Config object.
After loading, any arguments that are not key-value or flags will be stored in self.extra_args - a list of unparsed command-line arguments. This is used for arguments such as input files or subcommands.
Parameters: | argv : list, optional
aliases : dict
flags : dict
|
---|
Bases: IPython.config.loader.CommandLineConfigLoader
A loader that uses the argparse module to load from the command line.
Create a config loader for use with argparse.
Parameters: | argv : optional, list
parser_args : tuple
parser_kw : dict
|
---|---|
Returns: | config : Config
|
Parse command line arguments and return as a Config object.
Parameters: | args : optional, list
|
---|
Bases: IPython.config.loader.ArgParseConfigLoader
A config loader that loads aliases and flags with argparse, but will use KVLoader for the rest. This allows better parsing of common args, such as ipython -c ‘print 5’, but still gets arbitrary config with ipython –InteractiveShell.use_readline=False
Load multiple Python config files, merging each of them in turn.
Parameters: | config_files : list of str
path : unicode
|
---|