changeset 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 90189f312fd3
children 322694543225
files src/plugins/plugin_xep_0277.py src/tools/common/data_objects.py
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0277.py	Wed Jun 21 19:47:38 2017 +0200
+++ b/src/plugins/plugin_xep_0277.py	Thu Jun 22 09:13:28 2017 +0200
@@ -190,6 +190,12 @@
             msg = u'No atom entry found in the pubsub item {}'.format(id_)
             raise failure.Failure(exceptions.DataError(msg))
 
+        # language
+        try:
+            microblog_data[u'language'] = entry_elt[(C.NS_XML, u'lang')]
+        except KeyError:
+            pass
+
         # atom:id
         try:
             id_elt = entry_elt.elements(NS_ATOM, 'id').next()
@@ -345,6 +351,10 @@
         client = self.host.getClient(profile)
         entry_elt = domish.Element((NS_ATOM, 'entry'))
 
+        ## language ##
+        if u'language' in data:
+            entry_elt[(C.NS_XML, u'lang')] = data[u'language']
+
         ## content and title ##
         synt = self.host.plugins["TEXT-SYNTAXES"]
 
--- a/src/tools/common/data_objects.py	Wed Jun 21 19:47:38 2017 +0200
+++ b/src/tools/common/data_objects.py	Thu Jun 22 09:13:28 2017 +0200
@@ -52,6 +52,10 @@
         return self.mb_data.get(u'updated')
 
     @property
+    def language(self):
+        return self.mb_data.get(u'language')
+
+    @property
     def author(self):
         return self.mb_data.get(u'author')