Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/pylint/pyreverse/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/pylint/pyreverse/__pycache__/utils.cpython-37.pyc

B

A!p\^�@s�dZddlmZddlZddlZddlZdZdd�Zdd�Ze�	d	�Z
e�	d
�Ze�	d�Zdd
�Z
e�	d�Ze�	d�Zdd�Zdd�Zdd�Zdd�ZdZdZdZdZdeeeeeed�Zeeedd�ZGdd�d�ZGd d!�d!�ZGd"d#�d#e�ZdS)$z9
generic classes/functions for pyreverse core/extensions
�)�print_functionNz.pyreverserccCsRg}tj�dd�}|rNtj�|t�}yt|�����}Wnt	k
rLYnX|S)z5
    Read config file and return list of options
    �HOME�)
�os�environ�get�path�join�RCFILE�open�read�split�IOError)�options�homeZrcfile�r�G/opt/alt/python37/lib/python3.7/site-packages/pylint/pyreverse/utils.py�get_default_optionssrcCs.t�}|��x|D]}tj�d|�qWdS)z'insert default options to sys.argv
    �N)r�reverse�sys�argv�insert)r�argrrr�insert_default_options*s
rz^__[A-Za-z0-9]+[A-Za-z0-9_]*__$z^__[_A-Za-z0-9]*[A-Za-z0-9]+_?$z^_[_A-Za-z0-9]*$cCs8t�|�rd}n$t�|�r d}nt�|�r0d}nd}|S)zMreturn the visibility from a name: public, protected, private or special
    �special�private�	protected�public)�SPECIAL�match�PRIVATE�	PROTECTED)�name�
visibilityrrr�get_visibility:s


r%z
^.*Abstract.*z	^[A-Z_]*$cCst�|j�S)zWreturn true if the given class node correspond to an abstract class
    definition
    )�ABSTRACTr r#)�noderrr�is_abstractMsr(cCst�|j�S)zTreturn true if the given class/function node correspond to final
    definition
    )�FINALr r#)r'rrr�is_finalTsr*cCs
|jdkS)NZ	interface)�type)r'rrr�is_interface[sr,cCs
|jdkS)N�	exception)r+)r'rrr�is_exception`sr.r���)ZALLZPUB_ONLYrZOTHER)rrrrc@s eZdZdZdd�Zdd�ZdS)�FilterMixInz;filter nodes according to a mode and nodes' visibility
    cCshd}xX|�d�D]J}y|t|7}Wqtk
rX}ztd|tjd�Wdd}~XYqXqW||_dS)zinit filter modesr�+zUnknown filter mode %s)�fileN)r
�MODES�KeyError�printr�stderr�_FilterMixIn__mode)�self�moder9Znummod�exrrr�__init__}s(zFilterMixIn.__init__cCs tt|d|��}|jt|@S)z2return true if the node should be treated
        r#)r%�getattrr9�VIS_MOD)r:r'r$rrr�	show_attr�szFilterMixIn.show_attrN)�__name__�
__module__�__qualname__�__doc__r=r@rrrrr2ys
r2c@s:eZdZdZdd�Zd
dd�Zdd�Zd	d
�Zdd�ZdS)�	ASTWalkeraa walker visiting a tree in preorder, calling on the handler:

    * visit_<class name> on entering a node, where class name is the class of
    the node in lower case

    * leave_<class name> on leaving a node, where class name is the class of
    the node in lower case
    cCs||_i|_dS)N)�handler�_cache)r:rFrrrr=�szASTWalker.__init__NcCs�|dkrt�}||kr*tt|�||jf��|�|�|�|�x(|��D]}||k	sXt�|�||�qHW|�|�|j|k	s�t�dS)z<walk on the tree from <node>, getting callbacks from handlerN)	�set�AssertionError�id�parent�add�visitZget_children�walk�leave)r:r'Z_doneZ
child_noderrrrN�s


zASTWalker.walkcCsz|j}|j�|�}|dkrj|j}|j��}t|d|t|dd��}t|d|t|dd��}||f|j|<n|\}}||fS)z/get callbacks from handler for the visited nodeNzvisit_%sZ
visit_defaultzleave_%sZ
leave_default)�	__class__rGrrFrA�lowerr>)r:r'�klass�methodsrFZkidZe_methodZl_methodrrr�
get_callbacks�s
zASTWalker.get_callbackscCs"|�|�d}|dk	r||�dS)z<walk on the tree from <node>, getting callbacks from handlerrN)rT)r:r'�methodrrrrM�szASTWalker.visitcCs"|�|�d}|dk	r||�dS)z<walk on the tree from <node>, getting callbacks from handlerrN)rT)r:r'rUrrrrO�szASTWalker.leave)N)	rArBrCrDr=rNrTrMrOrrrrrE�s
rEc@s eZdZdZdd�Zdd�ZdS)�
LocalsVisitorz3visit a project by traversing the locals dictionarycCst�||�i|_dS)N)rEr=�_visited)r:rrrr=�szLocalsVisitor.__init__cCs|||jkrdSd|j|<|�|�}|ddk	r:|d|�t|d�r`x|��D]}|�|�qNW|ddk	rx|d|�SdS)z-launch the visit starting from the given nodeNrr�locals)rWrT�hasattr�valuesrM)r:r'rSZ
local_noderrrrM�s



zLocalsVisitor.visitN)rArBrCrDr=rMrrrrrV�srV)rD�
__future__rr�rerr
rr�compilerr!r"r%r&r)r(r*r,r.Z_CONSTRUCTORZ_SPECIALZ
_PROTECTEDZ_PRIVATEr5r?r2rErVrrrr�<module>s@





;