gin/config.py
def constants_from_enum(cls, module=None):
  """Decorator for an enum class that generates Gin constants from values.

  Generated constants have format `module.ClassName.ENUM_VALUE`. The module
  name is optional when using the constant.

  Args:
    cls: Class type.
    module: The module to associate with the constants, to help handle naming
      collisions. If `None`, `cls.__module__` will be used.

  Returns:
    Class type (identity function).

  Raises:
    TypeError: When applied to a non-enum class.
  """
  if not issubclass(cls, enum.Enum):
    raise TypeError("Class '{}' is not subclass of enum.".format(cls.__name__))

  if module is None:
    module = cls.__module__
  for value in cls:
    constant('{}.{}'.format(module, str(value)), value)
  return cls
def constants_from_enum(cls, module=None):
  if not issubclass(cls, enum.Enum):
    raise TypeError("Class '{}' is not subclass of enum.".format(cls.__name__))

  if module is None:
    module = cls.__module__
  for value in cls:
    constant('{}.{}'.format(module, str(value)), value)
  return cls
def constants_from_enum ( cls , module = None ) : if not issubclass ( cls , enum . Enum ) : raise TypeError ( "Class '{}' is not subclass of enum." . format ( cls . __name__ ) ) if module is None : module = cls . __module__ for value in cls : constant ( '{}.{}' . format ( module , str ( value ) ) , value ) return cls
Decorator for an enum class that generates Gin constants from values.

  Generated constants have format `module.ClassName.ENUM_VALUE`. The module
  name is optional when using the constant.

  Args:
    cls: Class type.
    module: The module to associate with the constants, to help handle naming
      collisions. If `None`, `cls.__module__` will be used.

  Returns:
    Class type (identity function).

  Raises:
    TypeError: When applied to a non-enum class.
Decorator for an enum class that generates Gin constants from values .