Profile Override

Override the IPython IPython.core.profiledir.ProfileDir.

Initially created to implement a repr for the class, it was expanded in order to also modify the behavior that automatically adds the directories.:

  1. PID

  2. security

  3. log

  4. db

It automatically creates them in the current working directory and this behavior was not designed to be modifiable.

As a result, profiles are frequently created in the wrong dir often enough that it should be configurable behavior.

See Also

IPython.core.profileapp

How IPython implements the profile originally.

IPython.core.profiledir

The overridden class.

Profile App API

exception ProfileDirError[source][source]

Bases: Exception

class ReprProfileDir(**kwargs)[source][source]

Bases: IPython.core.profiledir.ProfileDir

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.

Notes

Implements __fspath__ to implement the pathlib protocol.

__init__(**kwargs)[source][source]

Create an init and then make it way shorter.

class DirectoryChecker(*args)[source][source]

Bases: object

Checks for the presence of needed directories and creates them.

__init__(*args)[source][source]

Initialize with optional needed dirs.

property shell[source][source]

Return the global IPython instance.

initialize()[source][source]

Initialize with a modified version of the IPython shell.

ensure_dir_exists(path, mode=493)[source][source]

Ensure that a directory exists.

If it doesn’t exist, try to create it and protect against a race condition if another process is doing the same.

The default permissions are 0o755, which differ from os.makedirs() default of 0o777.

Parameters
  • path (str (path-like)) – Path to the directory

  • mode (int) – If the directory doesn’t exist, what mode should it be created as?

Returns

Return type

None

Raises

OSError, IOError

initialize_profile()[source][source]

Initialize the profile but sidestep the IPython.core.ProfileDir().

The class searches for directories named default_profile and if found uses that as a profile which I dislike.