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