|
@@ -34,15 +34,18 @@ def parse_order_confirmation_mail(mail):
|
|
|
def get_text(tag):
|
|
|
return u''.join([c if type(c) is BeautifulSoup.NavigableString else get_text(c) for c in tag.contents])
|
|
|
|
|
|
- shipping_attr = re.search(
|
|
|
- ur'^Shipping(?P<dest>.*)\((?P<price>.*)\)$',
|
|
|
- doc.find(text = re.compile('Shipping')).parent.parent.text,
|
|
|
- ).groupdict()
|
|
|
-
|
|
|
- shipping = dingguo.Shipping(
|
|
|
- destination_point = shipping_attr['dest'].strip(),
|
|
|
- price_brutto = dingguo.Sum.parse_text(shipping_attr['price']),
|
|
|
- )
|
|
|
+ shipping_label_tag = doc.find(text = re.compile('Shipping'))
|
|
|
+ if shipping_label_tag:
|
|
|
+ shipping_attr = re.search(
|
|
|
+ ur'^Shipping(?P<dest>.*)\((?P<price>.*)\)$',
|
|
|
+ shipping_label_tag.parent.parent.text,
|
|
|
+ ).groupdict()
|
|
|
+ shipping = dingguo.Shipping(
|
|
|
+ destination_point = shipping_attr['dest'].strip(),
|
|
|
+ price_brutto = dingguo.Sum.parse_text(shipping_attr['price']),
|
|
|
+ )
|
|
|
+ else:
|
|
|
+ shipping = None
|
|
|
|
|
|
pledge_amount = dingguo.Sum.parse_text(
|
|
|
doc.find(text = re.compile('Amount pledged')).parent.parent.text.replace('Amount pledged', '')
|
|
@@ -56,11 +59,12 @@ def parse_order_confirmation_mail(mail):
|
|
|
doc.find(text = re.compile('your card will be charged on')).findNext('time')['datetime']
|
|
|
),
|
|
|
),
|
|
|
- price_brutto = pledge_amount - shipping.price_brutto,
|
|
|
+ price_brutto = pledge_amount - shipping.price_brutto if shipping else pledge_amount,
|
|
|
reward = get_text(doc.find(text = re.compile('Reward')).findPrevious('td'))
|
|
|
.strip()[len('Reward'):].strip().replace('\r\n', '\n'),
|
|
|
))
|
|
|
|
|
|
- order.items.append(shipping)
|
|
|
+ if shipping:
|
|
|
+ order.items.append(shipping)
|
|
|
|
|
|
return [order]
|