Warning
This documentation is for an old version of IPython. You can find docs for newer versions here.
A simple configuration system.
Inheritance diagram:
Bases: exceptions.Exception
Bases: argparse.ArgumentParser
Simple argparse subclass that prints help to stdout by default.
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 Struct.
Notes
A ConfigLoader does one thing: load a config from a source (file, command line arguments) and returns the data as a Struct. 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.
Bases: IPython.config.loader.FileConfigLoader
A config loader for pure python files.
This calls execfile on a plain python file and looks for attributes that are all caps. These attribute are added to the config Struct.
Build a config loader for a filename and path.
Parameters: | filename : str
path : str, list, tuple
|
---|
Load the config from a file and return it as a Struct.
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
|
---|