cognition.util.enumeration

Enumeration support

Classes

DocEnum

An enumeration where members can have individual docstrings.

AutoDocEnum

An enumeration where members have individual docstrings

EnumDispatch

Support for dispatch to an object's

Module Contents

class cognition.util.enumeration.DocEnum(*args)

Bases: enum.Enum

An enumeration where members can have individual docstrings.

Example usage:

MEMBER = value[, "docstring"]
Parameters:

args (Any)

class cognition.util.enumeration.AutoDocEnum(*args)

Bases: enum.Enum

An enumeration where members have individual docstrings and the value is automatically set (as integers: 1, 2, …)

Example usage:

MEMBER = "docstring"
Parameters:

args (Any)

__doc__ = ''
class cognition.util.enumeration.EnumDispatch[T: enum.Enum]

Support for dispatch to an object’s methods based upon supplied enum name

dispatch(v, *args, **kwargs)

If it exists, returns the result of calling the method with the enumeration’s name (lower-case).

Parameters:
  • v (T) – enumeration value to dispatch

  • args (Any) – positional arguments

  • kwargs (Any) – keyword arguments

Returns:

method result (if found, else None)

Return type:

Any