Skip to content

Commit b93f6c5

Browse files
authored
fix: version in filename (#165)
* Modified regex pattern and adapted tests
1 parent 51f4f6d commit b93f6c5

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

src/migmose/parsing.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ def get_latest_file(file_list: list[Path]) -> Path:
7676
Returns:
7777
Path: The path of the latest file. Returns None if no valid date is found.
7878
"""
79-
# Initialize variables to keep track of the latest file and date
80-
if len(file_list) == 1:
81-
logger.info("Using the only file: {}", file_list[0])
82-
return file_list[0]
8379
try:
8480
# Define the keywords to filter relevant files
8581
keywords = ["konsolidiertelesefassungmitfehlerkorrekturen", "außerordentlicheveröffentlichung"]
@@ -160,8 +156,9 @@ def parse_raw_nachrichtenstrukturzeile(input_path: Path) -> list[str]:
160156

161157

162158
_pattern = re.compile(
163-
r"MIG(?:Strom|Gas)?-?informatorischeLesefassung?(?P<version>(?P<major>\d+)\.(?P<minor>\d+)(?P<suffix>[a-z]?))"
164-
r"(?:_|KonsolidierteLesefassung|-AußerordentlicheVeröffentlichung)",
159+
r"MIG(?:Strom|Gas)?(?:-informatorischeLesefassung)?"
160+
r"(?P<version>(?:S|G)?(?P<major>\d+)\.(?P<minor>\d+)(?P<suffix>[a-z]?))"
161+
r"(?:_|KonsolidierteLesefassung|-AußerordentlicheVeröffentlichung)?",
165162
re.IGNORECASE,
166163
)
167164

unittests/__snapshots__/test_parsing.ambr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
# ---
2626
# name: TestParsing.test_extract_document_version[UTILMDG]
2727
tuple(
28-
'',
29-
None,
30-
None,
31-
'',
28+
'G1.0a',
29+
1,
30+
0,
31+
'a',
3232
)
3333
# ---
3434
# name: TestParsing.test_extract_document_version[UTILMDS]
3535
tuple(
36-
'',
37-
None,
38-
None,
36+
'S1.1',
37+
1,
38+
1,
3939
'',
4040
)
4141
# ---

unittests/test_parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_parse_raw_nachrichtenstrukturzeile(self):
100100
pytest.param(
101101
Path(
102102
"edi_energy_de/FV2310/IFTSTAMIG-informatorischeLesefassung-AußerordentlicheVeröffentlichung_20231022_20231001.docx"
103-
),
103+
), # will return nothing as there is no version number
104104
id="IFTSTA",
105105
),
106106
pytest.param(

0 commit comments

Comments
 (0)