home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from __future__ import generators
- __all__ = [
- 'Protocol',
- 'InterfaceClass',
- 'Interface',
- 'AbstractBase',
- 'AbstractBaseMeta',
- 'IAdapterFactory',
- 'IProtocol',
- 'IAdaptingProtocol',
- 'IOpenProtocol',
- 'IOpenProvider',
- 'IOpenImplementor',
- 'IImplicationListener',
- 'Attribute',
- 'Variation']
- import api
- from advice import metamethod, classicMRO, mkRef
- from adapters import composeAdapters, updateWithSimplestAdapter
- from adapters import NO_ADAPTER_NEEDED, DOES_NOT_SUPPORT
- from types import InstanceType
-
- try:
- from thread import allocate_lock
- except ImportError:
-
- try:
- from dummy_thread import allocate_lock
- except ImportError:
-
- class allocate_lock(object):
- __slots__ = ()
-
- def acquire(*args):
- pass
-
-
- def release(*args):
- pass
-
-
- except:
- None<EXCEPTION MATCH>ImportError
-
-
- None<EXCEPTION MATCH>ImportError
-
-
- class Protocol:
-
- def __init__(self):
- self._Protocol__adapters = { }
- self._Protocol__implies = { }
- self._Protocol__listeners = None
- self._Protocol__lock = allocate_lock()
-
-
- def getImpliedProtocols(self):
- out = []
- add = out.append
- self._Protocol__lock.acquire()
-
- try:
- for k, v in self._Protocol__implies.items():
- proto = k()
- if proto is None:
- del self._Protocol__implies[k]
- continue
- add((proto, v))
-
- return out
- finally:
- self._Protocol__lock.release()
-
-
-
- def addImpliedProtocol(self, proto, adapter = NO_ADAPTER_NEEDED, depth = 1):
- self._Protocol__lock.acquire()
-
- try:
- key = mkRef(proto)
- if not updateWithSimplestAdapter(self._Protocol__implies, key, adapter, depth):
- return self._Protocol__implies[key][0]
- finally:
- self._Protocol__lock.release()
-
- for baseAdapter, d in self._Protocol__adapters.items():
- api.declareAdapterForType(proto, composeAdapters(baseAdapter, self, adapter), klass, depth + d)
-
- if self._Protocol__listeners:
- for listener in self._Protocol__listeners.keys():
- listener.newProtocolImplied(self, proto, adapter, depth)
-
-
- return adapter
-
- addImpliedProtocol = metamethod(addImpliedProtocol)
-
- def registerImplementation(self, klass, adapter = NO_ADAPTER_NEEDED, depth = 1):
- self._Protocol__lock.acquire()
-
- try:
- if not updateWithSimplestAdapter(self._Protocol__adapters, klass, adapter, depth):
- return self._Protocol__adapters[klass][0]
- finally:
- self._Protocol__lock.release()
-
- if adapter is DOES_NOT_SUPPORT:
- return adapter
-
- for extender, d in self.getImpliedProtocols():
- api.declareAdapterForType(proto, composeAdapters(adapter, self, extender), klass, depth + d)
-
- return adapter
-
- registerImplementation = metamethod(registerImplementation)
-
- def registerObject(self, ob, adapter = NO_ADAPTER_NEEDED, depth = 1):
- if api.adapt(ob, IOpenProvider).declareProvides(self, adapter, depth):
- if adapter is DOES_NOT_SUPPORT:
- return None
-
- for extender, d in self.getImpliedProtocols():
- api.declareAdapterForObject(proto, composeAdapters(adapter, self, extender), ob, depth + d)
-
-
-
- registerObject = metamethod(registerObject)
-
- def __adapt__(self, obj):
- get = self._Protocol__adapters.get
-
- try:
- typ = obj.__class__
- except AttributeError:
- typ = type(obj)
-
-
- try:
- mro = typ.__mro__
- except AttributeError:
- mro = classicMRO(typ, extendedClassic = True)
-
- for klass in mro:
- factory = get(klass)
- if factory is not None:
- return factory[0](obj)
- continue
-
-
-
- try:
- from _speedups import Protocol__adapt__ as __adapt__
- except ImportError:
- pass
-
- __adapt__ = metamethod(__adapt__)
-
- def addImplicationListener(self, listener):
- self._Protocol__lock.acquire()
-
- try:
- if self._Protocol__listeners is None:
- WeakKeyDictionary = WeakKeyDictionary
- import weakref
- self._Protocol__listeners = WeakKeyDictionary()
-
- self._Protocol__listeners[listener] = 1
- finally:
- self._Protocol__lock.release()
-
-
- addImplicationListener = metamethod(addImplicationListener)
-
- def __call__(self, ob, default = api._marker):
- return api.adapt(ob, self, default)
-
-
-
- try:
- from _speedups import Protocol__call__
- except ImportError:
- pass
-
- from new import instancemethod
- Protocol.__call__ = instancemethod(Protocol__call__, None, Protocol)
-
- class AbstractBaseMeta(Protocol, type):
-
- def __init__(self, __name__, __bases__, __dict__):
- type.__init__(self, __name__, __bases__, __dict__)
- Protocol.__init__(self)
- for b in __bases__:
- if isinstance(b, AbstractBaseMeta) and b.__bases__ != (object,):
- self.addImpliedProtocol(b)
- continue
-
-
-
- def __setattr__(self, attr, val):
- if attr == '__bases__':
- raise TypeError("Can't change interface __bases__", self)
-
- type.__setattr__(self, attr, val)
-
- __call__ = type.__call__
-
-
- class AbstractBase(object):
- __metaclass__ = AbstractBaseMeta
-
-
- class InterfaceClass(AbstractBaseMeta):
-
- def __call__(self, *_InterfaceClass__args, **_InterfaceClass__kw):
- if self.__init__ is Interface.__init__:
- return Protocol.__call__(self, *_InterfaceClass__args, **_InterfaceClass__kw)
- else:
- return type.__call__(self, *_InterfaceClass__args, **_InterfaceClass__kw)
-
-
- def getBases(self):
- return _[1]
-
-
-
- class Interface(object):
- __metaclass__ = InterfaceClass
-
-
- class Variation(Protocol):
-
- def __init__(self, baseProtocol, context = None):
- self.baseProtocol = baseProtocol
- self.context = context
- Protocol.__init__(self)
- api.declareAdapterForProtocol(self, NO_ADAPTER_NEEDED, baseProtocol)
-
-
- def __repr__(self):
- if self.context is None:
- return 'Variation(%r)' % self.baseProtocol
-
- return 'Variation(%r,%r)' % (self.baseProtocol, self.context)
-
-
-
- class Attribute(object):
-
- def __init__(self, doc, name = None, value = None):
- self.__doc__ = doc
- self.name = name
- self.value = value
-
-
- def __get__(self, ob, typ = None):
- if ob is None:
- return self
-
- if not self.name:
- raise NotImplementedError('Abstract attribute')
-
-
- try:
- return ob.__dict__[self.name]
- except KeyError:
- return self.value
-
-
-
- def __set__(self, ob, val):
- if not self.name:
- raise NotImplementedError('Abstract attribute')
-
- ob.__dict__[self.name] = val
-
-
- def __delete__(self, ob):
- if not self.name:
- raise NotImplementedError('Abstract attribute')
-
- del ob.__dict__[self.name]
-
-
- def __repr__(self):
- return 'Attribute: %s' % self.__doc__
-
-
-
- class IAdapterFactory(Interface):
-
- def __call__(ob):
- pass
-
-
-
- class IProtocol(Interface):
-
- def __hash__():
- pass
-
-
- def __eq__(other):
- pass
-
-
- def __ne__(other):
- pass
-
-
-
- class IAdaptingProtocol(IProtocol):
-
- def __adapt__(ob):
- pass
-
-
-
- class IConformingObject(Interface):
-
- def __conform__(protocol):
- pass
-
-
-
- class IOpenProvider(Interface):
-
- def declareProvides(protocol, adapter = NO_ADAPTER_NEEDED, depth = 1):
- pass
-
-
-
- class IOpenImplementor(Interface):
-
- def declareClassImplements(protocol, adapter = NO_ADAPTER_NEEDED, depth = 1):
- pass
-
-
-
- class IOpenProtocol(IAdaptingProtocol):
-
- def addImpliedProtocol(proto, adapter = NO_ADAPTER_NEEDED, depth = 1):
- pass
-
-
- def registerImplementation(klass, adapter = NO_ADAPTER_NEEDED, depth = 1):
- pass
-
-
- def registerObject(ob, adapter = NO_ADAPTER_NEEDED, depth = 1):
- pass
-
-
- def addImplicationListener(listener):
- pass
-
-
-
- class IImplicationListener(Interface):
-
- def newProtocolImplied(srcProto, destProto, adapter, depth):
- pass
-
-
-