home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2857 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  3.0 KB  |  84 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __all__ = [
  5.     'NodeList',
  6.     'EmptyNodeList',
  7.     'StringTypes',
  8.     'defproperty']
  9. import xml.dom as xml
  10.  
  11. try:
  12.     unicode
  13. except NameError:
  14.     StringTypes = (type(''),)
  15.  
  16. StringTypes = (type(''), type(unicode('')))
  17.  
  18. class NodeList(list):
  19.     __slots__ = ()
  20.     
  21.     def item(self, index):
  22.         if index <= index:
  23.             pass
  24.         elif index < len(self):
  25.             return self[index]
  26.  
  27.     
  28.     def _get_length(self):
  29.         return len(self)
  30.  
  31.     
  32.     def _set_length(self, value):
  33.         raise xml.dom.NoModificationAllowedErr("attempt to modify read-only attribute 'length'")
  34.  
  35.     length = property(_get_length, _set_length, doc = 'The number of nodes in the NodeList.')
  36.     
  37.     def __getstate__(self):
  38.         return list(self)
  39.  
  40.     
  41.     def __setstate__(self, state):
  42.         self[:] = state
  43.  
  44.  
  45.  
  46. class EmptyNodeList(tuple):
  47.     __slots__ = ()
  48.     
  49.     def __add__(self, other):
  50.         NL = NodeList()
  51.         NL.extend(other)
  52.         return NL
  53.  
  54.     
  55.     def __radd__(self, other):
  56.         NL = NodeList()
  57.         NL.extend(other)
  58.         return NL
  59.  
  60.     
  61.     def item(self, index):
  62.         pass
  63.  
  64.     
  65.     def _get_length(self):
  66.         return 0
  67.  
  68.     
  69.     def _set_length(self, value):
  70.         raise xml.dom.NoModificationAllowedErr("attempt to modify read-only attribute 'length'")
  71.  
  72.     length = property(_get_length, _set_length, doc = 'The number of nodes in the NodeList.')
  73.  
  74.  
  75. def defproperty(klass, name, doc):
  76.     get = getattr(klass, '_get_' + name).im_func
  77.     
  78.     def set(self, value, name = name):
  79.         raise xml.dom.NoModificationAllowedErr('attempt to modify read-only attribute ' + repr(name))
  80.  
  81.     prop = property(get, set, doc = doc)
  82.     setattr(klass, name, prop)
  83.  
  84.