o
    gHd2  ã                   @   sF   d Z ddlmZ g d¢ZddlZdd„ Zdd„ Zdd	d
„Zdd„ ZdS )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           
      C   s¦   | j }| j}||u }d|v }d|v }|o|}|o|d |d k}|r*tj |d ¡p+d}|o2|j|u }|s8d}	n|r?|s?d}	n|rF|sFd}	n|sKd}	nd}	|	|||fS )	z„Return (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Úkind© r   ú\/var/www/html/facialservice/flask-venv/lib/python3.10/site-packages/zope/interface/advice.pyr   '   s&   r   c                 C   s   t | tƒo	t| dƒS )z(True if 'ob' is a class advisor functionÚpreviousMetaclass)Ú
isinstancer   Úhasattr)Úobr   r   r   r   K   s   r   c                 C   sZ   dd„ | D ƒ}|dur|  |¡ t|ƒdkr|d S t|ƒ}t|ƒdkr)td| ƒ‚|d S )zEDetermine metaclass from 1+ bases and optional explicit __metaclass__c                 S   s   g | ]
}t |d t|ƒƒ‘qS )Ú	__class__)ÚgetattrÚtype)Ú.0Úbr   r   r   Ú
<listcomp>S   s    z&determineMetaclass.<locals>.<listcomp>Né   r   zIncompatible metatypes)ÚappendÚlenr   Ú	TypeError)ÚbasesÚexplicit_mcÚmetaÚ
candidatesr   r   r   r   P   s   

r   c                 C   sN   g }| D ] }| D ]}t ||ƒr||ur nq||v r| |¡ | |¡ q|S )z?Reduce a list of base classes to its ordered minimum equivalent)Ú
issubclassÚremover'   )Úclassesr-   ÚmÚnr   r   r   r   h   s   €

€r   )N)	Ú__doc__Útypesr   Ú__all__r   r   r   r   r   r   r   r   r   Ú<module>   s   $
