Skip to main content

easyfabric.policies

ViolationPolicy Objects​

class ViolationPolicy()

Decides the action to take when a data or configuration violation is encountered. Actions: 'stop' (raise exception), 'warn' (log warning), 'skip' (log info and stop processing for that item), 'silent' (do nothing - no log, no exception).

Severity sets the logging level of a 'warn' result: info, warning or critical. 'stop' logs ERROR and 'skip' logs INFO whatever the severity, because the action decides those. silent is the old spelling of severity none; both return without logging.

handle​

def handle(message: str,
exception_cls: Optional[type[FabricError]] = None,
severity: Optional[str] = None,
**kwargs)

Handles a violation according to the policy.

Arguments:

  • message str - The message to log or include in the exception.
  • exception_cls Optional[Type[FabricError]] - Specific exception to raise if action is 'stop'.
  • severity Optional[str] - Rung for this one result, overriding the policy's own. For checks whose severity varies per item.
  • **kwargs - Additional data to format into the message if it's a template.

ViolationRegistry Objects​

class ViolationRegistry()

Utility to manage map from config keys to policies.

get_policy​

@classmethod
def get_policy(cls,
action_string: Optional[str],
default_action: str = ViolationPolicy.WARN,
severity: Optional[str] = None) -> ViolationPolicy

Returns a ViolationPolicy based on a configuration string. Caching instances to reduce overhead, keyed on action and severity.