core.alias — IPython 0.11 documentation

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »

# core.alias

## Module: `core.alias`

Inheritance diagram for `IPython.core.alias`:

System command aliases.

Authors:

- Fernando Perez
- Brian Granger

## Classes

### `AliasError`

class `IPython.core.alias.``AliasError`

  Bases: `exceptions.Exception`

  `__init__`()

    x.__init__(...) initializes x; see x.__class__.__doc__ for signature

  `args`
  `message`

### `AliasManager`

class `IPython.core.alias.``AliasManager`(shell=None, config=None)

  Bases: `IPython.config.configurable.Configurable`

  `__init__`(shell=None, config=None)
  `aliases`
  `call_alias`(alias, rest='')

    Call an alias given its name and the rest of the line.

  classmethod `class_config_section`()

    Get the config class config section

  classmethod `class_get_help`()

    Get the help string for this class in ReST format.

  classmethod `class_get_trait_help`(trait)

    Get the help string for a single trait.

  classmethod `class_print_help`()

    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.

  `clear_aliases`()
  `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.

  `created` = None
  `default_aliases`

    An instance of a Python list.

  `define_alias`(name, cmd)

    Define a new alias after validating it.

    This will raise an `AliasError` if there are validation problems.

  `exclude_aliases`()
  `expand_alias`(line)

    Expand an alias in the command line

    Returns the provided command line, possibly with the first word (command) translated according to alias expansion rules.

    [ipython]|16> _ip.expand_aliases(“np myfile.txt”)
      <16> ‘q:/opt/np/notepad++.exe myfile.txt’
  `expand_aliases`(fn, rest)

    Expand multiple levels of aliases:

    if:

    alias foo bar /tmp alias baz foo

    then:

    baz huhhahhei -> bar /tmp huhhahhei

  `init_aliases`()
  `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.

  `shell`

    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.

  `soft_define_alias`(name, cmd)

    Define an alias, but don’t raise on an AliasError.

  `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.

  `transform_alias`(alias, rest='')

    Transform alias to system command string.

  `undefine_alias`(name)
  `user_aliases`

    An instance of a Python list.

  `validate_alias`(name, cmd)

    Validate an alias and return the its number of arguments.

### `InvalidAliasError`

class `IPython.core.alias.``InvalidAliasError`

  Bases: `IPython.core.alias.AliasError`

  `__init__`()

    x.__init__(...) initializes x; see x.__class__.__doc__ for signature

  `args`
  `message`

## Function

`IPython.core.alias.``default_aliases`()

  Return list of shell aliases to auto-define.

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »