
    e2                     >    d Z ddlmZ g dZddlZd Zd Zd	dZd Zy)
aj  Class advice.

This module was adapted from 'protocols.advice', part of the Python
Enterprise Application Kit (PEAK).  Please notify the PEAK authors
(pje@telecommunity.com and tsarna@sarna.org) if bugs are found or
Zope-specific changes are required, so that the PEAK version of this module
can be kept in sync.

PEAK is a Python application framework that interoperates with (but does
not require) Zope 3 and Twisted.  It provides tools for manipulating UML
models, object-relational persistence, aspect-oriented programming, and more.
Visit the PEAK home page at http://peak.telecommunity.com for more information.
    )FunctionType)determineMetaclassgetFrameInfoisClassAdvisorminimalBasesNc                 ,   | j                   }| j                  }||u }d|v }d|v }|xr |}|xr |d   |d   k(  }|xr" t        j                  j	                  |d         xs d}|xr |j
                  |u }|sd}	n|r|sd}	n|r|sd}	n|sd}	nd}	|	|||fS )	zReturn (kind,module,locals,globals) for a frame

    'kind' is one of "exec", "module", "class", "function call", or "unknown".
    
__module____name__Nexecmoduleclasszfunction callunknown)f_locals	f_globalssysmodulesget__dict__)
framer   r   sameNamespace	hasModulehasNamesameNamer   namespaceIsModulekinds
             7/usr/lib/python3/dist-packages/zope/interface/advice.pyr   r   '   s     ~~HI	)M(II%G$WHIIj18L3IIH?:)>?G4F?6??i#?	y	- 9,,    c                 >    t        | t              xr t        | d      S )z(True if 'ob' is a class advisor functionpreviousMetaclass)
isinstancer   hasattr)obs    r   r   r   K   s    b&J726I+JJr   c           
          | D cg c]  }t        |dt        |             }}||j                  |       t        |      dk(  r|d   S t	        |      }t        |      dkD  rt        d|       |d   S c c}w )zEDetermine metaclass from 1+ bases and optional explicit __metaclass__	__class__   r   zIncompatible metatypes)getattrtypeappendlenr   	TypeError)basesexplicit_mcbmeta
candidatess        r   r   r   P   s     5::qGAk$q'*:D: 	K 
4y!|Awd#J
:q0%88 a=% ;s   A4c                     g }| D ]B  }| D ]  }t        ||      s||us  ||v r|j                  |       |j                  |       D |S )z?Reduce a list of base classes to its ordered minimum equivalent)
issubclassremover(   )classesr/   mns       r   r   r   h   sd    J ! 	!A!A1A:	!
 J!!!$a ! r   )N)	__doc__typesr   __all__r   r   r   r   r    r   r   <module>r:      s1     !-HK
0r   