Skip to content

Commit ef363e1

Browse files
author
Konstantin
committed
Revert "feat: normalize/sanitize Anwendungsfall.beschreibung"
This reverts commit 0797061.
1 parent dc883fb commit ef363e1

3 files changed

Lines changed: 4 additions & 48 deletions

File tree

src/fundamend/reader/ahbreader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
_is_segment_group,
3232
_is_uebertragungsdatei,
3333
)
34-
from fundamend.utils import lstrip, remove_linebreaks_and_hyphens, strip
34+
from fundamend.utils import lstrip, strip
3535

3636
# pylint:disable=duplicate-code
3737
# yes, it's very similar to the MigReader
@@ -252,7 +252,7 @@ def _read_anwendungsfall(self, original_element: ET.Element) -> Anwendungsfall:
252252
format_element = next((child for child in original_element[0] if child.tag.startswith("M_")))
253253
return Anwendungsfall(
254254
pruefidentifikator=original_element.attrib["Pruefidentifikator"],
255-
beschreibung=remove_linebreaks_and_hyphens(original_element.attrib["Beschreibung"]),
255+
beschreibung=original_element.attrib["Beschreibung"].strip(),
256256
kommunikation_von=original_element.attrib["Kommunikation_von"].strip(),
257257
format=EdifactFormat(lstrip("M_", format_element.tag)),
258258
elements=tuple(segments_and_groups),

src/fundamend/utils.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,6 @@ def strip(prefix: str, text: str, suffix: str) -> str:
5353
return lstrip(prefix, rstrip(text, suffix))
5454

5555

56-
_replacements: dict[str, str] = {
57-
"-\r\n": "",
58-
"\r\n": " ",
59-
"\r": "",
60-
"\n": "",
61-
}
62-
63-
64-
def remove_linebreaks_and_hyphens(original: str) -> str:
65-
"""
66-
Normalize a multi line string by stripping leading and trailing whitespace and removing line breaks.
67-
68-
Args:
69-
original: The string to normalize.
70-
71-
Returns:
72-
The normalized string.
73-
"""
74-
result = original
75-
for old, new in _replacements.items():
76-
result = result.replace(old, new)
77-
# if you add more replacement rules, please also add a unit test in bltest_utils.py
78-
return " ".join(result.strip().split())
79-
80-
8156
_UNIFIED_SEPARATOR = "/" # how multiple Marktrollen shall be split in the kommunikation_von attribute
8257
_ALTERNATIVE_SEPARATORS = [","] # other separators that are used in the wild
8358

@@ -143,4 +118,4 @@ def parse_kommunikation_von(kommunikation_von: Optional[str]) -> list[Kommunikat
143118
return result
144119

145120

146-
__all__ = ["lstrip", "rstrip", "strip", "remove_linebreaks_and_hyphens", "parse_kommunikation_von"]
121+
__all__ = ["lstrip", "rstrip", "strip", "parse_kommunikation_von"]

unittests/test_utils.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,11 @@
55

66
from fundamend import AhbReader
77
from fundamend.models.anwendungshandbuch import Anwendungsfall, Kommunikationsrichtung
8-
from fundamend.utils import parse_kommunikation_von, remove_linebreaks_and_hyphens
8+
from fundamend.utils import parse_kommunikation_von
99

1010
from .conftest import is_private_submodule_checked_out
1111

1212

13-
@pytest.mark.parametrize(
14-
"original, expected",
15-
[
16-
pytest.param("foo", "foo", id="no change"),
17-
pytest.param("foo ", "foo", id="trailing whitespace"),
18-
pytest.param(" foo", "foo", id="leading whitespace"),
19-
pytest.param(" foo ", "foo", id="trailing and leading whitespaces"),
20-
pytest.param(" foo\r\n ", "foo", id="trailing and leading whitespaces and line break"),
21-
# hyphen requirements discussed here:
22-
# https://github.com/Hochfrequenz/xml-fundamend-python/issues/172#issue-3427724092
23-
pytest.param(" Foo-\r\nbar ", "Foobar", id="hyphen with line break"),
24-
pytest.param(" Foo\r\n and bar ", "Foo and bar", id="line break w/o hyphen"),
25-
],
26-
)
27-
def test_anwendungsfall_beschreibung_normalization(original: str, expected: str) -> None:
28-
actual = remove_linebreaks_and_hyphens(original)
29-
assert actual == expected
30-
31-
3213
@pytest.mark.parametrize(
3314
"original, expected",
3415
[

0 commit comments

Comments
 (0)