Skip to content

Commit

Permalink
fixed merging issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaDaniel committed Aug 14, 2024
1 parent 320f77f commit 2c60871
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/migmose/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,19 @@ def process_segmentlayouts(segmentlayout_tables: list[list[_Cell]]) -> dict[str,
)
)
return segment_layouts_dict


def _extract_document_version(path: Path) -> str:
document_str = str(path)
pattern = (
r"MIG(?:Strom|Gas)?-?informatorischeLesefassung?(.*?)"
r"(?:_|KonsolidierteLesefassung|-AußerordentlicheVeröffentlichung)"
)
matches = re.search(pattern, document_str, re.IGNORECASE)
if matches:
document_version = matches.group(1)
if document_version == "":
logger.warning(f"❌ No document version found in {path}.", fg="red")
return document_version
logger.error(f"❌ Unexpected document name in {path}.", fg="red")
return ""
2 changes: 1 addition & 1 deletion unittests/test_reduced_nested_nachrichtenstruktur.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_output_tree(self, message_format: EdifactFormat, tmp_path, snapshot):
[message_format], path_to_test_edi_energy_mirror_repo, EdifactFormatVersion.FV2310
)
file_path = file_path_dict[message_format]
raw_lines = parse_raw_nachrichtenstrukturzeile(file_path)
raw_lines, _ = parse_raw_nachrichtenstrukturzeile(file_path)
nachrichtenstrukturtabelle = NachrichtenstrukturTabelle.create_nachrichtenstruktur_tabelle(raw_lines)
nested_nachrichtenstruktur, _ = NestedNachrichtenstruktur.create_nested_nachrichtenstruktur(
nachrichtenstrukturtabelle
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_segment_group_hierarchies.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_create_create_segmentgroup_hierarchy(self, message_format: EdifactForma
[message_format], path_to_test_edi_energy_mirror_repo, EdifactFormatVersion.FV2310
)
file_path = file_path_dict[message_format]
raw_lines = parse_raw_nachrichtenstrukturzeile(file_path)
(raw_lines, _) = parse_raw_nachrichtenstrukturzeile(file_path)
nachrichtenstrukturtabelle = NachrichtenstrukturTabelle.create_nachrichtenstruktur_tabelle(raw_lines)
nested_nachrichtenstruktur, _ = NestedNachrichtenstruktur.create_nested_nachrichtenstruktur(
nachrichtenstrukturtabelle
Expand Down

0 comments on commit 2c60871

Please sign in to comment.