home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / jabber / objects / vcard_avatar.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  2.2 KB  |  57 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import libxml2
  5. from pyxmpp.objects import StanzaPayloadObject
  6. from pyxmpp.xmlextra import common_doc, get_node_ns_uri
  7. from pyxmpp.utils import to_utf8, from_utf8
  8. VCARD_AVATAR_NS = 'vcard-temp:x:update'
  9.  
  10. class X_Update(StanzaPayloadObject):
  11.     xml_element_name = 'x'
  12.     xml_element_namespace = VCARD_AVATAR_NS
  13.     
  14.     def __str__(self):
  15.         n = self.as_xml(doc = common_doc)
  16.         r = n.serialize()
  17.         n.unlinkNode()
  18.         n.freeNode()
  19.         return r
  20.  
  21.  
  22.  
  23. class Photo(StanzaPayloadObject):
  24.     xml_element_name = 'photo'
  25.     xml_element_namespace = VCARD_AVATAR_NS
  26.     
  27.     def __init__(self, xmlnode_or_hash):
  28.         if isinstance(xmlnode_or_hash, libxml2.xmlNode):
  29.             self.from_xml(xmlnode_or_hash)
  30.         else:
  31.             self.hash = xmlnode_or_hash
  32.  
  33.     
  34.     def from_xml(self, node):
  35.         if node.type != 'element':
  36.             raise ValueError, 'XML node is not a photo (not en element)'
  37.         node.type != 'element'
  38.         ns = get_node_ns_uri(node)
  39.         if ns or ns != self.xml_element_namespace or node.name != self.xml_element_name:
  40.             raise ValueError, 'XML node is not a %s descriptor' % self.xml_element_name
  41.         node.name != self.xml_element_name
  42.         self.hash = from_utf8(node.getContent())
  43.  
  44.     
  45.     def complete_xml_element(self, xmlnode, _unused):
  46.         xmlnode.addContent(to_utf8(self.hash))
  47.  
  48.     
  49.     def __str__(self):
  50.         n = self.as_xml(doc = common_doc)
  51.         r = n.serialize()
  52.         n.unlinkNode()
  53.         n.freeNode()
  54.         return r
  55.  
  56.  
  57.