home *** CD-ROM | disk | FTP | other *** search
/ Freelog 116 / FreelogNo116-JuilletSeptembre2013.iso / GestionFichiers / metamorphose / metamorphose2_0.8.2_setup.exe / metamorphose2.exe / copy_reg.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2011-01-12  |  4KB  |  168 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from types import ClassType as _ClassType
  5. __all__ = [
  6.     'pickle',
  7.     'constructor',
  8.     'add_extension',
  9.     'remove_extension',
  10.     'clear_extension_cache']
  11. dispatch_table = { }
  12.  
  13. def pickle(ob_type, pickle_function, constructor_ob = None):
  14.     if type(ob_type) is _ClassType:
  15.         raise TypeError('copy_reg is not intended for use with classes')
  16.     type(ob_type) is _ClassType
  17.     if not hasattr(pickle_function, '__call__'):
  18.         raise TypeError('reduction functions must be callable')
  19.     hasattr(pickle_function, '__call__')
  20.     dispatch_table[ob_type] = pickle_function
  21.     if constructor_ob is not None:
  22.         constructor(constructor_ob)
  23.     
  24.  
  25.  
  26. def constructor(object):
  27.     if not hasattr(object, '__call__'):
  28.         raise TypeError('constructors must be callable')
  29.     hasattr(object, '__call__')
  30.  
  31.  
  32. try:
  33.     complex
  34. except NameError:
  35.     pass
  36.  
  37.  
  38. def pickle_complex(c):
  39.     return (complex, (c.real, c.imag))
  40.  
  41. pickle(complex, pickle_complex, complex)
  42.  
  43. def _reconstructor(cls, base, state):
  44.     if base is object:
  45.         obj = object.__new__(cls)
  46.     else:
  47.         obj = base.__new__(cls, state)
  48.         if base.__init__ != object.__init__:
  49.             base.__init__(obj, state)
  50.         
  51.     return obj
  52.  
  53. _HEAPTYPE = 512
  54.  
  55. def _reduce_ex(self, proto):
  56.     for base in self.__class__.__mro__:
  57.         if hasattr(base, '__flags__') and not (base.__flags__ & _HEAPTYPE):
  58.             break
  59.             continue
  60.     else:
  61.         base = object
  62.     if base is object:
  63.         state = None
  64.     elif base is self.__class__:
  65.         raise TypeError, "can't pickle %s objects" % base.__name__
  66.     
  67.     state = base(self)
  68.     args = (self.__class__, base, state)
  69.     
  70.     try:
  71.         getstate = self.__getstate__
  72.     except AttributeError:
  73.         if getattr(self, '__slots__', None):
  74.             raise TypeError('a class that defines __slots__ without defining __getstate__ cannot be pickled')
  75.         getattr(self, '__slots__', None)
  76.         
  77.         try:
  78.             dict = self.__dict__
  79.         except AttributeError:
  80.             dict = None
  81.         except:
  82.             None<EXCEPTION MATCH>AttributeError
  83.         
  84.  
  85.         None<EXCEPTION MATCH>AttributeError
  86.  
  87.     dict = getstate()
  88.     if dict:
  89.         return (_reconstructor, args, dict)
  90.     return (_reconstructor, args)
  91.  
  92.  
  93. def __newobj__(cls, *args):
  94.     return cls.__new__(cls, *args)
  95.  
  96.  
  97. def _slotnames(cls):
  98.     names = cls.__dict__.get('__slotnames__')
  99.     if names is not None:
  100.         return names
  101.     names = []
  102.     if not hasattr(cls, '__slots__'):
  103.         pass
  104.     else:
  105.         for c in cls.__mro__:
  106.             if '__slots__' in c.__dict__:
  107.                 slots = c.__dict__['__slots__']
  108.                 if isinstance(slots, basestring):
  109.                     slots = (slots,)
  110.                 
  111.                 for name in slots:
  112.                     if name in ('__dict__', '__weakref__'):
  113.                         continue
  114.                         continue
  115.                     if name.startswith('__') and not name.endswith('__'):
  116.                         names.append('_%s%s' % (c.__name__, name))
  117.                         continue
  118.                     names.append(name)
  119.                 
  120.         
  121.     
  122.     try:
  123.         cls.__slotnames__ = names
  124.     except:
  125.         pass
  126.  
  127.     return names
  128.  
  129. _extension_registry = { }
  130. _inverted_registry = { }
  131. _extension_cache = { }
  132.  
  133. def add_extension(module, name, code):
  134.     code = int(code)
  135.     if code <= code:
  136.         pass
  137.     elif not code <= 2147483647:
  138.         raise ValueError, 'code out of range'
  139.     
  140.     key = (module, name)
  141.     if _extension_registry.get(key) == code and _inverted_registry.get(code) == key:
  142.         return None
  143.     if key in _extension_registry:
  144.         raise ValueError('key %s is already registered with code %s' % (key, _extension_registry[key]))
  145.     key in _extension_registry
  146.     if code in _inverted_registry:
  147.         raise ValueError('code %s is already in use for key %s' % (code, _inverted_registry[code]))
  148.     code in _inverted_registry
  149.     _extension_registry[key] = code
  150.     _inverted_registry[code] = key
  151.  
  152.  
  153. def remove_extension(module, name, code):
  154.     key = (module, name)
  155.     if _extension_registry.get(key) != code or _inverted_registry.get(code) != key:
  156.         raise ValueError('key %s is not registered with code %s' % (key, code))
  157.     _inverted_registry.get(code) != key
  158.     del _extension_registry[key]
  159.     del _inverted_registry[code]
  160.     if code in _extension_cache:
  161.         del _extension_cache[code]
  162.     
  163.  
  164.  
  165. def clear_extension_cache():
  166.     _extension_cache.clear()
  167.  
  168.