home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 June / PCWorld_2005-06_cd.bin / software / vyzkuste / firewally / firewally.exe / framework-2.3.exe / minicompat.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2003-12-30  |  7KB  |  165 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.3)
  3.  
  4. '''Python version compatibility support for minidom.'''
  5. __all__ = [
  6.     'NodeList',
  7.     'EmptyNodeList',
  8.     'NewStyle',
  9.     'StringTypes',
  10.     'defproperty',
  11.     'GetattrMagic']
  12. import xml.dom as xml
  13.  
  14. try:
  15.     unicode
  16. except NameError:
  17.     StringTypes = (type(''),)
  18.  
  19. StringTypes = (type(''), type(unicode('')))
  20.  
  21. try:
  22.     True
  23. except NameError:
  24.     True = 1
  25.     False = 0
  26.     __all__.extend([
  27.         'True',
  28.         'False'])
  29.  
  30.  
  31. try:
  32.     isinstance('', StringTypes)
  33. except TypeError:
  34.     _isinstance = isinstance
  35.     
  36.     def isinstance(obj, type_or_seq):
  37.         
  38.         try:
  39.             return _isinstance(obj, type_or_seq)
  40.         except TypeError:
  41.             for t in type_or_seq:
  42.                 if _isinstance(obj, t):
  43.                     return 1
  44.                     continue
  45.             
  46.             return 0
  47.  
  48.  
  49.     __all__.append('isinstance')
  50.  
  51. if list is type([]):
  52.     
  53.     class NodeList(list):
  54.         __slots__ = ()
  55.         
  56.         def item(self, index):
  57.             if index <= index:
  58.                 pass
  59.             elif index < len(self):
  60.                 return self[index]
  61.             
  62.  
  63.         
  64.         def _get_length(self):
  65.             return len(self)
  66.  
  67.         
  68.         def _set_length(self, value):
  69.             raise xml.dom.NoModificationAllowedErr("attempt to modify read-only attribute 'length'")
  70.  
  71.         length = property(_get_length, _set_length, doc = 'The number of nodes in the NodeList.')
  72.         
  73.         def __getstate__(self):
  74.             return list(self)
  75.  
  76.         
  77.         def __setstate__(self, state):
  78.             self[:] = state
  79.  
  80.  
  81.     
  82.     class EmptyNodeList(tuple):
  83.         __slots__ = ()
  84.         
  85.         def __add__(self, other):
  86.             NL = NodeList()
  87.             NL.extend(other)
  88.             return NL
  89.  
  90.         
  91.         def __radd__(self, other):
  92.             NL = NodeList()
  93.             NL.extend(other)
  94.             return NL
  95.  
  96.         
  97.         def item(self, index):
  98.             return None
  99.  
  100.         
  101.         def _get_length(self):
  102.             return 0
  103.  
  104.         
  105.         def _set_length(self, value):
  106.             raise xml.dom.NoModificationAllowedErr("attempt to modify read-only attribute 'length'")
  107.  
  108.         length = property(_get_length, _set_length, doc = 'The number of nodes in the NodeList.')
  109.  
  110. else:
  111.     
  112.     def NodeList():
  113.         return []
  114.  
  115.     
  116.     def EmptyNodeList():
  117.         return []
  118.  
  119.  
  120. try:
  121.     property
  122. except NameError:
  123.     
  124.     def defproperty(klass, name, doc):
  125.         pass
  126.  
  127.     
  128.     class GetattrMagic:
  129.         
  130.         def __getattr__(self, key):
  131.             if key.startswith('_'):
  132.                 raise AttributeError, key
  133.             
  134.             
  135.             try:
  136.                 get = getattr(self, '_get_' + key)
  137.             except AttributeError:
  138.                 raise AttributeError, key
  139.  
  140.             return get()
  141.  
  142.  
  143.     
  144.     class NewStyle:
  145.         pass
  146.  
  147.  
  148.  
  149. def defproperty(klass, name, doc):
  150.     get = getattr(klass, '_get_' + name).im_func
  151.     
  152.     def set(self, value, name = name):
  153.         raise xml.dom.NoModificationAllowedErr('attempt to modify read-only attribute ' + repr(name))
  154.  
  155.     if not not hasattr(klass, '_set_' + name):
  156.         raise AssertionError, 'expected not to find _set_' + name
  157.     prop = property(get, set, doc = doc)
  158.     setattr(klass, name, prop)
  159.  
  160.  
  161. class GetattrMagic:
  162.     pass
  163.  
  164. NewStyle = object
  165.