comparison src/plugins/plugin_xep_0277.py @ 1919:d3354c80bd1f

core (tools): moved common to a separate package, and put data method in a data_format module
author Goffi <goffi@goffi.org>
date Tue, 22 Mar 2016 22:46:04 +0100
parents ee1125fffba8
children 2daf7b4c6756
comparison
equal deleted inserted replaced
1918:01d56efd488b 1919:d3354c80bd1f
26 from twisted.internet import defer 26 from twisted.internet import defer
27 from twisted.python import failure 27 from twisted.python import failure
28 from sat.core import exceptions 28 from sat.core import exceptions
29 from sat.tools import xml_tools 29 from sat.tools import xml_tools
30 from sat.tools import sat_defer 30 from sat.tools import sat_defer
31 from sat.tools import common 31 from sat.tools.common import data_format
32 32
33 # XXX: tmp.pubsub is actually use instead of wokkel version 33 # XXX: tmp.pubsub is actually use instead of wokkel version
34 from wokkel import pubsub 34 from wokkel import pubsub
35 try: 35 try:
36 from feed.date import rfc3339 36 from feed.date import rfc3339
324 else: 324 else:
325 microblog_data[u'author_email'] = unicode(email_elt) 325 microblog_data[u'author_email'] = unicode(email_elt)
326 326
327 # categories 327 # categories
328 categories = (category_elt.getAttribute('term','') for category_elt in entry_elt.elements(NS_ATOM, 'category')) 328 categories = (category_elt.getAttribute('term','') for category_elt in entry_elt.elements(NS_ATOM, 'category'))
329 common.iter2dict('tag', categories, microblog_data) 329 data_format.iter2dict('tag', categories, microblog_data)
330 330
331 ## the trigger ## 331 ## the trigger ##
332 # if other plugins have things to add or change 332 # if other plugins have things to add or change
333 yield self.host.trigger.point("XEP-0277_item2data", item_elt, entry_elt, microblog_data) 333 yield self.host.trigger.point("XEP-0277_item2data", item_elt, entry_elt, microblog_data)
334 334
424 content=rfc3339.timestamp_from_tf(float(data.get('updated', current_time)))) 424 content=rfc3339.timestamp_from_tf(float(data.get('updated', current_time))))
425 entry_elt.addElement('published', 425 entry_elt.addElement('published',
426 content=rfc3339.timestamp_from_tf(float(data.get('published', current_time)))) 426 content=rfc3339.timestamp_from_tf(float(data.get('published', current_time))))
427 427
428 ## categories ## 428 ## categories ##
429 for tag in common.dict2iter("tag", data): 429 for tag in data_format.dict2iter("tag", data):
430 category_elt = entry_elt.addElement("category") 430 category_elt = entry_elt.addElement("category")
431 category_elt['term'] = tag 431 category_elt['term'] = tag
432 432
433 ## id ## 433 ## id ##
434 entry_id = data.get('id', item_id) # FIXME: use a proper id (see XEP-0277 §7.1) 434 entry_id = data.get('id', item_id) # FIXME: use a proper id (see XEP-0277 §7.1)