From 1c4902bc18ae829d778d623c8da0ff291ba15604 Mon Sep 17 00:00:00 2001 From: "a.jurcenko" Date: Mon, 14 Aug 2023 17:05:18 +0200 Subject: [PATCH] Initial Commit --- .idea/.gitignore | 3 + .../inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 4 + .idea/modules.xml | 8 + .idea/xml_status_reader.iml | 10 + aktion_status.py | 15 + app.py | 37 ++ main.py | 9 + requirements.txt | Bin 0 -> 28 bytes testdata/01_11082023113554_266287-LS.xml | 509 ++++++++++++++++++ testdata/01_WA20230811_133614.xml | 292 ++++++++++ testdata/TOUROUT00008445_001.XML | 23 + 12 files changed, 916 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/xml_status_reader.iml create mode 100644 aktion_status.py create mode 100644 app.py create mode 100644 main.py create mode 100644 requirements.txt create mode 100644 testdata/01_11082023113554_266287-LS.xml create mode 100644 testdata/01_WA20230811_133614.xml create mode 100644 testdata/TOUROUT00008445_001.XML diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d9e9f69 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c4a4f4c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/xml_status_reader.iml b/.idea/xml_status_reader.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/.idea/xml_status_reader.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/aktion_status.py b/aktion_status.py new file mode 100644 index 0000000..1e12650 --- /dev/null +++ b/aktion_status.py @@ -0,0 +1,15 @@ + + +class AktionsStatus: + status = { + 1: "Neuer Auftrag", + 2: "Auftrag Ändern", + 3: "Auftrag Löschen", + 4: "Wenn Auftrag existiert - anhängen mit Abgleich", + 5: "Wenn Auftrag existiert - immer anhängen", + 6: "Statusmeldung", + } + + @classmethod + def get_status(cls, st: int): + return cls.status.get(st) diff --git a/app.py b/app.py new file mode 100644 index 0000000..5a46f50 --- /dev/null +++ b/app.py @@ -0,0 +1,37 @@ +import lxml.etree +from lxml import etree +from aktion_status import AktionsStatus + + +class App: + + def __init__(self): + pass + + def read_xml(self, path, hide_empty=True): + with open(path, encoding="utf-8") as xml_file: + head = xml_file.readline() + xml = xml_file.read() + root = etree.fromstring(xml) + for data in root.getchildren(): + + for elem in data.getchildren(): + self.read_element(elem, hide_empty=hide_empty) + + def read_element(self, element, sign="", hide_empty=True): + element_text = element.text + if hide_empty and not element_text or isinstance(element, lxml.etree._Comment) or isinstance(element, lxml.etree._ProcessingInstruction): + pass + elif element.tag.find("AKTION") > -1: + num = int(element_text) + print(sign, self.clean_xmlns(element.tag), AktionsStatus.get_status(num)) + else: + print(sign, self.clean_xmlns(element.tag), element.text if element.text else "") + if len(element.getchildren()) > 0: + for el in element.getchildren(): + self.read_element(el, sign+"\t") + + def clean_xmlns(self, tag_text): + if tag_text and tag_text.startswith("{"): + return tag_text.split("}")[1] + return tag_text diff --git a/main.py b/main.py new file mode 100644 index 0000000..d69f4b2 --- /dev/null +++ b/main.py @@ -0,0 +1,9 @@ +from app import App + +app = App() + + +if __name__ == '__main__': + # app.read_xml("testdata/01_WA20230811_133614.xml") + app.read_xml("testdata/01_11082023113554_266287-LS.xml") + # app.read_xml("testdata/TOUROUT00008445_001.XML") diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..a40cd1367d2da0779320061bc018d4c02caae7f3 GIT binary patch literal 28 gcmezWFNdLmA(tVC!4?Qj81xt{f!LUVmw}4`0C5flNB{r; literal 0 HcmV?d00001 diff --git a/testdata/01_11082023113554_266287-LS.xml b/testdata/01_11082023113554_266287-LS.xml new file mode 100644 index 0000000..d5216e1 --- /dev/null +++ b/testdata/01_11082023113554_266287-LS.xml @@ -0,0 +1,509 @@ + + + + 20230811 + 113436 + + 2 + 0 + WO_04266287 + 2 + 20230809 + 1 + + 0 + + 32200 + + + 0 + + + 0 + + + 0 + 0 + + + 0 + 04266287 + 0 + + 2 + + + 0 + 1021855 + + Orterer + Getränkemarkt GmbH + + München + D + D + 80807 + Milbertshofener Str.69 + + + + 0 + + + 0 + + + 0 + + + 0 + 0 + 0.000 + 311.27 + 311.27 + 311.27 + 0.000 + 0.000 + 0.000 + 1 + 0 + 0.000 + 0.000 + 0.000 + + + 20230809 + 20230809 + 0 + 0 + 0 + 0.000 + 0.000 + 0.000 + 0 + 0 + 0 + + + + + + 0 + 0 + + + 0.000 + 0.000 + 1 + 1 + + + 1 + + + 26.75 + 26.75 + 26.75 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 4.000000 + WO Geniesserkiste + 320100 + 1 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 2 + + + 0.0 + 0.0 + 0.0 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000000 + Wolfra Mehrfruchtsaft + 325400 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 3 + + + 0.0 + 0.0 + 0.0 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000000 + Wolfra Apfelsaft klar + 303400 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 4 + + + 33.897 + 33.897 + 33.897 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 3.000000 + Wolfra Bio-Apfelsaft naturtr + 316700 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 5 + + + 56.51 + 56.51 + 56.51 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 5.000000 + Wolfra Milder Apfel + 351700 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 6 + + + 33.883 + 33.883 + 33.883 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 3.000000 + Wolfra Milde Orange + 333700 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 7 + + + 0.0 + 0.0 + 0.0 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000000 + Wolfra schw. Johannis-Nektar + 301700 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 8 + + + 33.973 + 33.973 + 33.973 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 3.000000 + Wolfra Maracuja - Nektar + 314700 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 9 + + + 33.867 + 33.867 + 33.867 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 3.000000 + WO Rhabarber-Nektar + 317700 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 10 + + + 0.0 + 0.0 + 0.0 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000000 + Wolfra Maracuja Schorle + 374200 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 11 + + + 33.966 + 33.966 + 33.966 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 3.000000 + Wolfra Birnensaft-naturtrüb + 302700 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 12 + + + 22.871 + 22.871 + 22.871 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 2.000000 + Wolfra Traubensaft rot + 306700 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 13 + + + 22.721 + 22.721 + 22.721 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 2.000000 + Wolfra Pfirsich - Nektar + 329700 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + 14 + + + 22.0 + 22.0 + 22.0 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 1.000000 + Europalette 1200x800 + 9800 + 0.000 + 0.000 + 0.000 + 0.000 + + + 0.000 + 0.000 + + + + + + + + + diff --git a/testdata/01_WA20230811_133614.xml b/testdata/01_WA20230811_133614.xml new file mode 100644 index 0000000..af49c7c --- /dev/null +++ b/testdata/01_WA20230811_133614.xml @@ -0,0 +1,292 @@ + + + + 20230811 + 133614 + + 3 + 0 + WA_0028327242 + 1 + + + + + 1 + + + 11801 + + + 0 + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + 0 + + 0 + + + + + + + + 0 + 0028327242 + 0 + + 300573 + + + + + + + + + + + + + + + 0 + 0001584658 + + DACHSER SE + Logistikzentrum Hof + Hof + D + D + 95030 + Hermann und Bertl Müller Str. 3 + + + + + + 0 + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + 3.000 + 1699.380 + 1658.880 + 1699.380 + 0.000 + CIP + + + 20230816 + + + + 20230817 + + + + 0 + 0 + + + 0.000 + 0.000 + 0.000 + 0 + 0 + 0 + + + mind. 24 Std. vor Auslieferung bei der Adresse zu avisieren: warehouse / -el.hof@dachser.com Tel. 09281/6290 4212 + + + + + + + Kristin Heinrich + + + + + + 3 x , 3 x PALETTE 760x1140 CP5 HITZEBEHANDEL - 3 x , 3 x KARTON HTV 540KG 1150X 720X 730 WP + + + + + 2702/01 ULZ + Alexander Kröger, 0711-61942-41, alexander.kroeger + + + + + + + + + + + 1 + 3 x , 3 x PALETTE 760x1140 CP5 HITZEBEHANDEL + + 13,800 + + + + 40.500 + 0.000 + 40.500 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 3.000 + + + + + 0.000 + 0.000 + 0.000 + 0.000 + + + + + + + + + + + + + + 0.000 + + 0.000 + + + 2 + 3 x , 3 x KARTON HTV 540KG 1150X 720X 730 WP + + 13,800 + + + + 1658.880 + 1658.880 + 1658.880 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + 3.000 + ELASTOSIL® R 401/40 S 540KG KARTON + + + 60006597 + 0.000 + 0.000 + 0.000 + 0.000 + + + + + + + + + + + + + + 0.000 + + 0.000 + + + + + diff --git a/testdata/TOUROUT00008445_001.XML b/testdata/TOUROUT00008445_001.XML new file mode 100644 index 0000000..87ae041 --- /dev/null +++ b/testdata/TOUROUT00008445_001.XML @@ -0,0 +1,23 @@ + + + + + 00008445 + + + 20230811 + 124021 + + + + + + + + 3 + 1 + 2223369187 + 957232 + + +