U
    ©€ljZ›  ã                   @   s  d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlm	Z d	d
dgZdZdZdZdZeƒ Zeƒ Zdd„ Zdd„ ZG dd„ dƒZeZeG dd„ dƒƒZG dd„ dƒZeG dd„ deeƒƒZeg dƒZG dd
„ d
eƒZ G dd„ de!ƒZ"e"d	ee efdd iƒZ#d!d"„ Z$G d#d	„ d	e#ƒZ%e%d$d%d&�Z&d'd(„ e&_'e& (e&¡ e&j)e&fk�spt*‚e&e _+e&e	_+G d)d*„ d*e%ƒZ,G d+d,„ d,eƒZ-G d-d.„ d.e-ƒZ.d:d/d0„Z/d;d1d2„Z0d3d4„ Z1dd5l2m3Z3 dd6l2m4Z4 dd7lm5Z5 dd8lm6Z6 dd9l2m7Z7 e  (e7e7¡ dS )<z Interface object implementation
é    N)ÚFunctionType)Ú
MethodType©ÚUnion)Úro)Ú_use_c_impl)ÚInvalidÚInterfaceClassÚSpecificationÚadapter_hooksé   é   Z__interface_tagged_values__Z__interface_methods__c                 C   s2   t  d¡j}| ti ¡}| dg ¡}| | ¡ tS )Né   Ú
invariants)ÚsysÚ	_getframeÚf_localsÚ
setdefaultÚTAGGED_DATAÚappendÚ_decorator_non_return)Úcallr   Útagsr   © r   ú</tmp/pip-unpacked-wheel-8v5_7jmu/zope/interface/interface.pyÚ	invariant2   s
    
r   c                 C   s$   t  d¡j}| ti ¡}||| < tS )z;Attaches a tagged value to an interface at definition time.r   )r   r   r   r   r   r   )ÚkeyÚvaluer   Ztagged_valuesr   r   r   ÚtaggedValue:   s    r   c                   @   sX   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zddd„Zdd„ Z	dd„ Z
eZeZe	ZdS )ÚElementzI
    Default implementation of `zope.interface.interfaces.IElement`.
    Ú c                 C   s0   |s|  d¡dkr|}d }|| _|| _d | _d S )Nú r   )ÚfindÚ__name__Ú__doc__Ú_Element__tagged_values)Úselfr#   r$   r   r   r   Ú__init__L   s    zElement.__init__c                 C   s   | j S )z! Returns the name of the object. ©r#   ©r&   r   r   r   ÚgetNameY   s    zElement.getNamec                 C   s   | j S )z+ Returns the documentation for the object. )r$   r)   r   r   r   ÚgetDoc]   s    zElement.getDocc                 C   s   | j st|ƒ‚| j | S ©ú* Returns the value associated with 'tag'. )r%   ÚKeyError)r&   Útagr   r   r   ÚgetTaggedValueh   s    zElement.getTaggedValueNc                 C   s   | j r| j  ||¡S |S r,   )r%   Úget)r&   r/   Údefaultr   r   r   ÚqueryTaggedValuen   s    þ ÿþzElement.queryTaggedValuec                 C   s   | j r| j  ¡ S dS )z# Returns a collection of all tags. r   )r%   Úkeysr)   r   r   r   ÚgetTaggedValueTagst   s    zElement.getTaggedValueTagsc                 C   s   | j dkri | _ || j |< dS )z  Associates 'value' with 'key'. N)r%   ©r&   r/   r   r   r   r   ÚsetTaggedValuex   s    
zElement.setTaggedValue)r    )N)r#   Ú
__module__Ú__qualname__r$   r'   r*   r+   r0   r3   r5   r7   ÚqueryDirectTaggedValueZgetDirectTaggedValueÚgetDirectTaggedValueTagsr   r   r   r   r   B   s   
 ÿ

r   c                   @   s,   e Zd ZdZdd„ Zdd„ Zdd„ ZeZdS )	ÚSpecificationBase)Ú_impliedÚ_dependentsÚ_basesÚ_v_attrsÚ__iro__Ú__sro__Ú__weakref__c                 C   s   t |ƒ}| |jkS )z2Is the interface implemented by an object
        )Ú
