multidirmap

A multidirectional mapping with an arbitrary number of key columns.

class multidirmap.MultiDirMap(columns, key_columns=None, data=None)[source]

A multidirectional mapping with an arbitrary number of key columns.

clear()[source]

Clear all key dicts, thereby deleting all stored data.

get(key, default=None)[source]

Redirects to get() of the primary key dict.

items()[source]

Redirects to items() of the primary key dict.

keys()[source]

Redirects to keys() of the primary key dict.

pop(key, default=<object object>)[source]

Pop an entry from the mapping.

Entry is returned from the primary key dict and it as well as all consequently orphaned entries are removed from the secondary key dicts.

popitem()[source]

Pop from the end of the primary key dict.

All consequently orphaned entries are removed from the secondary key dicts.

print_settings(**kwargs)[source]

Change the print settings for __str__().

max_width gives the maximum width of the entire table. max_cols gives the maximum number of columns. max_col width gives the maximum width of each column.

reorder_secondary_keys()[source]

Refresh the order of the secondary key dicts.

This will recreate all secondary key dicts such that the keys will be in the same order as the primary keys, as the secondary key order can get scrambled when secondary entries are overwritten.

sort(key=<function <lambda>>, reverse=False)[source]

Sort the map by the given key.

If no key is given, sorting is done by the entries in the primary key column.

to_list()[source]

Dump all the contents of the map into a list of lists.

update(data, overwrite=<Overwrite.PRIMARY: 'primary'>, skip_duplicates=False)[source]

Update the map with the provided data.

overwrite is an enum (Overwrite) that can be NONE, PRIMARY, SECONDARY, or ALL and determines whether an entry can still be added when it conflicts with an existing entry. skip_duplicates determines whether a conflicting entry that will not overwrite should be skipped. If False, an exception will be raised in that situation and a rollback performed, so that the update() operation does not change the state of the map.

values()[source]

Redirects to values() of the primary key dict.

exception multidirmap.DuplicateKeyError[source]

Raised when secondary key is not unique.

class multidirmap.Overwrite[source]

Enum for setting the overwrite mode.