rics.action_level#

Action level enumeration types.

Classes

ActionLevel(value[, names, module, ...])

Action level enumeration type for events.

ActionLevelHelper([require_purpose])

Helper class for keeping track of per-purpose forbidden actions.

Exceptions

BadActionLevelError(action[, purpose, forbidden])

Error raised for unknown or disallowed action arguments.

class ActionLevel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

Action level enumeration type for events.

ParseType#

Types that may be interpreted as an ActionLevel.

alias of Union[Literal[‘ignore’, ‘warn’, ‘raise’, ‘IGNORE’, ‘WARN’, ‘RAISE’], ActionLevel]

RAISE = 'raise'#

Raise an error.

WARN = 'warn'#

Raise a warning

IGNORE = 'ignore'#

Ignore the event.

classmethod verify(action: str | ActionLevel, purpose: str | None = None, forbidden: Literal['ignore', 'warn', 'raise', 'IGNORE', 'WARN', 'RAISE'] | ActionLevel | None = None) ActionLevel[source]#

Verify an action level.

Parameters:
  • action – The value to verify.

  • purpose – Additional information to add if an exception is raised.

  • forbidden – Which of (‘ignore’, ‘warn’, ‘raise’) not to accept. Accept all if None.

Returns:

A valid action level for the given purpose.

Raises:

BadActionLevelError – If action is not in (‘ignore’, ‘warn’, ‘raise’) or if action is in forbidden.

class ActionLevelHelper(require_purpose: Literal['given', 'exists'] = 'exists', **forbidden_for_purpose: Literal['ignore', 'warn', 'raise', 'IGNORE', 'WARN', 'RAISE'] | ActionLevel | None)[source]#

Bases: object

Helper class for keeping track of per-purpose forbidden actions.

Parameters:
  • require_purpose – Determine how to handle the purpose argument given in verify(); require that it exists, or just that it is given. Must be one of (‘given’, ‘exists’).

  • **forbidden_for_purpose – Per-purpose forbidden actions.

verify(action: Literal['ignore', 'warn', 'raise', 'IGNORE', 'WARN', 'RAISE'] | ActionLevel, purpose: str) ActionLevel[source]#

Verify an action level with constraints.

Parameters:
  • action – The value to verify.

  • purpose – Additional information to add if an exception is raised.

Returns:

A valid action level for the given purpose.

Raises:
  • BadActionLevelError – If action is not in (‘ignore’, ‘warn’, ‘raise’) or if action is in remove.

  • ValueError – If purpose is unknown and require_purpose is set to ‘exists’.

exception BadActionLevelError(action: Literal['ignore', 'warn', 'raise', 'IGNORE', 'WARN', 'RAISE'] | ActionLevel, purpose: str | None = None, forbidden: ActionLevel | None = None)[source]#

Bases: ValueError

Error raised for unknown or disallowed action arguments.