3 \"@svdZddlmZddZGdddeZGdddeZGd d d eZ Gd d d e Z Gd dde dZ ddZ dS)z3Abstract Base Classes (ABCs) according to PEP 3119.)WeakSetcCs d|_|S)aA decorator indicating abstract methods. Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal 'super' call mechanisms. Usage: class C(metaclass=ABCMeta): @abstractmethod def my_abstract_method(self, ...): ... T)__isabstractmethod__)funcobjr/usr/lib64/python3.6/abc.pyabstractmethod srcs$eZdZdZdZfddZZS)abstractclassmethodaO A decorator indicating abstract classmethods. Similar to abstractmethod. Usage: class C(metaclass=ABCMeta): @abstractclassmethod def my_abstract_classmethod(cls, ...): ... 'abstractclassmethod' is deprecated. Use 'classmethod' with 'abstractmethod' instead. Tcsd|_tj|dS)NT)rsuper__init__)selfcallable) __class__rrr 0szabstractclassmethod.__init__)__name__ __module__ __qualname____doc__rr __classcell__rr)r rrsrcs$eZdZdZdZfddZZS)abstractstaticmethodaO A decorator indicating abstract staticmethods. Similar to abstractmethod. Usage: class C(metaclass=ABCMeta): @abstractstaticmethod def my_abstract_staticmethod(...): ... 'abstractstaticmethod' is deprecated. Use 'staticmethod' with 'abstractmethod' instead. Tcsd|_tj|dS)NT)rr r )r r )r rrr Hszabstractstaticmethod.__init__)rrrrrr rrr)r rr5src@seZdZdZdZdS)abstractpropertyak A decorator indicating abstract properties. Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal 'super' call mechanisms. Usage: class C(metaclass=ABCMeta): @abstractproperty def my_abstract_property(self): ... This defines a read-only property; you can also define a read-write abstract property using the 'long' form of property declaration: class C(metaclass=ABCMeta): def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx) 'abstractproperty' is deprecated. Use 'property' with 'abstractmethod' instead. TN)rrrrrrrrrrMsrcsFeZdZdZdZfddZddZddd Zd d Zd d Z Z S)ABCMetaaiMetaclass for defining Abstract Base Classes (ABCs). Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as 'virtual subclasses' -- these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won't show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()). rc  stj||||f|}dd|jD}xF|D]>}x8t|dtD]&}t||d}t|ddrB|j|qBWq.Wt||_t|_ t|_ t|_ t j |_|S)NcSs h|]\}}t|ddr|qS)rF)getattr).0namevaluerrr sz"ABCMeta.__new__..__abstractmethods__rF)r __new__itemsrsetadd frozensetrr _abc_registry _abc_cache_abc_negative_cacher_abc_invalidation_counter_abc_negative_cache_version) mclsrbases namespacekwargscls abstractsbaser)r rrrs     zABCMeta.__new__cCsPt|tstdt||r |St||r2td|jj|tjd7_|S)zsRegister a virtual subclass of an ABC. Returns the subclass, to allow usage as a class decorator. zCan only register classesz'Refusing to create an inheritance cycle) isinstancetype TypeError issubclass RuntimeErrorr!rrr$)r*subclassrrrregisters    zABCMeta.registerNcCs|td|j|jf|dtdtj|dxLt|jD]>}|jdr6t||}t |t r`t |}td||f|dq6WdS)z'Debug helper to print the ABC registry.z Class: %s.%s)filezInv.counter: %s_abc_z%s: %rN) printrrrr$sorted__dict__ startswithrr.rr)r*r5rrrrr_dump_registrys   zABCMeta._dump_registrycsb|j}|jkrdSt|}||krHjtjkr>|jkr>dSj|Stfdd||hDS)z'Override for isinstance(instance, cls).TFc3s|]}j|VqdS)N)__subclasscheck__)rc)r*rr sz,ABCMeta.__instancecheck__..) r r"r/r%rr$r#r<any)r*instancer3subtyper)r*r__instancecheck__s   zABCMeta.__instancecheck__cCs||jkrdS|jtjkr,t|_tj|_n||jkr:dS|j|}|tk rn|r^|jj|n |jj||S|t |dfkr|jj|dSx(|j D]}t ||r|jj|dSqWx*|j D]}t ||r|jj|dSqW|jj|dS)z'Override for issubclass(subclass, cls).TF__mro__) r"r%rr$rr#__subclasshook__NotImplementedrrr!r1__subclasses__)r*r3okrclssclsrrrr<s4             zABCMeta.__subclasscheck__)N) rrrrr$rr4r;rBr<rrr)r rrms  rc@seZdZdZdS)ABCzVHelper class that provides a standard way to create an ABC using inheritance. N)rrrrrrrrrJsrJ) metaclasscCstjS)zReturns the current ABC cache token. The token is an opaque object (supporting equality testing) identifying the current version of the ABC cache for virtual subclasses. The token changes with every call to ``register()`` on any ABC. )rr$rrrrget_cache_tokensrLN)r _weakrefsetrr classmethodr staticmethodrpropertyrr/rrJrLrrrrs