providedByr=   )r&   ÚobÚspecr   r   r   rD   Ÿ   s    zSpecificationBase.providedByc                 C   s   t |ƒ}| |jkS )z•Test whether the specification is implemented by a class or factory.

        Raise TypeError if argument is neither a class nor a callable.
        )ÚimplementedByr=   )r&   ÚclsrF   r   r   r   rG   ¥   s    zSpecificationBase.implementedByc                 C   s
   || j kS )zCIs the interface the same as or extend the given interface
        ©r=   )r&   Ú	interfacer   r   r   ÚisOrExtends­   s    zSpecificationBase.isOrExtendsN)r#   r8   r9   Ú	__slots__rD   rG   rK   Ú__call__r   r   r   r   r<   †   s
   r<   c                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚNameAndModuleComparisonMixinr   c                 C   s^   || krdS |dkrdS | j | jf}z|j |jf}W n tk
rL   t Y S X ||k||k  S )a«  
        Compare *self* to *other* based on ``__name__`` and ``__module__``.

        Return 0 if they are equal, return 1 if *self* is
        greater than *other*, and return -1 if *self* is less than
        *other*.

        If *other* does not have ``__name__`` or ``__module__``, then
        return ``NotImplemented``.

        .. caution::
           This allows comparison to things well outside the type hierarchy,
           perhaps not symmetrically.

           For example, ``class Foo(object)`` and ``class Foo(Interface)``
           in the same file would compare equal, depending on the order of
           operands. Writing code like this by hand would be unusual, but it
           could happen with dynamic creation of types and interfaces.

        None is treated as a pseudo interface that implies the loosest
        contact possible, no contract. For that reason, all interfaces
        sort before None.
        r   Néÿÿÿÿ)r#   r8   ÚAttributeErrorÚNotImplemented)r&   ÚotherZn1Zn2r   r   r   Ú_compareÄ   s    
z%NameAndModuleComparisonMixin._comparec                 C   s   |   |¡}|tkr|S |dk S ©Nr   ©rS   rQ   ©r&   rR   Úcr   r   r   Ú__lt__ë   s    
z#NameAndModuleComparisonMixin.__lt__c                 C   s   |   |¡}|tkr|S |dkS rT   rU   rV   r   r   r   Ú__le__ñ   s    
z#NameAndModuleComparisonMixin.__le__c                 C   s   |   |¡}|tkr|S |dkS rT   rU   rV   r   r   r   Ú__gt__÷   s    
z#NameAndModuleComparisonMixin.__gt__c                 C   s   |   |¡}|tkr|S |dkS rT   rU   rV   r   r   r   Ú__ge__ý   s    
z#NameAndModuleComparisonMixin.__ge__N)	r#   r8   r9   rL   rS   rX   rY   rZ   r[   r   r   r   r   rN   µ   s   'rN   c                   @   s^   e Zd ZdZdZddd„Zdd„ Zedd	„ ƒZe	fd
d„Z
dd„ Zdd„ Zdd„ Zdd„ ZdS )ÚInterfaceBasez:Base class that wants to be replaced with a C base :)
    )r#   Ú__ibmodule__Ú_v_cached_hashNc                 C   s   || _ || _d S ©N©r#   r]   )r&   ÚnameÚmoduler   r   r   r'     s    zInterfaceBase.__init__c                 C   s   t ‚d S r_   )ÚNotImplementedError©r&   Úconformr   r   r   Ú_call_conform  s    zInterfaceBase._call_conformc                 C   s   | j S r_   )r]   r)   r   r   r   Ú__module_property__  s    z!InterfaceBase.__module_property__c                 C   st   z
|j }W n tk
r"   d}Y nX |dk	rB|  |¡}|dk	rB|S |  |¡}|dk	rX|S |tk	rd|S td|| ƒ‚dS )z)Adapt an object to the interface
        NzCould not adapt)Z__conform__rP   rf   Ú	__adapt__Ú_markerÚ	TypeError)r&   ÚobjZ	alternatere   Úadapterr   r   r   rM     s    



zInterfaceBase.__call__c                 C   s6   |   |¡r|S tD ]}|| |ƒ}|dk	r|  S qdS )z(Adapt an object to the receiver
        N)rD   r   )r&   rk   Úhookrl   r   r   r   rh   0  s    


