granola.enums module

class granola.enums.DocumentedEnum(value)

Bases: Enum

Enum Base class to inherit from that replaces the value option with a description option.

Examples

>>> class HookTypes(DocumentedEnum):
...     pre_reading = "Hook to run before `get_reading` methods"
...     post_reading = "Hook to run after `get_reading` methods"
>>> HookTypes.pre_reading.name
'pre_reading'
>>> HookTypes.post_reading.description
'Hook to run after `get_reading` methods'
classmethod str_enum_options()
class granola.enums.HookTypes(value)

Bases: DocumentedEnum

Allowed hook types for BaseHook methods or for a register_hook Current allowed hook types are pre_reading and post_reading.

post_reading = 'Hook to run after `get_reading` methods'
pre_reading = 'Hook to run before `get_reading` methods'
class granola.enums.RandomizeResponse(value)

Bases: DocumentedEnum

The different ways to specify to randomize or not randomize your CannedQueries response

not_randomized = "Don't randomize the response"
randomize_and_remove = 'Randomize and remove'
randomized_w_replacement = 'Randomize with replacement'
class granola.enums.SetRelationship(value)

Bases: DocumentedEnum

The different ways to specify what a hook should do with commands or attributes, should the hook include everything listed in the corresponding data container and nothing else, or should it exclude everything in the corresponding data container and include everything else.

exclude = 'Exclude everything listed in the corresponding data container'
include = 'Include everything listed in the corresponding data container'
granola.enums.get_attribute_from_enum(maybe_enum, enum_attribute)

If the passed in maybe_enum is an enum, return the attribute, else return the maybe_enum

Parameters
  • maybe_enum (Enum or Enum key) –

  • enum_attribute (str) – The name of the enum attribute to retrieve

granola.enums.validate_enum(value, enum)

Validate the given value is in the given enum

Parameters
  • value (Enum or enum key) –

  • enum – the enum to validate against