IPython Documentation

Table Of Contents

Previous topic

core.profileapp

Next topic

core.prompts

This Page

core.profiledir

Module: core.profiledir

Inheritance diagram for IPython.core.profiledir:

An object for managing IPython profile directories.

Authors:

  • Brian Granger
  • Fernando Perez
  • Min RK

Classes

ProfileDir

class IPython.core.profiledir.ProfileDir(**kwargs)

Bases: IPython.config.configurable.LoggingConfigurable

An object to manage the profile directory and its resources.

The profile directory is used by all IPython applications, to manage configuration, logging and security.

This object knows how to find, create and manage these directories. This should be used by any code that wants to handle profiles.

__init__(**kwargs)

Create a configurable given a config config.

Parameters :

config : Config

If this is empty, default values are used. If config is a Config instance, it will be used to configure the instance.

Notes

Subclasses of Configurable must call the __init__() method of Configurable before doing anything else and using super():

class MyConfigurable(Configurable):
    def __init__(self, config=None):
        super(MyConfigurable, self).__init__(config)
        # Then any other code you need to finish initialization.

This ensures that instances will be configured properly.

check_dirs()
check_log_dir()
check_pid_dir()
check_security_dir()
check_startup_dir()
classmethod class_config_section()

Get the config class config section

classmethod class_get_help(inst=None)

Get the help string for this class in ReST format.

If inst is given, it’s current trait values will be used in place of class defaults.

classmethod class_get_trait_help(trait, inst=None)

Get the help string for a single trait.

If inst is given, it’s current trait values will be used in place of the class default.

classmethod class_print_help(inst=None)

Get the help string for a single trait and print it.

classmethod class_trait_names(**metadata)

Get a list of all the names of this classes traits.

This method is just like the trait_names() method, but is unbound.

classmethod class_traits(**metadata)

Get a list of all the traits of this class.

This method is just like the traits() method, but is unbound.

The TraitTypes returned don’t know anything about the values that the various HasTrait’s instances are holding.

This follows the same algorithm as traits does and does not allow for any simple way of specifying merely that a metadata name exists, but has any value. This is because get_metadata returns None if a metadata key doesn’t exist.

config

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

copy_config_file(config_file, path=None, overwrite=False)

Copy a default config file into the active profile directory.

Default configuration files are kept in IPython.config.default. This function moves these from that location to the working profile directory.

classmethod create_profile_dir(profile_dir, config=None)

Create a new profile directory given a full path.

Parameters :

profile_dir : str

The full path to the profile directory. If it does exist, it will be used. If not, it will be created.

classmethod create_profile_dir_by_name(path, name=u'default', config=None)

Create a profile dir by profile name and path.

Parameters :

path : unicode

The path (directory) to put the profile directory in.

name : unicode

The name of the profile. The name of the profile directory will be “profile_<profile>”.

classmethod find_profile_dir(profile_dir, config=None)

Find/create a profile dir and return its ProfileDir.

This will create the profile directory if it doesn’t exist.

Parameters :

profile_dir : unicode or str

The path of the profile directory. This is expanded using IPython.utils.genutils.expand_path().

classmethod find_profile_dir_by_name(ipython_dir, name=u'default', config=None)

Find an existing profile dir by profile name, return its ProfileDir.

This searches through a sequence of paths for a profile dir. If it is not found, a ProfileDirError exception will be raised.

The search path algorithm is: 1. os.getcwdu() 2. ipython_dir

Parameters :

ipython_dir : unicode or str

The IPython directory to use.

name : unicode or str

The name of the profile. The name of the profile directory will be “profile_<profile>”.

location

A trait for unicode strings.

log

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

log_dir

A trait for unicode strings.

log_dir_name

A trait for unicode strings.

on_trait_change(handler, name=None, remove=False)

Setup a handler to be called when a trait changes.

This is used to setup dynamic notifications of trait changes.

Static handlers can be created by creating methods on a HasTraits subclass with the naming convention ‘_[traitname]_changed’. Thus, to create static handler for the trait ‘a’, create the method _a_changed(self, name, old, new) (fewer arguments can be used, see below).

Parameters :

handler : callable

A callable that is called when a trait changes. Its signature can be handler(), handler(name), handler(name, new) or handler(name, old, new).

name : list, str, None

If None, the handler will apply to all traits. If a list of str, handler will apply to all names in the list. If a str, the handler will apply just to that name.

remove : bool

If False (the default), then install the handler. If True then unintall it.

pid_dir

A trait for unicode strings.

pid_dir_name

A trait for unicode strings.

security_dir

A trait for unicode strings.

security_dir_name

A trait for unicode strings.

startup_dir

A trait for unicode strings.

startup_dir_name

A trait for unicode strings.

trait_metadata(traitname, key)

Get metadata values for trait by key.

trait_names(**metadata)

Get a list of all the names of this classes traits.

traits(**metadata)

Get a list of all the traits of this class.

The TraitTypes returned don’t know anything about the values that the various HasTrait’s instances are holding.

This follows the same algorithm as traits does and does not allow for any simple way of specifying merely that a metadata name exists, but has any value. This is because get_metadata returns None if a metadata key doesn’t exist.

update_config(config)

Fire the traits events when the config is updated.

ProfileDirError

class IPython.core.profiledir.ProfileDirError

Bases: exceptions.Exception

__init__()

x.__init__(...) initializes x; see help(type(x)) for signature

args
message