zInterfaceBase.__adapt__c                 C   s6   z| j W S  tk
r.   t| j| jfƒ| _ Y nX | j S r_   )r^   rP   Úhashr#   r8   r)   r   r   r   Ú__hash__=  s
    zInterfaceBase.__hash__c                 C   s   |   |¡}|tkr|S |dkS rT   rU   rV   r   r   r   Ú__eq__E  s    
zInterfaceBase.__eq__c                 C   s*   || krdS |   |¡}|tkr"|S |dkS )NFr   rU   rV   r   r   r   Ú__ne__K  s    
zInterfaceBase.__ne__)NN)r#   r8   r9   r$   rL   r'   rf   Úpropertyrg   ri   rM   rh   ro   rp   rq   r   r   r   r   r\     s   

r\   c                   @   sš   e Zd ZdZdZdZejZejZddd„Z	e
dd„ ƒZdd	„ Zd
d„ Zdd„ Ze
dd„ eƒZeZdd„ Zdd„ Zdd„ Zddd„Zddd„Zd dd„ZdS )!r
   aw  Specifications

    An interface specification is used to track interface declarations
    and component registrations.

    This class is a base class for both interfaces themselves and for
    interface specifications (declarations).

    Specifications are mutable.  If you reassign their bases, their
    relations with other specifications are adjusted accordingly.
    r   Nc                 C   s2   d | _ d| _i | _d | _d| _d| _t|ƒ| _d S )Nr   )r>   r?   r=   r@   rA   rB   ÚtupleÚ	__bases__)r&   Úbasesr   r   r   r'   n  s    	zSpecification.__init__c                 C   s   | j d krt ¡ | _ | j S r_   )r>   ÚweakrefÚWeakKeyDictionaryr)   r   r   r   Ú
dependents€  s    

zSpecification.dependentsc                 C   s   | j  |d¡d | j|< d S )Nr   r   )rx   r1   r>   )r&   Ú	dependentr   r   r   Ú	subscribe†  s    zSpecification.subscribec                 C   s\   z| j | }W n tk
r*   t|ƒ‚Y nX |d8 }|sB| j|= n|dksNt‚|| j|< d S )Nr   r   )r>   rj   r.   rx   ÚAssertionError)r&   ry   Únr   r   r   Úunsubscribe‰  s    
zSpecification.unsubscribec                 C   s>   | j D ]}| | ¡ q|| _|D ]}| | ¡ q |  | ¡ d S r_   )rt   r}   r?   rz   Úchanged)r&   ru   Úbr   r   r   Z
__setBases•  s    
zSpecification.__setBasesc                 C   s   | j S r_   )r?   r)   r   r   r   Ú<lambda>¢  ó    zSpecification.<lambda>c                    sV   | j dd„ | jD ƒd�}| j‰ ˆ dk	rR|rR|d ˆ k	rR‡ fdd„|D ƒ}| ˆ ¡ |S )z¤Compute resolution order for this object using its ``__bases__``.

        Ensures that ``Interface`` is always the last (lowest priority)
        element.
        c                 S   s   i | ]}||j “qS r   )rB   )Ú.0r   r   r   r   Ú
<dictcomp>Î  s   ÿ z0Specification._calculate_sro.<locals>.<dictcomp>)Z	base_mrosNrO   c                    s   g | ]}|ˆ k	r|‘qS r   r   )r‚   Úx©Úrootr   r   Ú
<listcomp>Û  s   þz0Specification._calculate_sro.<locals>.<listcomp>)Ú_do_calculate_rort   Ú_ROOTr   )r&   Zsror   r…   r   Ú_calculate_sro¬  s    "
þ

þ
zSpecification._calculate_sroc                 C   s~   d| _ | j}| ¡  |  ¡ }t|ƒ| _tdd„ |D ƒƒ| _|D ]}d||< q>t| jr^| j ¡ ndƒD ]}| 	|¡ qdd| _ dS )z´
        We, or something we depend on, have changed.

        By the time this is called, the things we depend on,
        such as our bases, should themselves be stable.
        Nc                 S   s   g | ]}t |tƒr|‘qS r   ©Ú
isinstancer	   )r‚   Úancestorr   r   r   r‡   ò  s    
ÿz)Specification.changed.<locals>.<listcomp>r   )
r@   r=   ÚclearrŠ   rs   rB   rA   r>   r4   r~   )r&   Zoriginally_changedZimpliedZ	ancestorsr�   ry   r   r   r   r~   ä  s    

