From 3f502f99cf702209cbdecc747ea0432d921ed52e Mon Sep 17 00:00:00 2001 From: konstantin Date: Fri, 30 Jun 2023 16:13:56 +0200 Subject: [PATCH] Use same result code regex over entire code base (#92) --- src/ebdtable2graph/models/ebd_graph.py | 4 ++-- src/ebdtable2graph/models/ebd_table.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ebdtable2graph/models/ebd_graph.py b/src/ebdtable2graph/models/ebd_graph.py index dd949bf..5be93dc 100644 --- a/src/ebdtable2graph/models/ebd_graph.py +++ b/src/ebdtable2graph/models/ebd_graph.py @@ -8,7 +8,7 @@ from networkx import DiGraph # type:ignore[import] # pylint:disable=too-few-public-methods -from ebdtable2graph.models.ebd_table import MultiStepInstruction +from ebdtable2graph.models.ebd_table import RESULT_CODE_REGEX, MultiStepInstruction @attrs.define(auto_attribs=True, kw_only=True) @@ -85,7 +85,7 @@ class OutcomeNode(EbdGraphNode): An outcome node is a leaf of the Entscheidungsbaum tree. It has no subsequent steps. """ - result_code: str = attrs.field(validator=attrs.validators.matches_re(r"^[A-Z]\d+$")) + result_code: str = attrs.field(validator=attrs.validators.matches_re(RESULT_CODE_REGEX)) """ The outcome of the decision tree check; e.g. 'A55' """ diff --git a/src/ebdtable2graph/models/ebd_table.py b/src/ebdtable2graph/models/ebd_table.py index 591f32a..0591994 100644 --- a/src/ebdtable2graph/models/ebd_table.py +++ b/src/ebdtable2graph/models/ebd_table.py @@ -59,6 +59,9 @@ class EbdCheckResult: """ +RESULT_CODE_REGEX = r"^((?:[A-Z]\d+)|(?:A\*{2})|(?:A[A-Z]\d))$" + + @attrs.define(auto_attribs=True, kw_only=True) class EbdTableSubRow: """ @@ -72,7 +75,7 @@ class EbdTableSubRow: The column 'Prüfergebnis' """ result_code: Optional[str] = attrs.field( - validator=attrs.validators.optional(attrs.validators.matches_re(r"^((?:[A-Z]\d+)|(?:A\*{2})|(?:A[A-Z]\d))$")) + validator=attrs.validators.optional(attrs.validators.matches_re(RESULT_CODE_REGEX)) ) """ The outcome if no subsequent step was defined in the CheckResult.