diff src/plugins/plugin_xep_0277.py @ 1935:1128feb54180

core: removed pyfeed and xe dependencies: pyfeed and xe where still used only for date format handling, and there is already dateutil which is a dependency of Wokkel. Furthermore pyfeed and xe are still not on pypi, causing troubles for installation with pip
author Goffi <goffi@goffi.org>
date Sun, 17 Apr 2016 17:08:12 +0200
parents 2daf7b4c6756
children 627cc6120c0e
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0277.py	Sun Apr 17 14:45:26 2016 +0200
+++ b/src/plugins/plugin_xep_0277.py	Sun Apr 17 17:08:12 2016 +0200
@@ -28,16 +28,15 @@
 from sat.core import exceptions
 from sat.tools import xml_tools
 from sat.tools import sat_defer
+from sat.tools import utils
 from sat.tools.common import data_format
 
 # XXX: tmp.pubsub is actually use instead of wokkel version
 from wokkel import pubsub
-try:
-    from feed.date import rfc3339
-except ImportError:
-    raise exceptions.MissingModule(u"Missing module pyfeed, please download/install it from http://home.avvanta.com/~steveha/pyfeed.html")
 import uuid
 import time
+import dateutil
+import calendar
 import urlparse
 
 NS_MICROBLOG = 'urn:xmpp:microblog:0'
@@ -252,13 +251,13 @@
         except StopIteration:
             msg = u'No atom updated element found in the pubsub item {}'.format(id_)
             raise failure.Failure(exceptions.DataError(msg))
-        microblog_data[u'updated'] = unicode(rfc3339.tf_from_timestamp(unicode(updated_elt)))
+        microblog_data[u'updated'] = unicode(calendar.timegm(dateutil.parser.parse(unicode(updated_elt)).utctimetuple()))
         try:
             published_elt = entry_elt.elements(NS_ATOM, 'published').next()
         except StopIteration:
             microblog_data[u'published'] = microblog_data[u'updated']
         else:
-            microblog_data[u'published'] = unicode(rfc3339.tf_from_timestamp(unicode(published_elt)))
+            microblog_data[u'published'] = unicode(calendar.timegm(dateutil.parser.parse(unicode(published_elt)).utctimetuple()))
 
         # links
         for link_elt in entry_elt.elements(NS_ATOM, 'link'):
@@ -421,9 +420,9 @@
         ## published/updated time ##
         current_time = time.time()
         entry_elt.addElement('updated',
-            content=rfc3339.timestamp_from_tf(float(data.get('updated', current_time))))
+            content = utils.xmpp_date(float(data.get('updated', current_time))))
         entry_elt.addElement('published',
-            content=rfc3339.timestamp_from_tf(float(data.get('published', current_time))))
+            content = utils.xmpp_date(float(data.get('published', current_time))))
 
         ## categories ##
         for tag in data_format.dict2iter("tag", data):