Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: version in filename #165

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/migmose/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ def get_latest_file(file_list: list[Path]) -> Path:
Returns:
Path: The path of the latest file. Returns None if no valid date is found.
"""
# Initialize variables to keep track of the latest file and date
if len(file_list) == 1:
logger.info("Using the only file: {}", file_list[0])
return file_list[0]
try:
# Define the keywords to filter relevant files
keywords = ["konsolidiertelesefassungmitfehlerkorrekturen", "außerordentlicheveröffentlichung"]
Expand Down Expand Up @@ -160,8 +156,9 @@ def parse_raw_nachrichtenstrukturzeile(input_path: Path) -> list[str]:


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

Expand Down
14 changes: 7 additions & 7 deletions unittests/__snapshots__/test_parsing.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
# ---
# name: TestParsing.test_extract_document_version[UTILMDG]
tuple(
'',
None,
None,
'',
'G1.0a',
1,
0,
'a',
)
# ---
# name: TestParsing.test_extract_document_version[UTILMDS]
tuple(
'',
None,
None,
'S1.1',
1,
1,
'',
)
# ---
2 changes: 1 addition & 1 deletion unittests/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_parse_raw_nachrichtenstrukturzeile(self):
pytest.param(
Path(
"edi_energy_de/FV2310/IFTSTAMIG-informatorischeLesefassung-AußerordentlicheVeröffentlichung_20231022_20231001.docx"
),
), # will return nothing as there is no version number
id="IFTSTA",
),
pytest.param(
Expand Down