Skip to content

Commit

Permalink
Revert "Revert "1.5""
Browse files Browse the repository at this point in the history
  • Loading branch information
hparfr committed May 2, 2017
1 parent c51f6f7 commit 877aab3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Roadmap / TODO:
- Support additionnal methods of api
- Write tests

# 0.1.5 2017-05-02
- fix escaping issue in DPD
- fix output of DPD (now always base64 decoded)

# 0.1.4 2017-03-20
- Automatic deployment to pypi

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.4
0.1.5
9 changes: 6 additions & 3 deletions roulier/carriers/dpd/dpd_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from lxml import objectify
from roulier.codec import Decoder
from roulier import ws_tools as tools
import base64


class DpdDecoder(Decoder):
Expand All @@ -19,6 +20,8 @@ def create_shipment_with_labels(msg):
label, attachment = labels.getchildren()
label_data = self.handle_zpl(label.label.text, output_format)
# .text because we want str instead of objectify.StringElement
summary_data = base64.b64decode(attachment.label.text)
summary_format = output_format == 'ZPL' and 'png' or output_format
x = {
"tracking": {
'number': shipment.barcode.text,
Expand All @@ -30,9 +33,9 @@ def create_shipment_with_labels(msg):
"type": output_format,
},
"annexes": [{
"data": attachment.label.text,
"data": summary_data,
"name": "Summary",
"type": output_format
"type": summary_format
}]
}
return x
Expand All @@ -54,4 +57,4 @@ def handle_zpl(self, png, label_format):
if label_format == 'ZPL':
return tools.png_to_zpl(png, True)
else:
return png
return base64.b64decode(png)
3 changes: 2 additions & 1 deletion roulier/carriers/dpd/dpd_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def encode(self, api_input, action):

env = Environment(
loader=PackageLoader('roulier', '/carriers/dpd/templates'),
extensions=['jinja2.ext.with_'])
extensions=['jinja2.ext.with_', 'jinja2.ext.autoescape'],
autoescape=True)

template = env.get_template("dpd_%s.xml" % action)
return {
Expand Down

0 comments on commit 877aab3

Please sign in to comment.