[Calypso-commits] [calypso] 05/07: Newer python-vobject return bytestrings

Guido Guenther agx at moszumanska.debian.org
Thu Jun 22 13:28:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

agx pushed a commit to branch master
in repository calypso.

commit a3a397e05dca4d46bcaea237af6e5c69e5593059
Author: Guido Günther <agx at sigxcpu.org>
Date:   Sat Apr 8 20:54:56 2017 +0200

    Newer python-vobject return bytestrings
    
    so decode properly from utf-8.
    
    This unbreaks calypso with newer python-vobject:
    
        https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=841247
---
 calypso/webdav.py        | 23 ++++++++++++-----------
 requirements.txt         |  2 +-
 tests/test_collection.py |  2 +-
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/calypso/webdav.py b/calypso/webdav.py
index 4fc128c..0bbf5cf 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -433,9 +433,15 @@ class Collection(object):
         self.log.debug('Wrote %s to %s', file, path)
         return path
 
+    def _action_msg(self, action, item):
+        return u'%s %s' % (action, str(item).decode('utf-8'))
+
+    def _log_action(self, action, item):
+        self.log.debug("%s %s", action, item.name.decode('utf-8'))
+
     def create_file(self, item, context):
         # Create directory if necessary
-        self.log.debug("Add %s", item.name)
+        self._log_action("Add", item)
         if not os.path.exists(os.path.dirname(self.path)):
             try:
                 os.makedirs(os.path.dirname(self.path))
@@ -443,8 +449,7 @@ class Collection(object):
                 self.log.exception("Failed to make collection directory %s: %s", self.path, ose)
                 raise
 
-        context['action'] = u'Add %s'%item
-
+        context['action'] = self._action_msg("Add", item)
         try:
             path = self.write_file(item)
             self.git_add(path, context=context)
@@ -458,10 +463,8 @@ class Collection(object):
             raise
 
     def destroy_file(self, item, context):
-        self.log.debug("Remove %s", item.name)
-
-        context['action'] = u'Remove %s'%item
-
+        self._log_action("Remove", item)
+        context['action'] = self._action_msg("Remove", item)
         try:
             os.unlink(item.path)
             self.git_rm(item.path, context=context)
@@ -471,10 +474,8 @@ class Collection(object):
             raise
 
     def rewrite_file(self, item, context):
-        self.log.debug("Change %s", item.name)
-
-        context['action'] = u'Modify %s'%item
-
+        self._log_action("Change", item)
+        context['action'] = self._action_msg("Modify", item)
         try:
             new_path = self.write_file(item)
             os.rename(new_path, item.path)
diff --git a/requirements.txt b/requirements.txt
index 7512adf..613c087 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
 python-daemon==2.1.1
-git+https://github.com/eventable/vobject@0.8.2#egg=vobject
+vobject==0.9.4.1
diff --git a/tests/test_collection.py b/tests/test_collection.py
index 62a8d0a..54434dd 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -19,7 +19,7 @@ class TestCollection(CalypsoTestCase):
         collection = Collection("")
         self.assertTrue(collection.import_file(self.test_vcard))
         self.assertEqual(len(collection.items), 2)
-        org = u'Universitetet i Tromsø'
+        org = u'Universitetet i Tromsø'.encode('utf-8')
         self.assertEquals(org, collection.items[0].object.org.value[0])
 
     def test_remove_existent_item(self):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/calypso/calypso.git



More information about the Calypso-commits mailing list