diff --git a/app.py b/app.py
index fcf556a..a63dcdf 100644
--- a/app.py
+++ b/app.py
@@ -1,6 +1,7 @@
import os
import json
import datetime as dt
+import sys
import lxml.etree
from lxml import etree
import win32com.client as win32
@@ -20,9 +21,20 @@ class App:
self._attach_file = False
self._text = None
self._print_console = True
+ self._autoremove = True
self._read_config()
+ if len(sys.argv) > 1:
+ self._path = sys.argv[1]
+ if os.path.isfile(self._path):
+ self.read_xml(self._path)
+ else:
+ files = [file for file in os.listdir(self._path) if os.path.isfile(self._path + os.path.sep + file)]
+ for file in files:
+ self.read_xml(self._path + os.path.sep + file)
+
+
def read_xml(self, path, hide_empty=True):
self._text = ""
with open(path, encoding="utf-8") as xml_file:
@@ -36,12 +48,14 @@ class App:
if self._send_outlook:
outlook = win32.gencache.EnsureDispatch('Outlook.Application')
new_mail = outlook.CreateItem(0)
- new_mail.Subject = "Test"
+ new_mail.Subject = ""
new_mail.Body = self._text
if self._attach_file:
abs_path = os.path.abspath(path)
new_mail.Attachments.Add(Source=abs_path)
new_mail.Display(True)
+ if self._autoremove:
+ os.remove(path)
def _read_element(self, element, sign="", hide_empty=True):
element_text = element.text
@@ -54,7 +68,7 @@ class App:
elif element.tag.find("AKTION") > -1:
num = int(element_text)
self._print(sign, self._clean_xmlns(element.tag), self._delimiter, AktionsStatus.get_status(num), end=self._endline)
- elif self._convert_date and element.tag.find("NKZEIT") > -1:
+ elif self._convert_date and element.tag.find("ZEIT") > -1:
time = dt.datetime.strptime(element_text, "%H%M%S")
uhrzeit = time.strftime("%H:%M:%S")
self._print(sign, self._clean_xmlns(element.tag), self._delimiter, uhrzeit,
@@ -119,4 +133,7 @@ class App:
self._send_outlook = send
if attach:
self._attach_file = attach
+ autoremove = json_raw.get("autoremove")
+ if autoremove is not None:
+ self._autoremove = autoremove
diff --git a/config.json b/config.json
index 54acab8..334e884 100644
--- a/config.json
+++ b/config.json
@@ -1,20 +1,20 @@
{
- "path": null,
- "hide-elements": [
- "PO", "TO", "ADR-AG", "ADR-FZ",
+ "path": "C:\\Users\\a.jurcenko\\Desktop\\xml to send",
+ "hide-elements": ["PO", "TO", "ADR-AG", "ADR-FZ",
"ADR-UNT","AK", "NKNR",
"NVE", "GGVS", "POFD",
"ABR", "LM", "INFO", "RSTK", "FD",
"ADR-VU", "SD", "ADR-BST", "ADR-EST", "ADR-ABS",
"ADR-EMP", "FZGD"
+
],
"delimiter": ": ",
"endline": "\n",
"prefix": "\t",
"convert-date": true,
"outlook": {
- "send": false,
- "attach-file": false,
+ "send": true,
+ "attach-file": true,
"conditions": {
"CarloIn": {
"to": [
@@ -23,5 +23,6 @@
}
}
},
- "print-console": true
+ "print-console": true,
+ "autoremove": true
}
\ No newline at end of file
diff --git a/main.py b/main.py
index d69f4b2..98364f5 100644
--- a/main.py
+++ b/main.py
@@ -4,6 +4,14 @@ app = App()
if __name__ == '__main__':
+ pass
# app.read_xml("testdata/01_WA20230811_133614.xml")
- app.read_xml("testdata/01_11082023113554_266287-LS.xml")
+ # app.read_xml("testdata/01_11082023113554_266287-LS.xml")
# app.read_xml("testdata/TOUROUT00008445_001.XML")
+ # app.read_xml("testdata/01_B420230818_070805.xml.xml")
+ # app.read_xml("testdata/02_B420230818_070805.xml.xml")
+ # app.read_xml("testdata/03_B420230818_070805.xml.xml")
+ # app.read_xml("testdata/04_B420230818_070805.xml.xml")
+ # app.read_xml("testdata/05_B420230818_070805.xml.xml")
+ # app.read_xml("testdata/06_B420230818_070805.xml.xml")
+ # app.read_xml("testdata/07_B420230818_070805.xml.xml")
diff --git a/testdata/01_11082023113554_266287-LS.xml b/testdata/01_11082023113554_266287-LS.xml
deleted file mode 100644
index d5216e1..0000000
--- a/testdata/01_11082023113554_266287-LS.xml
+++ /dev/null
@@ -1,509 +0,0 @@
-
-
-
- 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
deleted file mode 100644
index af49c7c..0000000
--- a/testdata/01_WA20230811_133614.xml
+++ /dev/null
@@ -1,292 +0,0 @@
-
-
-
- 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
deleted file mode 100644
index 87ae041..0000000
--- a/testdata/TOUROUT00008445_001.XML
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
- 00008445
-
-
- 20230811
- 124021
-
-
-
-
-
-
-
- 3
- 1
- 2223369187
- 957232
-
-
-