Package attmap Documentation

Class AttMapLike

Base class for multi-access-mode data objects.

def __init__(self, entries=None)

Create a new instance, optionally with initial key-value pairs.

Parameters:

  • entries (Mapping | Iterable[(Hashable, object)]): initialKV pairs to store
def add_entries(self, entries)

Update this instance with provided key-value pairs.

Parameters:

  • entries (Iterable[(object, object)] | Mapping | pandas.Series): collection of pairs of keys and values
def get_yaml_lines(self, conversions=((<function AttMapLike.<lambda> at 0x7fb4a5c70f80>, None),))

Get collection of lines that define YAML text rep. of this instance.

Parameters:

  • conversions (Iterable[(function(object) -> bool, object)]): collection of pairs in which first component is predicate function and second is what to replace a value with if it satisfies the predicate

Returns:

  • list[str]: YAML representation lines
def is_null(self, item)

Conjunction of presence in underlying mapping and value being None

Parameters:

  • item (object): Key to check for presence and null value

Returns:

  • bool: True iff the item is present and has null value
def non_null(self, item)

Conjunction of presence in underlying mapping and value not being None

Parameters:

  • item (object): Key to check for presence and non-null value

Returns:

  • bool: True iff the item is present and has non-null value
def to_dict(self)

Return a builtin dict representation of this instance.

Returns:

  • dict: builtin dict representation of this instance
def to_map(self)

Convert this instance to a dict.

Returns:

  • dict[str, object]: this map's data, in a simpler container
def to_yaml(self, trailing_newline=True)

Get text for YAML representation.

Parameters:

  • trailing_newline (bool): whether to add trailing newline

Returns:

  • str: YAML text representation of this instance.

Class AttMap

A class to convert a nested mapping(s) into an object(s) with key-values using object syntax (attmap.attribute) instead of getitem syntax (attmap["key"]). This class recursively sets mappings to objects, facilitating attribute traversal (e.g., attmap.attr.attr).

def copy(self)

Copy self to a new object.

Class EchoAttMap

An AttMap that returns key/attr if it has no set value.

Class OrdAttMap

Insertion-ordered mapping with dot notation access

def __init__(self, entries=None)

Initialize self. See help(type(self)) for accurate signature.

def clear(self)

od.clear() -> None. Remove all items from od.

def items(self)

D.items() -> a set-like object providing a view on D's items

def keys(self)

D.keys() -> a set-like object providing a view on D's keys

def pop(self, key, default=<object object at 0x7fb4a66514e0>)

od.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised.

def popitem(self, last=True)

Remove and return a (key, value) pair from the dictionary.

Pairs are returned in LIFO order if last is true or FIFO order if false.

def values(self)

D.values() -> an object providing a view on D's values

Class PathExAttMap

Used in pepkit projects, with Mapping conversion and path expansion

def get(self, k, default=None, expand=True)

Return the value for key if key is in the dictionary, else default.

def items(self, expand=False, to_dict=False)

Produce list of key-value pairs, optionally expanding paths.

Parameters:

  • expand (bool): whether to expand paths

Returns:

  • Iterable[object]: stored key-value pairs, optionally expanded
def to_dict(self, expand=False)

Return a builtin dict representation of this instance.

Returns:

  • dict: builtin dict representation of this instance
def to_map(self, expand=False)

Convert this instance to a dict.

Returns:

  • dict[str, object]: this map's data, in a simpler container
def values(self, expand=False)

Produce list of values, optionally expanding paths.

Parameters:

  • expand (bool): whether to expand paths

Returns:

  • Iterable[object]: stored values, optionally expanded
def get_data_lines(data, fun_key, space_per_level=2, fun_val=None)

Get text representation lines for a mapping's data.

Parameters:

  • data (Mapping): collection of data for which to get repr lines
  • fun_key (function(object, prefix) -> str): function to render keyas text
  • fun_val (function(object, prefix) -> str): function to render valueas text
  • space_per_level (int): number of spaces per level of nesting

Returns:

  • Iterable[str]: collection of lines

Version Information: attmap v0.13.2, generated by lucidoc v0.4.3