rxn.utilities.types.RxnEnum

class rxn.utilities.types.RxnEnum(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Custom enum with additional functions for string conversion.

Has the following functionality compared to a standard Enum: * to_string() to generate a lowercase representation of the instance. * from_string(value) to instantiate from a string. * Constructor is valid both with a string and with another enum instance.

__init__(*args, **kwds)

Methods

to_string()

Convert the enum to a string representation (all lowercase).

from_string(value)

Construct the enum from a string, i.e. from the the strings of its possible values.

classmethod from_string(value)[source]

Construct the enum from a string, i.e. from the the strings of its possible values.

Parameters
  • value (str) – string to convert to an instance of the Enum.

  • cls (Type[TypeVar(T, bound= RxnEnum)]) –

Raises

ValueError if the value is not found.

Return type

TypeVar(T, bound= RxnEnum)

Returns

An instance of the Enum.

to_string()[source]

Convert the enum to a string representation (all lowercase).

Return type

str