ÿzSpecification.changedc                 c   s8   i }| j D ](}| ¡ D ]}||krd||< |V  qq
dS )úDReturn an iterator for the interfaces in the specification.
        r   N)rt   Ú
interfaces)r&   ÚseenÚbaserJ   r   r   r   r�     s    
zSpecification.interfacesTc                 C   s   || j ko| p| |kS )z—Does the specification extend the given interface?

        Test whether an interface in the specification extends the
        given interface
        rI   )r&   rJ   Ústrictr   r   r   Úextends  s    
þzSpecification.extendsc                 C   s   t  | |¡S r_   )rv   Úref)r&   Úcallbackr   r   r   rv     s    zSpecification.weakrefc                 C   sd   | j }|dkri  }| _ | |¡}|dkrT| jD ]"}| |¡}|dk	r0|||<  qTq0|dkr`|S |S )z+Query for an attribute description
        N)r@   r1   rA   Údirect)r&   ra   r2   ÚattrsÚattrÚifacer   r   r   r1     s    



zSpecification.get)r   )T)N)N)r#   r8   r9   r$   rL   r‰   r<   rK   rD   r'   rr   rx   rz   r}   Z_Specification__setBasesrt   Úcalculate_rorˆ   rŠ   r~   r�   r”   rv   r1   r   r   r   r   r
   X  s,   

 ÿ	8"


c                   @   s,   e Zd ZdZdd„ Zedd„ ƒZdd„ ZdS )	Ú_InterfaceMetaClassr   c                 C   sP   t  d¡jd }tjd }t|tƒr.tjd }||d< t | |||¡}||_	|S )Nr   r#   r8   rg   )
r   r   Ú	f_globalsr\   Ú__dict__rŒ   ÚstrÚtypeÚ__new__Ú_InterfaceMetaClass__module)rH   ra   ru   r˜   r8   ZmoduledescrÚkindr   r   r   r¡   |  s    


z_InterfaceMetaClass.__new__c                 C   s   | j S r_   )r¢   ©rH   r   r   r   r8   Ž  s    z_InterfaceMetaClass.__module__c                 C   s   d  | j| j¡S )Nz<class '{}.{}'>)Úformatr¢   r#   r¤   r   r   r   Ú__repr__’  s    þz_InterfaceMetaClass.__repr__N)r#   r8   r9   rL   r¡   rr   r¦   r   r   r   r   rœ   0  s
   J
rœ   rL   r   c                 C   s&   t  d¡j}| ti ¡}| || j< tS )až  
    Convert a method specification to an actual method of the interface.

    This is a decorator that functions like `staticmethod` et al.

    The primary use of this decorator is to allow interface definitions to
    define the ``__adapt__`` method, but other interface methods can be
    overridden this way too.

    .. seealso::
        `zope.interface.interfaces.IInterfaceDeclaration.interfacemethod`
    r   )r   r   r   r   ÚINTERFACE_METHODSr#   r   )Úfuncr   Úmethodsr   r   r   Úinterfacemethod¡  s    
rª   c                   @   sÚ   e Zd ZdZd3dd„Zd4dd„Zdd	„ Zd
d„ Zdd„ Zdd„ Z	d5dd„Z
dd„ Zd6dd„Zdd„ ZeZdd„ Zdd„ Zd7dd„Zd8dd „Zd9d!d"„Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ ZdS ):r	   zÄ
    Prototype (scarecrow) Interfaces Implementation.

    Note that it is not possible to change the ``__name__`` or ``__module__``
    after an instance of this object has been constructed.
    Nr   c                 C   sž   t |tƒst‚|pi }| td ¡}|r”| d|kr@d| d¡ini ¡ d|krVd|d< t| tƒrh| f}n| tkrxtf}n| tf}t	| ƒ|d ||ƒ} t
 | ¡S )NÚ__classcell__rh   r   Z_CALL_CUSTOM_ADAPTz<WithCustomMethods>)rŒ   rs   r{   Úpopr§   ÚupdateÚ
issubclassÚ _InterfaceClassWithCustomMethodsr	   r    Ú_InterfaceClassBaser¡   )rH   ra   ru   r˜   r$   r8   Zneeds_custom_classZ	cls_basesr   r   r   r¡   Á  s,    ÿý
ýzInterfaceClass.__new__c           
   	   C   s.  t dd„ |D ƒƒstdƒ‚|d kr&i }|d krx| d¡}t|tƒrJ|d= n.zt d¡jd }W n tt	fk
