diff src/plugins/plugin_xep_0277.py @ 1822:aaf034bc6f7a

plugin XEP-0277: moved NS_XHTML namespace to constants + adapted parsing to new behaviour of ElementParser
author Goffi <goffi@goffi.org>
date Fri, 22 Jan 2016 20:24:17 +0100
parents d6062afdd54f
children 1424cc6f8e98
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0277.py	Fri Jan 22 20:24:17 2016 +0100
+++ b/src/plugins/plugin_xep_0277.py	Fri Jan 22 20:24:17 2016 +0100
@@ -43,7 +43,6 @@
 
 NS_MICROBLOG = 'urn:xmpp:microblog:0'
 NS_ATOM = 'http://www.w3.org/2005/Atom'
-NS_XHTML = 'http://www.w3.org/1999/xhtml'
 NS_PUBSUB_EVENT = "{}{}".format(pubsub.NS_PUBSUB, "#event")
 NS_COMMENT_PREFIX = '{}:comments/'.format(NS_MICROBLOG)
 
@@ -173,7 +172,7 @@
                 data_elt = elem.firstChildElement()
                 if data_elt is None:
                     raise failure.Failure(exceptions.DataError(u"XHML content not wrapped in a <div/> element, this is not standard !"))
-                if data_elt.uri != NS_XHTML:
+                if data_elt.uri != C.NS_XHTML:
                     raise failure.Failure(exceptions.DataError(_('Content of type XHTML must declare its namespace!')))
                 key = check_conflict(u'{}_xhtml'.format(elem.name))
                 data = data_elt.toXml()
@@ -367,10 +366,10 @@
                         else:
                             xml_content = data[attr]
 
-                        div_elt = xml_tools.ElementParser()(xml_content, namespace=NS_XHTML)
-                        if div_elt.name != 'div' or div_elt.uri != NS_XHTML or div_elt.attributes:
+                        div_elt = xml_tools.ElementParser()(xml_content, namespace=C.NS_XHTML)
+                        if div_elt.name != 'div' or div_elt.uri != C.NS_XHTML or div_elt.attributes:
                             # we need a wrapping <div/> at the top with XHTML namespace
-                            wrap_div_elt = domish.Element((NS_XHTML, 'div'))
+                            wrap_div_elt = domish.Element((C.NS_XHTML, 'div'))
                             wrap_div_elt.addChild(div_elt)
                             div_elt = wrap_div_elt
                         elem.addChild(div_elt)