Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/abc.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s}dZddlZddlmZddd��YZee��Zd�Zdefd��YZ	d	efd
��YZ
dS(s3Abstract Base Classes (ABCs) according to PEP 3119.i�N(tWeakSett_CcBseZRS((t__name__t
__module__(((s/sys/lib/python2.7/abc.pyRscCs
t|_|S(s�A 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, ...):
                ...
    (tTruet__isabstractmethod__(tfuncobj((s/sys/lib/python2.7/abc.pytabstractmethods	tabstractpropertycBseZdZeZRS(s/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)
    (RRt__doc__RR(((s/sys/lib/python2.7/abc.pyR$stABCMetacBsDeZdZdZd�Zd�Zdd�Zd�Zd�Z	RS(siMetaclass 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()).

    icCs�tt|�j||||�}td�|j�D��}xb|D]Z}xQt|dt��D]:}t||d�}t|dt�r`|j|�q`q`WqDWt	|�|_
t�|_t�|_
t�|_tj|_|S(Ncss-|]#\}}t|dt�r|VqdS(RN(tgetattrtFalse(t.0tnametvalue((s/sys/lib/python2.7/abc.pys	<genexpr>Ys	t__abstractmethods__R(tsuperR
t__new__tsettitemsRtNoneRtaddt	frozensetRRt
_abc_registryt
_abc_cachet_abc_negative_cachet_abc_invalidation_countert_abc_negative_cache_version(tmclsRtbasest	namespacetclst	abstractstbaseR((s/sys/lib/python2.7/abc.pyRVs!	
cCs{t|ttjf�s'td��nt||�r:dSt||�rXtd��n|jj|�t	j
d7_
dS(s&Register a virtual subclass of an ABC.sCan only register classesNs'Refusing to create an inheritance cyclei(t
isinstancettypettypest	ClassTypet	TypeErrort
issubclasstRuntimeErrorRRR
R(R tsubclass((s/sys/lib/python2.7/abc.pytregisteriscCs�|d|j|jfIJ|dtjIJxRt|jj��D];}|jd�rAt||�}|d||fIJqAqAWdS(s'Debug helper to print the ABC registry.sClass: %s.%ssInv.counter: %st_abc_s%s: %rN(	RRR
Rtsortedt__dict__tkeyst
startswithR(R tfileRR((s/sys/lib/python2.7/abc.pyt_dump_registrywscCs�t|dd�}|dk	r1||jkr1tSt|�}|tkrR|}n||ksj|dkr�|jtjkr�||j	kr�t
S|j|�S|j|�p�|j|�S(s'Override for isinstance(instance, cls).t	__class__N(RRRRR$t
_InstanceTypeRR
RRRt__subclasscheck__(R tinstanceR*tsubtype((s/sys/lib/python2.7/abc.pyt__instancecheck__�s	
cCsa||jkrtS|jtjkr@t�|_tj|_n||jkrStS|j|�}|t	k	r�t
|t�s�t�|r�|jj
|�n|jj
|�|S|t|dd�kr�|jj
|�tSx4|jD])}t||�r�jj
|�tSq�x7|j�D])}t||�r |jj
|�tSq W|jj
|�tS(s'Override for issubclass(subclass, cls).t__mro__((RRRR
RRRRt__subclasshook__tNotImplementedR#tbooltAssertionErrorRRRR(t__subclasses__(R R*toktrclstscls((s/sys/lib/python2.7/abc.pyR5�s6N(
RRR	RRR+RR2R8R5(((s/sys/lib/python2.7/abc.pyR
As				((R	R%t_weakrefsetRRR$R4RtpropertyRR
(((s/sys/lib/python2.7/abc.pyt<module>s	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].