Browse Source

lieferservice: support german

Fabian Peter Hammerle 8 years ago
parent
commit
96379b538f
2 changed files with 11 additions and 9 deletions
  1. 9 7
      scripts/order-confirmation-mail-parser
  2. 2 2
      setup.py

+ 9 - 7
scripts/order-confirmation-mail-parser

@@ -390,12 +390,12 @@ def parse_lieferservice(msg):
         raise Exception('no lieferservice.at confirmation')
 
     order_match = re.search(
-            ur'Your order \(.+\) at (?P<restaurant>.*)\s+'
-                + ur'Your order reference is: (?P<order_id>.*)\s+'
+            ur'(Your order|Ihre Bestellung) \(.+\) (at|bei) (?P<restaurant>.*)\s+'
+                + ur'(Your order reference is|Ihre Bestellnummer lautet): (?P<order_id>.*)\s+'
                 + ur'[\W\w]+'
-                + ur'Your order\s+'
+                + ur'(Your order|Ihre Bestellung)\s+'
                 + ur'(?P<orders_text>[\W\w]+)'
-                + ur'Delivery costs:\s+(?P<delivery_costs>.*)\s+',
+                + ur'(Delivery costs|Lieferung):\s+(?P<delivery_costs>.*)\s+',
             text,
             re.UNICODE,
             )
@@ -414,6 +414,8 @@ def parse_lieferservice(msg):
         order_date
         )
 
+    restaurant = order_match_groups['restaurant'].strip('"')
+
     for article_match in re.finditer(
             ur'(?P<quantity>\d+)x\s'
                 + ur'(?P<name>.*)\s'
@@ -440,12 +442,12 @@ def parse_lieferservice(msg):
                 name = name,
                 quantity = 1,
                 price_brutto = price,
-                reseller = order_match_groups['restaurant'],
-                shipper = order_match_groups['restaurant'],
+                reseller = restaurant,
+                shipper = restaurant,
                 ))
 
     delivery_costs = order_match_groups['delivery_costs'].strip()
-    assert delivery_costs == 'FREE'
+    assert delivery_costs in ['FREE', 'GRATIS']
     order.items.append(dingguo.Item(
         name = u'Delivery',
         price_brutto = dingguo.Sum(float('0'.replace(',', '.')), u'EUR'),

+ 2 - 2
setup.py

@@ -13,10 +13,10 @@ setup(
     # keywords = [],
     # classifiers = [],
     packages = [
-        'dingguo', 
+        'dingguo',
         'dingguo.parser',
         ],
     scripts = glob.glob('scripts/*'),
     install_requires = ['pdfminer>=20140328'],
-    tests_require = ['pytest']
+    tests_require = ['pytest'],
     )