ok

Mini Shell

Direktori : /usr/lib64/python3.6/site-packages/zope/interface/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/zope/interface/__pycache__/advice.cpython-36.pyc

3

��[>�@svdZddlmZyddlmZWnek
r8dZYnXdZddlZdd�Zdd
d�Zdd
�Z	ddd�Z
dd�ZdS)ajClass 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)�	ClassTypeTFNc
Cs�|j}|j}||k}d|k}d|k}|o*|}|o>|d|dk}|rTtjj|d�pVd}|od|j|k}|spd}	n.|r�|r�d}	n|r�|r�d}	n|s�d}	nd}	|	|||fS)	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
rZ
sameNamespaceZ	hasModuleZhasNameZsameNamerZnamespaceIsModule�kind�r�/usr/lib64/python3.6/advice.py�getFrameInfo&s&

r�csvtrtd��tj|�}t|�\}}}}|jd��trB|jdt��n|jdt�����fdd�}�|_�|_	||d<dS)a2Set up 'callback' to be passed the containing class upon creation

    This function is designed to be called by an "advising" function executed
    in a class suite.  The "advising" function supplies a callback that it
    wishes to have executed when the containing class is created.  The
    callback will be given one argument: the newly created containing class.
    The return value of the callback will be used in place of the class, so
    the callback should return the input if it does not wish to replace the
    class.

    The optional 'depth' argument to this function determines the number of
    frames between this function and the targeted class suite.  'depth'
    defaults to 2, since this skips this function's frame and one calling
    function frame.  If you use this function from a function called directly
    in the class suite, the default will be correct, otherwise you will need
    to determine the correct depth yourself.

    This function works by installing a special class factory function in
    place of the '__metaclass__' of the containing class.  Therefore, only
    callbacks *after* the last '__metaclass__' assignment in the containing
    class will be executed.  Be sure that classes using "advising" functions
    declare any '__metaclass__' *first*, to ensure all callbacks are run.z"Class advice impossible in Python3�
__metaclass__csVd|kr|d=�dkr*|r$t|�}qB�}nt��r8�}n
t|��}||||�}�|�S)Nr)�determineMetaclass�isClassAdvisor)�name�basesZcdict�metaZnewClass)�callback�defaultMetaclass�previousMetaclassrr�advisexs

zaddClassAdvisor.<locals>.adviseN)
�	__python3�	TypeErrorr�	_getframerr�typerrr)r�depthrrrZ
caller_localsZcaller_globalsrr)rrrr�addClassAdvisorJs


r%cCst|t�ot|d�S)z(True if 'ob' is a class advisor functionr)�
isinstancer�hasattr)�obrrrr�srcCsldd�|D�}|dk	r |j|�t|�dkr4|dSt|�}|sNtsJt�tSt|�dkrdtd|��|dS)zEDetermine metaclass from 1+ bases and optional explicit __metaclass__cSsg|]}t|dt|���qS)�	__class__)�getattrr#)�.0�brrr�
<listcomp>�sz&determineMetaclass.<locals>.<listcomp>N�rzIncompatible metatypes)�append�len�minimalBasesr �AssertionErrorrr!)rZexplicit_mcr�
candidatesrrrr�s


rcCsftsdd�|D�}g}xJ|D]B}x<|D]}t||�r&||k	r&Pq&W||krT|j|�|j|�qW|S)z?Reduce a list of base classes to its ordered minimum equivalentcSsg|]}|tk	r|�qSr)r)r+�crrrr-�sz minimalBases.<locals>.<listcomp>)r �
issubclass�remover/)�classesr3�m�nrrrr1�s


r1)r)N)�__doc__�typesrr�ImportErrorr rrr%rrr1rrrr�<module>s
$
P


Zerion Mini Shell 1.0