o
    diN                     @   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 )	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kind r   T/var/www/html/pca-backend/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   N   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>V   s    z&determineMetaclass.<locals>.<listcomp>N   r   zIncompatible metatypes)appendlenr   	TypeError)basesexplicit_mcmeta
candidatesr   r   r   r   S   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   k   s   

r   )N)	__doc__typesr   __all__r   r   r   r   r   r   r   r   r   <module>   s   %
