rics.utility.action_level#
Action level enumeration types.
Module Attributes
Types which may be interpreted as an ActionLevel. |
Classes
|
Action level enumeration type for events. |
|
Helper class for keeping track of per-purpose forbidden actions. |
Exceptions
|
Error raised for unknown or disallowed action arguments. |
- ActionLevelTypes#
Types which may be interpreted as an ActionLevel.
alias of
Union[Literal[‘ignore’, ‘warn’, ‘raise’, ‘IGNORE’, ‘WARN’, ‘RAISE’],ActionLevel]
- exception BadActionLevelError(action: Union[Literal['ignore', 'warn', 'raise', 'IGNORE', 'WARN', 'RAISE'], ActionLevel], purpose: Optional[str] = None, forbidden: Optional[ActionLevel] = None)[source]#
Bases:
ValueErrorError raised for unknown or disallowed action arguments.
- class ActionLevel(value)[source]#
Bases:
EnumAction level enumeration type for events.
- RAISE = 'raise'#
Raise an error.
- WARN = 'warn'#
Raise a warning
- IGNORE = 'ignore'#
Ignore the event.
- classmethod verify(action: Union[Literal['ignore', 'warn', 'raise', 'IGNORE', 'WARN', 'RAISE'], ActionLevel], purpose: Optional[str] = None, forbidden: Optional[Union[Literal['ignore', 'warn', 'raise', 'IGNORE', 'WARN', 'RAISE'], ActionLevel]] = 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 remove.
- class ActionLevelHelper(require_purpose: Literal['given', 'exists'] = 'exists', **forbidden_for_purpose: Optional[Union[Literal['ignore', 'warn', 'raise', 'IGNORE', 'WARN', 'RAISE'], ActionLevel]])[source]#
Bases:
objectHelper 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: Union[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’.