home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / plugins / stats_counters / stanzas / counter.pyo (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  2.9 KB  |  63 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from  import DIGSBY_STATS_COUNTER_NS
  5. from action import Action
  6. from jabber.jabber_util.functions import xpath_eval
  7. from pyxmpp.iq import Iq
  8. from pyxmpp.objects import StanzaPayloadObject
  9. from pyxmpp.xmlextra import common_doc, get_node_ns_uri
  10. import libxml2
  11.  
  12. class CounterQuery(StanzaPayloadObject, list):
  13.     xml_element_name = 'query'
  14.     xml_element_namespace = DIGSBY_STATS_COUNTER_NS
  15.     
  16.     def __init__(self, xmlelem_or_accounts = [], order = sentinel):
  17.         if isinstance(xmlelem_or_accounts, libxml2.xmlNode):
  18.             self._CounterQuery__from_xml(xmlelem_or_accounts)
  19.         else:
  20.             self.extend(xmlelem_or_accounts)
  21.  
  22.     
  23.     def __from_xml(self, node):
  24.         if node.type != 'element':
  25.             raise ValueError, 'XML node is not a Stats Counter element (not en element)'
  26.         node.type != 'element'
  27.         ns = get_node_ns_uri(node)
  28.         if ns or ns != DIGSBY_STATS_COUNTER_NS or node.name != 'query':
  29.             raise ValueError, 'XML node is not a Stats Counter element'
  30.         node.name != 'query'
  31.         actions = xpath_eval(node, 'sc:action', {
  32.             'sc': DIGSBY_STATS_COUNTER_NS })
  33.         self.extend((lambda .0: for action in .0:
  34. Action(action))(actions))
  35.  
  36.     
  37.     def complete_xml_element(self, xmlnode, doc):
  38.         [ item.as_xml(xmlnode, doc) for item in self ]
  39.  
  40.     
  41.     def make_push(self, digsby_protocol):
  42.         iq = Iq(stanza_type = 'set')
  43.         iq.set_to(digsby_protocol.jid.domain)
  44.         self.as_xml(parent = iq.get_node())
  45.         return iq
  46.  
  47.     
  48.     def make_get(self, digsby_protocol):
  49.         iq = Iq(stanza_type = 'get')
  50.         iq.set_to(digsby_protocol.jid.domain)
  51.         self.as_xml(parent = iq.get_node())
  52.         return iq
  53.  
  54.     
  55.     def __str__(self):
  56.         n = self.as_xml(doc = common_doc)
  57.         r = n.serialize()
  58.         n.unlinkNode()
  59.         n.freeNode()
  60.         return r
  61.  
  62.  
  63.