rv   Y nX t
 | ||¡ | d¡}|d k	r´t|tƒs´|d kr®|}|d= |d krÀd}t | ||¡ | td ¡}|d k	�r| ¡ D ]\}}	|  ||	¡ qìt | |¡ |  |¡| _|› d	|› �| _d S )
Nc                 s   s   | ]}t |tƒV  qd S r_   r‹   )r‚   r’   r   r   r   Ú	<genexpr>ð  s     z*InterfaceClass.__init__.<locals>.<genexpr>zExpected base interfacesr8   r   r#   r$   r    Ú.)Úallrj   r1   rŒ   rŸ   r   r   r�   rP   r.   r\   r'   Ú	Attributer   r¬   r   Úitemsr7   r
   Ú_InterfaceClass__compute_attrsÚ_InterfaceClass__attrsZ__identifier__)
r&   ra   ru   r˜   r$   r8   ÚdZtagged_datar   Úvalr   r   r   r'   å  s:    




zInterfaceClass.__init__c                    s"   ‡ fdd„‰‡fdd„|  ¡ D ƒS )Nc                    sH   t |tƒrˆ |_|jsD| |_n&t |tƒr8t|ˆ | d�}ntd|  ƒ‚|S )N)ra   zConcrete attribute, )rŒ   r´   rJ   r#   r   ÚfromFunctionÚInvalidInterface)ÚanameÚavalr)   r   r   Úupdate_value!  s    

z4InterfaceClass.__compute_attrs.<locals>.update_valuec                    s,   i | ]$\}}|d kr|t k	r|ˆ ||ƒ“qS ))Z
__locals__r9   Ú__annotations__Z__static_attributes__Z__firstlineno__Z__classdictcell__)r   )r‚   r¼   r½   )r¾   r   r   rƒ   ,  s
   î z2InterfaceClass.__compute_attrs.<locals>.<dictcomp>)rµ   )r&   r˜   r   )r&   r¾   r   Z__compute_attrs  s    
þzInterfaceClass.__compute_attrsc                 c   s
   | V  dS )r�   Nr   r)   r   r   r   r�   B  s    zInterfaceClass.interfacesc                 C   s   | j S r_   )rt   r)   r   r   r   ÚgetBasesG  s    zInterfaceClass.getBasesc                 C   s   | |kp|  | ¡S )zSame interface or extends?)r”   ©r&   rR   r   r   r   ÚisEqualOrExtendedByJ  s    z"InterfaceClass.isEqualOrExtendedByFc                 C   sB   |s| j  ¡ S | j  ¡ }| jD ]}| t | |¡¡¡ q| ¡ S )z4Return the attribute names defined by the interface.)r·   r4   Úcopyrt   r­   ÚdictÚfromkeysÚnames©r&   r³   Úrr’   r   r   r   rÆ   N  s    


zInterfaceClass.namesc                 C   s   t | jdd�ƒS )NT)r³   )ÚiterrÆ   r)   r   r   r   Ú__iter__Z  s    zInterfaceClass.__iter__c                 C   sP   |s| j  ¡ S i }| jddd… D ]}| t| |¡ƒ¡ q"| | j ¡ | ¡ S )z=Return attribute names and descriptions defined by interface.NrO   )r·   rµ   rt   r­   rÄ   ÚnamesAndDescriptionsrÇ   r   r   r   rË   ]  s    
z#InterfaceClass.namesAndDescriptionsc                 C   s"   |   |¡}|dk	r|S t|ƒ‚dS )z4Return the attribute description for the given name.N)r1   r.   ©r&   ra   rÈ   r   r   r   ÚgetDescriptionForl  s    
z InterfaceClass.getDescriptionForc                 C   s   |   |¡d k	S r_   ©r1   ©r&   ra   r   r   r   Ú__contains__v  s    zInterfaceClass.__contains__c                 C   s   | j  |¡S r_   )r·   r1   rÏ   r   r   r   r—   y  s    zInterfaceClass.directc                 C   s   |   ||¡S r_   rÎ   )r&   ra   r2   r   r   r   ÚqueryDescriptionFor|  s    z"InterfaceClass.queryDescriptionForc                 C   st   | j D ]\}| dd¡D ]J}z||ƒ W q tk
r^ } z|dk	rL| |¡ n‚ W 5 d}~X Y qX qq|rpt|ƒ‚dS )z&validate object to defined invariants.r   r   N)rA   r:   r   r   )r&   rk   Úerrorsrš   r   Úerrorr   r   r   ÚvalidateInvariants  s    
z!InterfaceClass.validateInvariantsc                 C   s,   | j D ] }| |t¡}|tk	r|  S q|S )z¬
        Queries for the value associated with *tag*, returning it from the
        nearest interface in the ``__iro__``.

        If not found, returns *default*.
        )rA   r:   ri   )r&   r/   r2   rš   r   r   r   r   r3   �  s
    

