Mix-ins

class omnifig.mixins.Activatable(*args, **kwargs)

Bases: object

Mix-in class for objects that can be activated and deactivated.

Once activated, the object is in a usable state, and cannot be activated again (and the object can only be deactivated if it is already activated).

Primarily used by omnifig.abstract.AbstractProfile and omnifig.abstract.AbstractProject.

__init__(*args, **kwargs)
property is_activated: bool

Flag whether the object is currently activated

Return type:

bool

activate(*args, **kwargs)

Top-level method to activate the object.

Parameters:
  • *args (Any) – Arguments to pass to the _activate() method

  • **kwargs (Any) – Keyword arguments to pass to the _activate() method

Return type:

None

Returns:

None

deactivate(*args, **kwargs)

Top-level method to deactivate the object.

Parameters:
  • *args – Arguments to pass to the _deactivate() method

  • **kwargs – Keyword arguments to pass to the _deactivate() method

Returns:

None

class omnifig.mixins.FileInfo(data=None, **kwargs)

Bases: object

Mix-in class for objects that loads and stores information from a file.

static load_raw_info(path)

Loads the info yaml file at the given path.

Parameters:

path (Path) – File path containing the info yaml file

Return type:

Dict[str, Any]

Returns:

dict containing the loaded info

__init__(data=None, **kwargs)

Loads the info if the provided data is a file path.

Parameters:
  • data (Union[str, Path, Dict[str, Any]]) – A file path to a yaml file, or a dictionary containing the info

  • **kwargs (Any) – Other arguments passed on to super()

property name

The name of the object, as specified in the info file.

extract_info(other)

Extracts the info from the given object and stores it in this object.

Usually used to replace other with self.

Parameters:

other (FileInfo) – The source object to extract the info from

Returns:

None