/usr/lib/python3/dist-packages/twisted/python/__pycache__
NameSizeModeActions
compat.cpython-310.pyc153980644editdlrm
components.cpython-310.pyc143640644editdlrm
constants.cpython-310.pyc4680644editdlrm
context.cpython-310.pyc46570644editdlrm
deprecate.cpython-310.pyc252210644editdlrm
failure.cpython-310.pyc189600644editdlrm
fakepwd.cpython-310.pyc72920644editdlrm
filepath.cpython-310.pyc520500644editdlrm
formmethod.cpython-310.pyc127170644editdlrm
htmlizer.cpython-310.pyc35820644editdlrm
lockfile.cpython-310.pyc51380644editdlrm
log.cpython-310.pyc230160644editdlrm
logfile.cpython-310.pyc104590644editdlrm
modules.cpython-310.pyc254690644editdlrm
monkey.cpython-310.pyc23150644editdlrm
procutils.cpython-310.pyc13890644editdlrm
randbytes.cpython-310.pyc37350644editdlrm
rebuild.cpython-310.pyc55780644editdlrm
reflect.cpython-310.pyc191270644editdlrm
release.cpython-310.pyc15250644editdlrm
roots.cpython-310.pyc89330644editdlrm
runtime.cpython-310.pyc56170644editdlrm
sendmsg.cpython-310.pyc25800644editdlrm
shortcut.cpython-310.pyc24640644editdlrm
syslog.cpython-310.pyc33680644editdlrm
systemd.cpython-310.pyc30510644editdlrm
text.cpython-310.pyc42690644editdlrm
threadable.cpython-310.pyc35200644editdlrm
threadpool.cpython-310.pyc105020644editdlrm
url.cpython-310.pyc2790644editdlrm
urlpath.cpython-310.pyc92820644editdlrm
usage.cpython-310.pyc286350644editdlrm
util.cpython-310.pyc279390644editdlrm
versions.cpython-310.pyc3560644editdlrm
win32.cpython-310.pyc48410644editdlrm
zippath.cpython-310.pyc91460644editdlrm
zipstream.cpython-310.pyc88260644editdlrm
_appdirs.cpython-310.pyc8620644editdlrm
_inotify.cpython-310.pyc25800644editdlrm
_pydoctor.cpython-310.pyc57500644editdlrm
_release.cpython-310.pyc181330644editdlrm
_shellcomp.cpython-310.pyc188550644editdlrm
_textattributes.cpython-310.pyc106420644editdlrm
_tzhelper.cpython-310.pyc33850644editdlrm
_url.cpython-310.pyc2690644editdlrm
__init__.cpython-310.pyc5460644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/python/__pycache__/components.cpython-310.pyc (14364B)
o bw7@sdZddlmZddlmZddlmZmZddlm Z ddl m Z e Z da ddZd d Zd d Zd dZee ddZeZGdddZGdddZGdddeZd ddZGdddZGdddZgdZdS)!a Component architecture for Twisted, based on Zope3 components. Using the Zope3 API directly is strongly recommended. Everything you need is in the top-level of the zope.interface package, e.g.:: from zope.interface import Interface, implementer class IFoo(Interface): pass @implementer(IFoo) class Foo: pass print(IFoo.implementedBy(Foo)) # True print(IFoo.providedBy(Foo())) # True L{twisted.python.components.registerAdapter} from this module may be used to add to Twisted's global adapter registry. L{twisted.python.components.proxyForInterface} is a factory for classes which allow access to only the parts of another class defined by a specified interface. )StringIO)Dict) declarations interface)AdapterRegistry)reflectcGszt}|sJdt|tjst|}|D]}||g|}|dur,ts,td|dq|D] }| |g|d|q/dS)a Register an adapter class. An adapter class is expected to implement the given interface, by adapting instances implementing 'origInterface'. An adapter class's __init__ method should accept one parameter, an instance implementing 'origInterface'. zYou need to pass an InterfaceNz an adapter (z) was already registered.) globalRegistry isinstancerInterfaceClassr implementedBy registeredALLOW_DUPLICATES ValueErrorregister)adapterFactory origInterfaceinterfaceClassesselfinterfaceClassfactoryr;/usr/lib/python3/dist-packages/twisted/python/components.pyregisterAdapter2s    rcCs6t}t|tjs t|}|||}|dur|}|S)zReturn registered adapter for a given class and interface. Note that is tied to the *Twisted* global registry, and will thus not find adapters registered elsewhere. N)r r rr rr lookup1) fromInterface toInterfacedefaultrrrrrgetAdapterFactoryJs   rcs"|jfdd}tj||S)z Add an adapter hook which will attempt to look up adapters in the given registry. @type registry: L{zope.interface.adapter.AdapterRegistry} @return: The hook which was added, for later use with L{_removeHook}. cs$t||}|durdS||SN)r providedBy)ifaceobrlookuprr_hookdsz_addHook.._hook)rr adapter_hooksappend)registryr%rr#r_addHookYs  r)cCstj|dS)z Remove a previously added adapter hook. @param hook: An object previously returned by a call to L{_addHook}. This will be removed from the list of adapter hooks. N)rr&remove)hookrrr _removeHookosr,cCstS)zWReturns the Twisted global C{zope.interface.adapter.AdapterRegistry} instance. )r rrrr getRegistry}sr-c@s0eZdZdZdZdZddZddZdd Zd S) Adaptera/I am the default implementation of an Adapter for some interface. This docstring contains a limerick, by popular demand:: Subclassing made Zope and TR much harder to work with by far. So before you inherit, be sure to declare it Adapter, not PyObject* @cvar temporaryAdapter: If this is True, the adapter will not be persisted on the Componentized. @cvar multiComponent: If this adapter is persistent, should it be automatically registered for all appropriate interfaces. rcCs ||_dS)z;Set my 'original' attribute to be the object I am adapting.Noriginalrr1rrr__init__s zAdapter.__init__cCst|jdr |j|SdS)zn I forward __conform__ to self.original if it has it, otherwise I simply return None. __conform__N)hasattrr1r4rrrrrr4s  zAdapter.__conform__cCs|j||S)z1 Forward isuper to self.original )r1isuper)rr!adapterrrrr7szAdapter.isuperN) __name__ __module__ __qualname____doc__temporaryAdaptermultiComponentr3r4r7rrrrr.s r.c@sjeZdZdZdZddZddZddZdd d Zd d Z dddZ ddZ ddZ dddZ ddZdS) ComponentizedaI am a mixin to allow you to be adapted in various ways persistently. I define a list of persistent adapters. This is to allow adapter classes to store system-specific state, and initialized on demand. The getComponent method implements this. You must also register adapters for this class for the interfaces that you wish to pass to getComponent. Many other classes and utilities listed here are present in Zope3; this one is specific to Twisted. r/cCs i|_dSr) _adapterCacherrrrr3 zComponentized.__init__cCs t|||Sr)r)rklassrrrrrlocateAdapterClasss z Componentized.locateAdapterClasscCs||||dS)zv Cache a provider for the given interface, by adapting C{self} using the given adapter class. N) setComponent)rr adapterClassrrr setAdapterszComponentized.setAdapterrcCs||}||||S)zUtility method that calls addComponent. I take an adapter class and instantiate it with myself as the first argument. @return: The adapter instantiated. ) addComponent)rrF ignoreClassadaptrrr addAdapters zComponentized.addAdaptercCs||jt|<dS)z: Cache a provider of the given interface. Nr@rqual)rr componentrrrrEszComponentized.setComponentcCs>t|D]}|s||j|d|jkr||jt|<qdS)a Add a component to me, for all appropriate interfaces. In order to determine which interfaces are appropriate, the component's provided interfaces will be scanned. If the argument 'ignoreClass' is True, then all interfaces are considered appropriate. Otherwise, an 'appropriate' interface is one for which its class has been registered as an adapter for my class according to the rules of getComponent. N)rr rD __class__r@rrM)rrNrIr!rrrrHszComponentized.addComponentcCs|jt|=dS)z;Remove my component specified by the given interface class.NrL)rrrrrunsetComponentszComponentized.unsetComponentcCs@g}t|jD]\}}||ur|j|=|t|q |S)z Remove the given component from me entirely, for all interfaces for which it has been registered. @return: a list of the interfaces that were removed. )listr@itemsr'r namedObject)rrNlkvrrrremoveComponentszComponentized.removeComponentNcCstt|}||jvr|j|S||}|dur2t|dr |js2||j|<t|dr2|jr2|||dur8|S|S)aCreate or retrieve an adapter for the given interface. If such an adapter has already been created, retrieve it from the cache that this instance keeps of all its adapters. Adapters created through this mechanism may safely store system-specific state. If you want to register an adapter that will be created through getComponent, but you don't require (or don't want) your adapter to be cached and kept alive for the lifetime of this Componentized object, set the attribute 'temporaryAdapter' to True on your adapter class. If you want to automatically register an adapter for all appropriate interfaces (with addComponent), set the attribute 'multiComponent' to True on your adapter class. Nr=r>)rrMr@ __adapt__r5r=r>rH)rrrrUr8rrr getComponents      zComponentized.getComponentcCs ||Sr)rYr6rrrr4#rBzComponentized.__conform__)rr)r9r:r;r<persistenceVersionr3rDrGrKrErHrPrWrYr4rrrrr?s     r?c@s"eZdZddZdefddZdS)ReprableComponentizedcCst|dSr)r?r3rArrrr3(szReprableComponentized.__init__returncCs&ddlm}t}||j||S)Nr)pprint)r]rr@getvalue)rr]siorrr__repr__+s  zReprableComponentized.__repr__N)r9r:r;r3strr`rrrrr['sr[r1csXfdd}d|i}|D] }t|||<q tdt|dtf|}t|||S)a Create a class which proxies all method calls which adhere to an interface to another provider of that interface. This function is intended for creating specialized proxies. The typical way to use it is by subclassing the result:: class MySpecializedProxy(proxyForInterface(IFoo)): def someInterfaceMethod(self, arg): if arg == 3: return 3 return self.original.someInterfaceMethod(arg) @param iface: The Interface to which the resulting object will conform, and which the wrapped object must provide. @param originalAttribute: name of the attribute used to save the original object in the resulting class. Default to C{original}. @type originalAttribute: C{str} @return: A class whose constructor takes the original object as its only argument. Constructing the class creates the proxy. cst||dSr)setattrr2originalAttributerrr3Lsz#proxyForInterface..__init__r3z (Proxy for ))_ProxyDescriptortyperrMobjectrclassImplements)r!rdr3contentsnameproxyrrcrproxyForInterface3s  rmc@s eZdZdZddZddZdS)_ProxiedClassMethoda A proxied class method. @ivar methodName: the name of the method which this should invoke when called. @type methodName: L{str} @ivar __name__: The name of the method being proxied (the same as C{methodName}). @type __name__: L{str} @ivar originalAttribute: name of the attribute of the proxy where the original object is stored. @type originalAttribute: L{str} cCs||_|_||_dSr) methodNamer9rd)rrordrrrr3js  z_ProxiedClassMethod.__init__cOs&t||j}t||j}||i|S)z Invoke the specified L{methodName} method of the C{original} attribute for proxyForInterface. @param oself: an instance of a L{proxyForInterface} object. @return: the result of the underlying method. )getattrrdro)roselfargskwr1 actualMethodrrr__call__ns z_ProxiedClassMethod.__call__N)r9r:r;r<r3rurrrrrnYs rnc@s2eZdZdZddZd ddZddZd d ZdS) rfa A descriptor which will proxy attribute access, mutation, and deletion to the L{_ProxyDescriptor.originalAttribute} of the object it is being accessed from. @ivar attributeName: the name of the attribute which this descriptor will retrieve from instances' C{original} attribute. @type attributeName: C{str} @ivar originalAttribute: name of the attribute of the proxy where the original object is stored. @type originalAttribute: C{str} cCs||_||_dSr) attributeNamerd)rrvrdrrrr3s z_ProxyDescriptor.__init__NcCs.|dur t|j|jSt||j}t||jS)zL Retrieve the C{self.attributeName} property from I{oself}. N)rnrvrdrp)rrqrgr1rrr__get__s  z_ProxyDescriptor.__get__cCst||j}t||j|dS)zE Set the C{self.attributeName} property of I{oself}. N)rprdrbrv)rrqvaluer1rrr__set__s z_ProxyDescriptor.__set__cCst||j}t||jdS)zH Delete the C{self.attributeName} property of I{oself}. N)rprddelattrrv)rrqr1rrr __delete__s z_ProxyDescriptor.__delete__r)r9r:r;r<r3rwryr{rrrrrf|s   rf)rrr.r?r[r-rmNr0)r<iortypingrzope.interfacerrzope.interface.adapterrtwisted.pythonrr rrrr)r,r- TypeError CannotAdaptr.r?r[rmrnrf__all__rrrrs,     *u &# +