Package pygeodesy :: Module named :: Class _NamedEnum |
[frames] | no frames]

# Class _NamedEnum

    object --+
             |
          dict --+
                 |
             ADict --+
                     |
        object --+   |
                 |   |
            _Named --+
                     |
            _NamedDict --+
                         |
                        _NamedEnum

(INTERNAL) Enum-like `_NamedDict` with attribute access restricted to valid keys.

Instance Methods
    new empty dictionary
__init__(self, Class, *Classes, **name) New `_NamedEnum`. |
__getattr__(self, name) Get the value of an attribute or item by `name`. |
__repr__(self) Default `repr(self)`. |
__str__(self) Default `str(self)`. |
find(self, item, dflt=None, all=False) Find a registered item. |
D[k] if k in D, else d |
get(self, name, dflt=None) Get the value of a registered item. |
list of D's (key, value) pairs, as 2-tuples |
items(self, all=False, asorted=False) Yield all or only the registered items. |
list of D's keys |
keys(self, **all_asorted) Yield the name (`str`) of all or only the currently registered items, optionally sorted alphabetically, case-insensitively. |
(k, v), remove and return some (key, value) pair as a |
popitem(self) Remove an, any currently registed item. |
register(self, item) Registed one new item or all or any unregistered ones. |
v, remove specified key and return the corresponding value |
unregister(self, name_or_item) Remove a registered item. |
v, remove specified key and return the corresponding value |
pop(self, name_or_item) Remove a registered item. |
toRepr(self, prec=6, fmt='F', sep=`'``,\n``'`, **all_asorted) Like `repr(dict)` but `name`s optionally sorted and `floats` formatted by function pygeodesy.fstr. |
toStr(self, *unused, **all_asorted) Return a string with all `name`s, optionally sorted. |
list of D's values |
values(self, **all_asorted) Yield the value (`type`) of all or only the registered items, optionally sorted alphabetically and case-insensitively. |
Inherited from `_NamedDict`: `__delattr__`, `__getitem__`, `__setattr__`, `__setitem__` Inherited from `ADict`: `set_` Inherited from `dict`: `__cmp__`, `__contains__`, `__delitem__`, `__eq__`, `__ge__`, `__getattribute__`, `__gt__`, `__iter__`, `__le__`, `__len__`, `__lt__`, `__ne__`, `__new__`, `__sizeof__`, `clear`, `copy`, `fromkeys`, `has_key`, `iteritems`, `iterkeys`, `itervalues`, `setdefault`, `update`, `viewitems`, `viewkeys`, `viewvalues` Inherited from `_Named`: `__imatmul__`, `__matmul__`, `__rmatmul__`, `attrs`, `classof`, `dup`, `methodname`, `rename`, `renamed`, `toStr2` Inherited from `object`: `__format__`, `__reduce__`, `__reduce_ex__`, `__subclasshook__`

Class Variables
Inherited from `dict`: `__hash__`

Properties
Inherited from `ADict`: `iteration` Inherited from `_Named`: `classname`, `classnaming`, `name`, `named`, `named2`, `named3`, `named4`, `sizeof` Inherited from `object`: `__class__`

Method Details

### __init__ (self, Class, *Classes, **name) (Constructor) |
New `_NamedEnum`. Arguments: `Class` - Initial class or type acceptable as items values (`type`). `Classes` - Additional, acceptable classes or `type`s. Returns:
    new empty dictionary
Overrides: object.__init__

### __getattr__ (self, name) (Qualification operator) |
Get the value of an attribute or item by `name`. Overrides: ADict.__getattr__

### __repr__ (self) (Representation operator) |
Default `repr(self)`. Overrides: object.__repr__

### __str__ (self) (Informal representation operator) |
Default `str(self)`. Overrides: object.__str__

### find (self, item, dflt=None, all=False) |
Find a registered item. Arguments: `item` - The item to look for (any `type`). `dflt` - Value to return if not found (any `type`). `all` - Use `True` to search all items or `False` only the currently registered ones (`bool`). Returns: The `item`'s name if found (`str`), or `{dflt}` if there is no such `item`.

### get (self, name, dflt=None) |
Get the value of a registered item. Arguments: `name` - The name of the item (`str`). `dflt` - Value to return (any `type`). Returns: D[k] if k in D, else d The item with `name` if found, or `dflt` if there is no registered item with that `name`. Overrides: dict.get

### items (self, all=False, asorted=False) |
Yield all or only the registered items. Arguments: `all` - Use `True` to yield all items or `False` for only the currently registered ones (`bool`). `asorted` - If `True`, yield the items in alphabetical, case-insensitive order (`bool`). Returns: list of D's (key, value) pairs, as 2-tuples Overrides: dict.items

### keys (self, **all_asorted) |
Yield the name (`str`) of all or only the currently registered items, optionally sorted alphabetically, case-insensitively. Arguments: `all_asorted` - See method `items`. Returns: list of D's keys Overrides: dict.keys

### popitem (self) |
Remove an, any currently registed item. Returns: (k, v), remove and return some (key, value) pair as a The removed item. Overrides: dict.popitem

### register (self, item) |
Registed one new item or all or any unregistered ones. Arguments: `item` - The item (any `type`) or all or `any`. Returns: The item name (`str`) or C("all") or `"any"`. Raises: `NameError` - An `item` with that name is already registered the `item` has no or an invalid name. `TypeError` - The `item` type invalid.

### unregister (self, name_or_item) |
Remove a registered item. Arguments: `name_or_item` - Name (`str`) or the item (any `type`). Returns: v, remove specified key and return the corresponding value The unregistered item. Raises: `AttributeError` - No such `item`. `NameError` - No item with that `name`.

### pop (self, name_or_item) |
Remove a registered item. Arguments: `name_or_item` - Name (`str`) or the item (any `type`). Returns: v, remove specified key and return the corresponding value The unregistered item. Raises: `AttributeError` - No such `item`. `NameError` - No item with that `name`. Overrides: dict.pop

### toRepr (self, prec=6, fmt='F', sep=`'``,\n``'`, **all_asorted) |
Like `repr(dict)` but `name`s optionally sorted and `floats` formatted by function pygeodesy.fstr. Overrides: _Named.toRepr

### toStr (self, *unused, **all_asorted) |
Return a string with all `name`s, optionally sorted. Overrides: _Named.toStr

### values (self, **all_asorted) |
Yield the value (`type`) of all or only the registered items, optionally sorted alphabetically and case-insensitively. Arguments: `all_asorted` - See method `items`. Returns: list of D's values Overrides: dict.values