medcat.utils.hasher =================== .. py:module:: medcat.utils.hasher Classes ------- .. autoapisummary:: medcat.utils.hasher.Hasher Functions --------- .. autoapisummary:: medcat.utils.hasher.dumps Module Contents --------------- .. py:function:: dumps(obj, length = False) Dump the content of an object to bytes. This method uses dill to dump the contents of an object into a BytesIO object and then either reads its bytes or (or length == True) simply reruns the process on the length of the byte array. :param obj: The object to dump. :type obj: Any :param length: Whether to only dump the length of the file array. Defaults to False. :type length: bool, optional :Returns: **bytes** -- The resulting byte array. .. py:class:: Hasher(dumper = dumps) A consistent hasher. This class is able to hash the same object(s) to the same value every time. This is in contrast to the normal hashing in python that does not guarantee identical results over multiple runs. :param dumper: The dumper to be used. Defaults to the `dumps` method. :type dumper: Callable[[Any, bool], bytes], optional .. py:method:: __init__(dumper = dumps) .. py:attribute:: m .. py:attribute:: _dumper .. py:method:: update(obj, length = False) Update the hasher with the object in question. If `length = True` is passed, only the length of the byte array corresponding to the data is considered Otherwise the entire byte array is used. :param obj: The object to be added / hashed. :type obj: Any :param length: Whether to only dump the length of the file array. Defaults to False. :type length: bool, optional .. py:method:: update_bytes(b) Update the hasher with a byte array. :param b: The byte array to update with. :type b: bytes .. py:method:: hexdigest() Get the hex for the current hash state. :Returns: **str** -- The hex representation of the hashed objects.