File size: 1,563 Bytes
4bc63c7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | """Reason codes owned by this bundle.
Three groups, per SPECIFICATION.md section 9: session codes, preflight codes raised by
the workspace admission check, and catalog codes raised by entry preconditions. Kernel
codes are imported from the kernel when a kernel is present and are never restated here.
"""
from typing import Dict
# Session and node codes.
SESSION_CODES = (
"NODE_TIMEOUT",
"NONSENSE_REPLAY",
"CHECKER_ABSTAIN",
"NOT_UNDERSTOOD",
"AMBIGUOUS_TARGET",
"ALREADY_APPLIED",
"PROTECTED_PATH",
"LINKED_PATH_IN_WORKSPACE",
"NO_TEST_ANCHOR",
"ASSERTION_REMOVED",
"OUT_OF_CATALOG",
"NO_MATCH",
"NO_EDIT",
"SEARCH_NOT_FOUND",
)
# Preflight codes: workspace admission, checked before any node runs (section 1.1).
PREFLIGHT_CODES = (
"NO_TEST_FILE",
"TAB_INDENTED_TARGET",
"CRLF_TARGET",
"NOT_ASCII_TARGET",
"DYNAMIC_REACH",
"GENERATED_TARGET",
)
# Lock codes raised by the gates.
GATE_CODES = (
"PAIR_DISHONEST",
"SHAPE_STILL_PRESENT",
"SUITE_RED",
"LEXICON_INCOMPLETE",
"CATALOG_INTEGRITY",
"CATALOG_CONFLICT",
"CONFINEMENT",
)
#: Every code this bundle may raise.
ALL_CODES: Dict[str, str] = {}
for _group, _name in ((SESSION_CODES, "session"), (PREFLIGHT_CODES, "preflight"),
(GATE_CODES, "gate")):
for _code in _group:
ALL_CODES[_code] = _group and _name or "session"
def group_of(code: str) -> str:
return ALL_CODES.get(code, "unknown")
def is_known(code: str) -> bool:
return code in ALL_CODES
|