hio.help.mining =============== .. py:module:: hio.help.mining .. autoapi-nested-parse:: hio.help.mining module Support for Mine dict subclass for shared in memory database Module Contents --------------- .. py:class:: Mine(*pa, **kwa) Bases: :py:obj:`dict` Mine subclass of dict with custom methods dunder methods and get that will only allow actual keys as str. Iterables passed in as key are converted to a "_' joined str. Uses "_" so can use dict constuctor if need be with str path. Assumes items in Iterable do not contain '_'. Supports attribute syntax to access items, e.g. mine.a = 5 and mine.a_b = 4. Special static methods: tokeys(k) returns split of k at separator '_' as tuple. .. py:method:: get(k, default=None) Return the value for key if key is in the dictionary, else default. .. py:method:: update(*pa, **kwa) Convert keys that are tuples when positional argument is Iterable or Mapping to '.' joined strings dict __init__ signature options are:: dict(**kwa) dict(mapping, **kwa) dict(iterable, **kwa) dict.update has same call signature:: d.update({"a": 5, "b": 2}, c=3, d=4) .. py:method:: tokey(keys) :staticmethod: Joins tuple of strings keys to '_' joined string key. If already str then returns unchanged. :param keys: non-string Iteralble of path key components to be '_' joined into key. If keys is already str then returns unchanged :type keys: Iterable[str] | str :returns: '.' joined string :rtype: key (str) .. py:method:: tokeys(key) :staticmethod: Converts '_' joined string key to tuple of keys by splitting on '_' :param key: '_' joined string to be split :type key: str :returns: split of key on '_' into path key components :rtype: keys (tuple[str])