Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/logilab/common/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/logilab/common/__pycache__/visitor.cpython-37.pyc

B

�d{Tt
�@sDdZdZdd�ZGdd�de�ZGdd�de�ZGdd	�d	e�Zd
S)z/A generic visitor abstract implementation.




zrestructuredtext encCsdS)N��)�_rr�G/opt/alt/python37/lib/python3.7/site-packages/logilab/common/visitor.py�	no_filtersrc@s"eZdZddd�Zdd�ZeZdS)�FilteredIteratorNcCs(|dfg|_|dkrt}|||�|_dS)N�)Z_nextr�_list)�self�nodeZ	list_func�filter_funcrrr�__init__ szFilteredIterator.__init__cCsy|j�d�SdSdS)Nr)r�pop)r	rrr�__next__&szFilteredIterator.__next__)N)�__name__�
__module__�__qualname__rr�nextrrrrrs
rc@s>eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)�VisitorNcCs||_||_dS)N)�_iter_class�filter)r	Ziterator_classrrrrr1szVisitor.__init__cOs"|j|f|�|�|�|�|��S)z�
        launch the visit on a given node

        call 'open_visit' before the beginning of the visit, with extra args
        given
        when all nodes have been visited, call the 'close_visit' method
        )�
open_visit�close_visit�_visit)r	r
�args�kargsrrr�visit5sz
Visitor.visitcCs2|�|�}t|�}x|r,|�|�}t|�}qW|S)N)�
_get_iteratorr�accept)r	r
�iterator�n�resultrrrr@s

zVisitor._visitcCs|�||j�S)N)rr)r	r
rrrrHszVisitor._get_iteratorcOsdS)z=
        method called at the beginning of the visit
        Nr)r	rrrrrrKszVisitor.open_visitcCs|S)z7
        method called at the end of the visit
        r)r	r rrrrQszVisitor.close_visit)N)	rrrrrrrrrrrrrr/s
rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�VisitedMixInz?
    Visited interface allow node visitors to use the node
    cCs&y|j�dd�S|jj��SdS)z�
        return the visit name for the mixed class. When calling 'accept', the
        method <'visit_' + name returned by this method> will be called on the
        visitor
        �-rN)ZTYPE�replace�	__class__r�lower)r	rrr�get_visit_name\szVisitedMixIn.get_visit_namecOs"t|d|���}||f|�|�S)Nzvisit_%s)�getattrr&)r	�visitorr�kwargs�funcrrrrgszVisitedMixIn.acceptcOs"t|d|���}||f|�|�S)Nzleave_%s)r'r&)r	r(rr)r*rrr�leavekszVisitedMixIn.leaveN)rrr�__doc__r&rr+rrrrr!Xsr!N)r,�
__docformat__r�objectrrr!rrrr�<module>s
)