comparison src/plugins/plugin_xep_0071.py @ 993:301b342c697a

core: use of the new core.log module: /!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
author Goffi <goffi@goffi.org>
date Sat, 19 Apr 2014 19:19:19 +0200
parents c897c8d321b3
children 069ad98b360d
comparison
equal deleted inserted replaced
992:f51a1895275c 993:301b342c697a
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _ 20 from sat.core.i18n import _
21 from sat.core import exceptions 21 from sat.core import exceptions
22 from logging import debug, info, error 22 from sat.core.log import getLogger
23 23 log = getLogger(__name__)
24 from wokkel import disco, pubsub, iwokkel 24
25 from wokkel import disco, iwokkel
25 from zope.interface import implements 26 from zope.interface import implements
26 # from lxml import etree 27 # from lxml import etree
27 from lxml import html 28 from lxml import html
28 try: 29 try:
29 from twisted.words.protocols.xmlstream import XMPPHandler 30 from twisted.words.protocols.xmlstream import XMPPHandler
67 68
68 class XEP_0071(object): 69 class XEP_0071(object):
69 SYNTAX_XHTML_IM = "XHTML-IM" 70 SYNTAX_XHTML_IM = "XHTML-IM"
70 71
71 def __init__(self, host): 72 def __init__(self, host):
72 info(_("XHTML-IM plugin initialization")) 73 log.info(_("XHTML-IM plugin initialization"))
73 self.host = host 74 self.host = host
74 self.synt_plg = self.host.plugins["TEXT-SYNTAXES"] 75 self.synt_plg = self.host.plugins["TEXT-SYNTAXES"]
75 self.synt_plg.addSyntax(self.SYNTAX_XHTML_IM, lambda xhtml: xhtml, self.XHTML2XHTML_IM, [self.synt_plg.OPT_HIDDEN]) 76 self.synt_plg.addSyntax(self.SYNTAX_XHTML_IM, lambda xhtml: xhtml, self.XHTML2XHTML_IM, [self.synt_plg.OPT_HIDDEN])
76 host.trigger.add("MessageReceived", self.messageReceivedTrigger) 77 host.trigger.add("MessageReceived", self.messageReceivedTrigger)
77 host.trigger.add("sendMessage", self.sendMessageTrigger) 78 host.trigger.add("sendMessage", self.sendMessageTrigger)
187 attrib["style"] = self._purgeStyle(attrib["style"]) 188 attrib["style"] = self._purgeStyle(attrib["style"])
188 189
189 for elem in to_strip: 190 for elem in to_strip:
190 if elem.tag in blacklist: 191 if elem.tag in blacklist:
191 #we need to remove the element and all descendants 192 #we need to remove the element and all descendants
192 debug(u"removing black listed tag: %s" % (elem.tag)) 193 log.debug(u"removing black listed tag: %s" % (elem.tag))
193 elem.drop_tree() 194 elem.drop_tree()
194 else: 195 else:
195 elem.drop_tag() 196 elem.drop_tag()
196 if len(body_elt) !=1: 197 if len(body_elt) !=1:
197 root_elt = body_elt 198 root_elt = body_elt