zInterfaceClass.queryTaggedValuec                 C   s"   | j |td�}|tkrt|ƒ‚|S )r-   )r2   )r3   ri   r.   r6   r   r   r   r0   œ  s    zInterfaceClass.getTaggedValuec                 C   s$   t ƒ }| jD ]}| | ¡ ¡ q|S )z Returns a list of all tags. )ÚsetrA   r­   r;   )r&   r4   r’   r   r   r   r5   £  s    
z!InterfaceClass.getTaggedValueTagsc                 C   sJ   z| j W S  tk
rD   t| ƒ}d| jj› d|› d�}|| _ | Y S X d S )Nú<r!   ú>)Z_v_reprrP   rŸ   Ú	__class__r#   rÌ   r   r   r   r¦   ª  s    zInterfaceClass.__repr__c                 C   s"   | j }| j}|r|› d|› �}|S )Nr²   r`   )r&   ra   Úmr   r   r   Ú__str__³  s
    zInterfaceClass.__str__c                 C   s8   z
|| ƒW S  t k
r2   t ¡ d jd k	r.‚ Y nX d S )Né   )rj   r   Úexc_infoÚtb_nextrd   r   r   r   rf   º  s    
zInterfaceClass._call_conformc                 C   s   | j S r_   r(   r)   r   r   r   Ú
__reduce__Í  s    zInterfaceClass.__reduce__c                 C   s   t | |f S )z,Allow type hinting syntax: Interface | None.r   rÁ   r   r   r   Ú__or__Ð  s    zInterfaceClass.__or__c                 C   s   t || f S )z,Allow type hinting syntax: None | Interface.r   rÁ   r   r   r   Ú__ror__Ô  s    zInterfaceClass.__ror__)Nr   NNN)r   NNN)F)F)N)N)N)r#   r8   r9   r$   r¡   r'   r¶   r�   rÀ   rÂ   rÆ   rÊ   rË   rÍ   Ú__getitem__rÐ   r—   rÑ   rÔ   r3   r0   r5   r¦   rÚ   rf   rÞ   rß   rà   r   r   r   r   r	   ´  sF        ú
'    ú
9$
 ÿ



	Ú	Interfacezzope.interface)r8   c                   C   s   t fS r_   )râ   r   r   r   r   r€   Û  r�   r€   c                   @   s   e Zd ZdZdS )r¯   zc
    Marker class for interfaces with custom methods that override
    InterfaceClass methods.
    N)r#   r8   r9   r$   r   r   r   r   r¯   â  s   r¯   c                   @   s,   e Zd ZdZdZdd„ Zdd„ Zdd„ ZdS )	r´   zAttribute descriptions
    Nc                 C   s   dS )z/Return extra data to put at the end of __str__.r    r   r)   r   r   r   Ú_get_str_infoô  s    zAttribute._get_str_infoc                 C   s<   d}| j d k	r&| j jd | j j d }|| jp0d |  ¡  S )Nr    r²   z	<unknown>)rJ   r8   r#   rã   )r&   Zofr   r   r   rÚ   ø  s    
ÿþýÿzAttribute.__str__c                 C   s    d  t| ƒjt| ƒjt| ƒ| ¡S )Nz<{}.{} object at 0x{:x} {}>)r¥   r    r8   r#   Úidr)   r   r   r   r¦     s    üzAttribute.__repr__)r#   r8   r9   r$   rJ   rã   rÚ   r¦   r   r   r   r   r´   é  s
   r´   c                   @   sd   e Zd ZdZd ZZd Z ZZdd„ Z	dd„ Z
