diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fd9379..7892ddc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Roadmap / TODO: - Support additionnal methods of api - Write tests +# 0.3.3 2018-02-19 + - Geodis force ASCII conversion for EDI. # 0.3.2 2018-02-06 - Geodis fix missing CTA segment diff --git a/VERSION b/VERSION index d15723f..1c09c74 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.2 +0.3.3 diff --git a/roulier/carriers/geodis/geodis_transport_edi.py b/roulier/carriers/geodis/geodis_transport_edi.py index 76b51f6..2db8074 100644 --- a/roulier/carriers/geodis/geodis_transport_edi.py +++ b/roulier/carriers/geodis/geodis_transport_edi.py @@ -53,7 +53,7 @@ def parse_lines(lines): return "\n".join([parse_segment(segment) for segment in lines]) def sanitize(token): - # replace escapable chars by space + # remove accents and replace escapable chars by space # because, replacing "'" by "?'" # increase length of the token # which is limited by 35 @@ -63,7 +63,35 @@ def sanitize(token): .replace("'", " ") .replace("+", " ") .replace(":", " ") - ) + # quick and dirty replacement + # of common accentued chars in french + # because geodis don't handle well utf8 + # TODO: put it in api coerce + .replace(u"é", "e") + .replace(u"è", "e") + .replace(u"ë", "e") + .replace(u"ê", "e") + .replace(u"ô", "o") + .replace(u"ï", "i") + .replace(u"ö", "o") + .replace(u"à", "a") + .replace(u"â", "a") + .replace(u"ç", "c") + .replace(u"û", "u") + .replace(u"ù", "u") + .replace(u"É", "E") + .replace(u"È", "E") + .replace(u"Ë", "E") + .replace(u"Ê", "E") + .replace(u"Ô", "O") + .replace(u"Ï", "I") + .replace(u"Ö", "O") + .replace(u"À", "A") + .replace(u"Â", "A") + .replace(u"Ç", "C") + .replace(u"Û", "U") + .replace(u"Ù", "U") + ).encode('ascii', 'ignore') # cut remaining chars return sanitized return parse_lines(arr)