Validation Codes Dictionary

class reasoner_validator.validation_codes.CodeDictionary

Bases: object

Attributes:
code_dictionary

Methods

display(code[, messages, add_prefix])

Generate one or more full messages from provided Validation Reporter code and associated parameters (if applicable).

filter_copy_by_facet(tree, facet)

Copy subtree, filtering out leaf data by specified facet.

get_code_entry(code[, facet])

Get the single code entry corresponding to the given code, if available.

get_code_subtree(code[, facet, is_leaf])

Get subtree of specified dot-delimited tag name, returning message type (i.e.

markdown([filename])

Dump the Code Dictionary into a validation_codes_dictionary.md Markdown file, for documentation purposes.

get_description

get_message_context

get_message_template

get_message_type

validation_code_tag

CODE_DICTIONARY_FILE: str = '/home/runner/work/reasoner-validator/reasoner-validator/reasoner_validator/codes.yaml'
CONTEXT = '$context'
DESCRIPTION = '$description'
MESSAGE = '$message'
code_dictionary: Dict | None = None
classmethod display(code: str, messages: Dict[str, Dict[str, List[Dict[str, str]] | None] | None] | None = None, add_prefix: bool = False) Dict[str, List[str]]

Generate one or more full messages from provided Validation Reporter code and associated parameters (if applicable).

Parameters:
  • code – str, valid (dot delimited YAML key path) identified code, which should be registered in the project codes.yaml file.

  • messages – Optional[SCOPED_MESSAGES], collection of scoped validation messages (Default: None) If this parameter specified as None, then it is actually taken to be {“global”: None}

  • add_prefix – bool, flag to prepend a prefix for the message type (i.e. critical, error, warning, info) to displayed messages (default: False)

Returns:

Dict[str, List[str]], scope-indexed dictionary of lists of decoded messages for a given code

classmethod filter_copy_by_facet(tree: Dict, facet: str) Dict

Copy subtree, filtering out leaf data by specified facet. Leaves are simply identified by the presence of the mandatory ‘$message’ tree parameter dictionary key.

Parameters:
  • tree – Dict, message code dictionary tree to be copied, possibly filtered by facet

  • facet – str, constraint on code entry facet to be returned; if specified, should be either “message”, “context” or “description” (default: return all facets of the code entry)

Returns:

Dict, tree filtered by facet

classmethod get_code_entry(code: str | None, facet: str | None = None) Dict[str, str] | None

Get the single code entry corresponding to the given code, if available.

Parameters:
  • code – Optional[str], dot delimited validation message code identifier (None is ok, but returns None)

  • facet – Optional[str], constraint on code entry facet to be returned; if specified, should be either “message” or “description” (default: return all facets of the code entry)

Returns:

Dict, single terminal leaf code entry (complete with indicated or all facets); None, if not available

classmethod get_code_subtree(code: str, facet: str | None = None, is_leaf: bool | None = False) Tuple[str, Dict] | None

Get subtree of specified dot-delimited tag name, returning message type (i.e. info, warning, error, critical). If optional ‘is_leaf’ flag is set to True, then only return the code if it is a terminal leaf in the code tree.

Parameters:
  • code – Optional[str], dot delimited validation message code identifier (None is ok, but returns None)

  • facet – Optional[str], constraint on code entry facet to be returned; if specified, should be either “message” or “description” (default: return all facets of the code entry)

  • is_leaf – Optional[bool], only return entry if it is a ‘leaf’ of the code tree (default: False)

Returns:

Optional[Tuple[str, Dict[str,str]]], 2-tuple of the code type (i.e. info, warning, error, critical) and the validation message entry (dictionary); None if empty code or code unknown in the code dictionary, or (if the is_leaf option is ‘True’) if the code doesn’t resolve to a single leaf.

classmethod get_description(code: str | None) str | None
classmethod get_message_context(code: str | None) List[str] | None
classmethod get_message_template(code: str | None) str | None
static get_message_type(code: str) str
classmethod markdown(filename: str = '/home/runner/work/reasoner-validator/reasoner-validator/docs/validation_codes_dictionary.md') bool

Dump the Code Dictionary into a validation_codes_dictionary.md Markdown file, for documentation purposes.

Parameters:

filename – str, defaults to DEFAULT_CODES_DOCUMENTATION_FILE

Returns:

bool, True if successful; False otherwise

static validation_code_tag(code: str) str