dd	„ Zee	e
eƒZd
d„ Zdd„ Zdd„ ZeZdS )ÚMethodzŽMethod interfaces

    The idea here is that you have objects that describe methods.
    This provides an opportunity for rich meta-data.
    r   Nc                 C   s   | j d kri S | j S r_   ©Ú	_optionalr)   r   r   r   Ú_get_optional  s    
zMethod._get_optionalc                 C   s
   || _ d S r_   ræ   )r&   Úoptr   r   r   Ú_set_optional!  s    zMethod._set_optionalc                 C   s
   d | _ d S r_   ræ   r)   r   r   r   Ú_del_optional$  s    zMethod._del_optionalc                 O   s   t | j| jƒ‚d S r_   )ÚBrokenImplementationrJ   r#   )r&   ÚargsÚkwr   r   r   rM   )  s    zMethod.__call__c                 C   s   | j | j| j| j| jdœS )N©Ú
positionalÚrequiredÚoptionalÚvarargsÚkwargsrï   r)   r   r   r   ÚgetSignatureInfo,  s    üzMethod.getSignatureInfoc                 C   s€   g }| j D ]:}| |¡ || j ¡ kr
|d  dt| j| ƒ 7  < q
| jr\| d| j ¡ | jrr| d| j ¡ dd |¡ S )NrO   ú=Ú*z**z(%s)z, )rð   r   rò   r4   Úreprró   rô   Újoin)r&   ÚsigÚvr   r   r   ÚgetSignatureString4  s    

 zMethod.getSignatureString)r#   r8   r9   r$   rð   rñ   rç   ró   rô   rè   rê   rë   rr   rò   rM   rõ   rü   rã   r   r   r   r   rå     s   rå   c                 C   s0  |p| j }t|| jƒ}t| dd ƒp$d}| j}|j| }|j|d … }i }	t|ƒ}
|
s`t| ddƒ}
||
 }|dk r‚|| d … }d}|	 t	t
||d … |ƒƒ¡ |d |… |_|d |… |_|	|_|}|jt@ râ|| |_|d }nd |_|jt@ rþ|| |_nd |_||_| j ¡ D ]\}}| ||¡ �q|S )NÚ__defaults__r   Z__defaults_count__r   r   )r#   rå   r$   ÚgetattrÚ__code__Úco_argcountÚco_varnamesÚlenr­   rÄ   Úziprð   rñ   rò   Úco_flagsÚ
CO_VARARGSró   ÚCO_VARKEYWORDSrô   rJ   rž   rµ   r7   )r¨   rJ   Úimlevelra   ÚmethodÚdefaultsÚcodeÚnarÆ   ré   Zdefaults_countÚnrZargnor   r   r   r   r   rº   D  s<    





rº   c                 C   s&   t | tƒr| j}n| }t||d|d�S )Nr   )r  ra   )rŒ   r   Ú__func__rº   )ÚmethrJ   ra   r¨   r   r   r   Ú
fromMethodx  s    
r  c                  C   s~   ddl m}  ddlm} | t|ƒ ddlm} | t|ƒ ddlm} | t|ƒ ddlm	} | t
|ƒ ddlm} | t|ƒ d S )Nr   )ÚclassImplements)ÚIElement)Ú
IAttribute)ÚIMethod)ÚISpecification)Ú
IInterface)Úzope.interface.declarationsr  Zzope.interface.interfacesr  r   r  r´   r  rå   r  r
   r  r	   )r  r  r  r  r  r  r   r   r   Ú_wire�  s    



r  )rG   )rD   )rì   )r»   )Ú_empty)Nr   N)NN)8r$   r   rv   Útypesr   r   Útypingr   Zzope.interfacer   Zzope.interface._compatr   Zzope.interface.exceptionsr   Zzope.interface.ror›   Ú__all__r  r  r   r§   Úobjectr   ri   r   r   r   ZSpecificationBasePyr<   rN   r\   r   r
   r    rœ   r°   rª   r	   râ   rŠ   r~   rB   r{   r‰   r¯   r´   rå   rº   r  r  r  rG   rD   rì   r»   r  r   r   r   r   Ú<module>   sv   ù
A.OP
 Yiü  '

$7
4
	