comparison src/plugins/plugin_xep_0277.py @ 2264:a8eaaac4d80f

plugin XEP-0277, tools/common/data_objects: language handling
author Goffi <goffi@goffi.org>
date Thu, 22 Jun 2017 09:13:28 +0200
parents 5e12fc5ae52a
children b5befe7722d3
comparison
equal deleted inserted replaced
2263:90189f312fd3 2264:a8eaaac4d80f
187 try: 187 try:
188 entry_elt = item_elt.elements(NS_ATOM, 'entry').next() 188 entry_elt = item_elt.elements(NS_ATOM, 'entry').next()
189 except StopIteration: 189 except StopIteration:
190 msg = u'No atom entry found in the pubsub item {}'.format(id_) 190 msg = u'No atom entry found in the pubsub item {}'.format(id_)
191 raise failure.Failure(exceptions.DataError(msg)) 191 raise failure.Failure(exceptions.DataError(msg))
192
193 # language
194 try:
195 microblog_data[u'language'] = entry_elt[(C.NS_XML, u'lang')]
196 except KeyError:
197 pass
192 198
193 # atom:id 199 # atom:id
194 try: 200 try:
195 id_elt = entry_elt.elements(NS_ATOM, 'id').next() 201 id_elt = entry_elt.elements(NS_ATOM, 'id').next()
196 except StopIteration: 202 except StopIteration:
342 """ 348 """
343 if item_id is None: 349 if item_id is None:
344 item_id = unicode(uuid.uuid4()) 350 item_id = unicode(uuid.uuid4())
345 client = self.host.getClient(profile) 351 client = self.host.getClient(profile)
346 entry_elt = domish.Element((NS_ATOM, 'entry')) 352 entry_elt = domish.Element((NS_ATOM, 'entry'))
353
354 ## language ##
355 if u'language' in data:
356 entry_elt[(C.NS_XML, u'lang')] = data[u'language']
347 357
348 ## content and title ## 358 ## content and title ##
349 synt = self.host.plugins["TEXT-SYNTAXES"] 359 synt = self.host.plugins["TEXT-SYNTAXES"]
350 360
351 for elem_name in ('title', 'content'): 361 for elem_name in ('title', 'content'):