[Calypso] [PATCH] Use UTF-8 when importing files to avoid mojobake
Petter Reinholdtsen
pere at hungry.com
Fri Jan 22 00:49:19 PST 2016
In Debian bug #780034, there is a patch by Gregor Herrmann to make sure
files are imported as UTF-8, making sure non-ascii characters make it
into the database. I've tested the patch, and it work just fine.
Note, the patch uses 'utf8', while other parts of the code uses 'utf-8'
for the same effect. Perhaps this should be changed for consistency.
Is there a preference in the project for either of these
decoding/encoding strings?
diff --git a/calypso/webdav.py b/calypso/webdav.py
index fca1636..6922cce 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -552,10 +552,11 @@ class Collection(acl.Entity):
if ve.contents.has_key('dtstart') and ve.contents.has_key('duration'):
del ve.contents['duration']
new_ics.vevent_list = [ve]
- new_item = Item(new_ics.serialize(), None, path)
+ # serialize returns a str, Item expects unicode
+ new_item = Item(new_ics.serialize().decode('utf8'), None, path)
self.import_item(new_item, path)
else:
- new_item = Item(new_ics.serialize(), None, path)
+ new_item = Item(new_ics.serialize().decode('utf8'), None, path)
self.import_item(new_item, path)
return True
except Exception, ex:
--
Happy hacking
Petter Reinholdtsen
More information about the Calypso
mailing list