Skip to content

Commit 482d83a

Browse files
committed
simplify pattern matching code
1 parent 41804ae commit 482d83a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

scripts/generator/pydifact_generator.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,18 +494,17 @@ def parse_composite_dir(text, only_code: str | None = None):
494494
# Cont: 1154 Reference number C an..35 an 1 35
495495
# 1156 Line number C an..6 an 1 6
496496

497-
pattern = re.match(
497+
if pattern := re.match(
498498
r"^(\d{3})\s+(\d{4})\s+(.*?)\s+([MC])\s+([an]+\.?\.?\d+)\s*$", line
499-
)
500-
if pattern:
499+
):
501500
pos, code, title, mandatory, repr_line = pattern.groups()
502501
else:
503-
pattern = re.match(
502+
if pattern := re.match(
504503
r"\s{10,18}(?:Cont: )?(\d{4})\s+(.*?)\s+([MC])\s+([an.\d]+)",
505504
line,
506-
)
507-
if pattern:
505+
):
508506
code, title, mandatory, repr_line = pattern.groups()
507+
# TODO: count and create POS manually
509508
pos = "000"
510509
if pattern:
511510
is_mandatory = mandatory == "M"

0 commit comments

Comments
 (0)