Access and manipulate the metadata of objects.

getarguments(obj)

A function to get the arguments captured by the init method of a class when an instance of the given type is initialized.

Parameters:
  • obj (object) –

    The object to get the arguments from.

Raises:
  • AttributeError

    If the object was not registered.

Returns:
  • dict[str, Any]

    dict[str, Any]: The arguments captured by the init method of the object.

gethash(obj)

A function to get an unique deterministic hash of the object calculated from the name and the arguments captured by the init method of the object. If the object was not registered, an AttributeError will be raised. The hash will be calculated using the md5 algorithm by default but can be setted manually using the sethash function.

Parameters:
  • obj (object) –

    The object to get the hash from.

Returns:
  • str( str ) –

    The hash of the object.

Raises:
  • AttributeError

    If the object was not registered and does not have a hash setted.

getmetadata(obj)

A function to get the metadata of the object. The metadata is a dictionary containing the name, the arguments and the hash of the object.

Parameters:
  • obj (object) –

    The object to get the metadata.

Returns:
  • dict[str, Any]

    dict[str, Any]: The metadata of the object.

getname(obj)

A function to get the name of the object. If the object has a model__name attribute, it will be returned. Otherwise, the class name will be returned.

Parameters:
  • obj (object) –

    The object to get the name from.

Returns:
  • str( str ) –

    The name of the object.

sethash(obj, hash=None)

A function to set the hash of the object. If the hash is not provided, it will be calculated using the md5 algorithm from the name and the arguments captured by the init method of the object by default. If a hash is provided, it will be setted as the hash of the object.

Parameters:
  • obj (object) –

    description

  • hash (str, default: None ) –

    description. Defaults to None.

setname(obj, name=None)

A function to set the name of the object. If the name is not provided, it will be retrieved from the class name. If a name is provided, it will be setted as the name of the object.

Parameters:
  • obj (object) –

    The object to set the name.

  • name (str, default: None ) –

    The name to set. Defaults to None.