Source code for slixmpp.plugins.xep_0060.stanza.pubsub_errors
# Slixmpp: The Slick XMPP Library# Copyright (C) 2011 Nathanael C. Fritz# This file is part of Slixmpp.# See the file LICENSE for copying permission.fromslixmpp.stanzaimportErrorfromslixmpp.xmlstreamimportElementBase,ET,register_stanza_plugin
[docs]defsetup(self,xml):"""Don't create XML for the plugin."""self.xml=ET.Element('')
[docs]defget_condition(self):"""Return the condition element's name."""forchildinself.parent().xml:if"{%s}"%self.condition_nsinchild.tag:cond=child.tag.split('}',1)[-1]ifcondinself.conditions:returncondreturn''
[docs]defset_condition(self,value):""" Set the tag name of the condition element. Arguments: value -- The tag name of the condition element. """ifvalueinself.conditions:delself['condition']cond=ET.Element("{%s}%s"%(self.condition_ns,value))self.parent().xml.append(cond)returnself
[docs]defdel_condition(self):"""Remove the condition element."""forchildinself.parent().xml:if"{%s}"%self.condition_nsinchild.tag:tag=child.tag.split('}',1)[-1]iftaginself.conditions:self.parent().xml.remove(child)returnself
[docs]defget_unsupported(self):"""Return the name of an unsupported feature"""xml=self.parent().xml.find('{%s}unsupported'%self.condition_ns)ifxmlisnotNone:returnxml.attrib.get('feature','')return''
[docs]defset_unsupported(self,value):"""Mark a feature as unsupported"""self.del_unsupported()xml=ET.Element('{%s}unsupported'%self.condition_ns)xml.attrib['feature']=valueself.parent().xml.append(xml)
[docs]defdel_unsupported(self):"""Delete an unsupported feature condition."""xml=self.parent().xml.find('{%s}unsupported'%self.condition_ns)ifxmlisnotNone:self.parent().xml.remove(xml)