Warning

This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: config.application

A base class for a configurable application.

Authors:

  • Brian Granger
  • Min RK

3 Classes

class IPython.config.application.ApplicationError

Bases: exceptions.Exception

class IPython.config.application.LevelFormatter(fmt=None, datefmt=None)

Bases: logging.Formatter

Formatter with additional highlevel record

This field is empty if log level is less than highlevel_limit, otherwise it is formatted with self.highlevel_format.

Useful for adding ‘WARNING’ to warning messages, without adding ‘INFO’ to info, etc.

class IPython.config.application.Application(**kwargs)

Bases: IPython.config.configurable.SingletonConfigurable

A singleton application with full configuration support.

__init__(**kwargs)
flatten_flags()

flatten flags and aliases, so cl-args override as expected.

This prevents issues such as an alias pointing to InteractiveShell, but a config file setting the same trait in TerminalInteraciveShell getting inappropriate priority over the command-line arg.

Only aliases with exactly one descendent in the class list will be promoted.

generate_config_file()

generate default config file from Configurables

initialize(argv=None)

Do the basic steps to configure me.

Override in subclasses.

initialize_subcommand(subc, argv=None)

Initialize a subcommand with argv.

classmethod launch_instance(argv=None, **kwargs)

Launch a global instance of this Application

If a global instance already exists, this reinitializes and starts it

load_config_file(filename, path=None)

Load config files by filename and path.

parse_command_line(argv=None)

Parse the command line arguments.

print_alias_help()

Print the alias part of the help.

print_description()

Print the application description.

print_examples()

Print usage and examples.

This usage string goes at the end of the command line help string and should contain examples of the application’s usage.

print_flag_help()

Print the flag part of the help.

print_help(classes=False)

Print the help for each Configurable class in self.classes.

If classes=False (the default), only flags and aliases are printed.

print_subcommands()

Print the subcommand part of the help.

print_version()

Print the version string.

start()

Start the app mainloop.

Override in subclasses.

update_config(config)

Fire the traits events when the config is updated.

2 Functions

IPython.config.application.catch_config_error(method)

Method decorator for catching invalid config (Trait/ArgumentErrors) during init.

On a TraitError (generally caused by bad config), this will print the trait’s message, and exit the app.

For use on init methods, to prevent invoking excepthook on invalid input.

IPython.config.application.boolean_flag(name, configurable, set_help='', unset_help='')

Helper for building basic –trait, –no-trait flags.

Parameters:

name : str

The name of the flag.

configurable : str

The ‘Class.trait’ string of the trait to be set/unset with the flag

set_help : unicode

help string for –name flag

unset_help : unicode

help string for –no-name flag

Returns:

cfg : dict

A dict with two keys: ‘name’, and ‘no-name’, for setting and unsetting the trait, respectively.