Ë
    \;j„  ã                   óV   — d Z ddlmZ  G d„ de«      Z edefi «      Z G d„ de«      Zy)a
  
Part of the astor library for Python AST manipulation.

License: 3-clause BSD

Copyright 2012 (c) Patrick Maupin
Copyright 2013 (c) Berker Peksag

This file contains a TreeWalk class that views a node tree
as a unified whole and allows several modes of traversal.

é   )Ú	iter_nodec                   ó   — e Zd ZdZd„ Zy)ÚMetaFlattenz«This metaclass is used to flatten classes to remove
    class hierarchy.

    This makes it easier to manipulate classes (find
    attributes in a single dict, etc.)

    c                 ó  — t         f}i }t        |«      D ]!  }||vsŒ|j                  t        |«      «       Œ# |j                  |«       |j	                  dd «       |j	                  dd «       t
        j                  | |||«      S )NÚ__dict__Ú__weakref__)ÚobjectÚreversedÚupdateÚvarsÚpopÚtypeÚ__new__)ÚclstypeÚnameÚbasesÚclsdictÚnewbasesÚnewdictÚbases          úXG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\astor/tree_walk.pyr   zMetaFlatten.__new__   ss   € Ü�9ˆØˆÜ˜U–OˆDØ˜8Ò#Ø—‘œt D›zÕ*ð $ð 	�‰�wÔà�‰�J Ô%Ø�‰�M 4Ô(ä�|‰|˜G T¨8°WÓ=Ð=ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r   r      s   „ ñó>r   r   c                   óT   — e Zd ZdZd
d„Zd„ Zdeeefd„Z	e
d„ «       Ze
d„ «       Zd	„ Zy)ÚTreeWalkaé  The TreeWalk class can be used as a superclass in order
    to walk an AST or similar tree.

    Unlike other treewalkers, this class can walk a tree either
    recursively or non-recursively.  Subclasses can define
    methods with the following signatures::

        def pre_xxx(self):
            pass

        def post_xxx(self):
            pass

        def init_xxx(self):
            pass

    Where 'xxx' is one of:

      - A class name
      - An attribute member name concatenated with '_name'
        For example, 'pre_targets_name' will process nodes
        that are referenced by the name 'targets' in their
        parent's node.
      - An attribute member name concatenated with '_item'
        For example, 'pre_targets_item'  will process nodes
        that are in a list that is the targets attribute
        of some node.

    pre_xxx will process a node before processing any of its subnodes.
    if the return value from pre_xxx evalates to true, then walk
    will not process any of the subnodes.  Those can be manually
    processed, if desired, by calling self.walk(node) on the subnodes
    before returning True.

    post_xxx will process a node after processing all its subnodes.

    init_xxx methods can decorate the class instance with subclass-specific
    information.  A single init_whatever method could be written, but to
    make it easy to keep initialization with use, any number of init_xxx
    methods can be written.  They will be called in alphabetical order.

    Nc                 óZ   — g | _         | j                  «        |�| j                  |«       y y ©N)Ú	nodestackÚsetupÚwalk)ÚselfÚnodes     r   Ú__init__zTreeWalk.__init__W   s(   € ØˆŒØ�
‰
ŒØÐØ�I‰I�d�Oð r   c                 óB  — i x| _         }i x| _        }t        t        t	        | «      «      «      D ]m  }|j                  d«      r t        | |«      «        Œ&|j                  d«      rt        | |«      ||dd <   ŒJ|j                  d«      sŒ\t        | |«      ||dd <   Œo y)zYAll the node-specific handlers are setup at
        object initialization time.

        Úinit_Úpre_é   NÚpost_é   )Úpre_handlersÚpost_handlersÚsortedr   r   Ú
startswithÚgetattr)r%   r.   r/   r   s       r   r#   zTreeWalk.setup]   s—   € ð
 ,.Ð-ˆÔ˜LØ-/Ð/ˆÔ˜]Üœ4¤ T£
Ó+Ö,ˆDØ�‰˜wÔ'Ø#”˜˜dÓ#Õ%Ø—‘ Ô(Ü)0°°tÓ)<�˜T ! "˜XÒ&Ø—‘ Õ)Ü*1°$¸Ó*=�˜d 1 2˜hÒ'ñ -r   Ú c                 ó,  — | j                   j                  }| j                  j                  }| j                  } ||«      }	|j                  |j
                  }}
 |
|| |t        ||dz   «      «      dg«        ||«      |	kD  �r|d   \  }}}}| ||«      k\  rs | ||«      j                  «      xs  ||dz   «      }|€ |«        ŒP|| _        || _	         |«        |xr |d   }|xr |d   |u }|r|d    ||d   «      k\  r |«        Œ”|dz   |d   d<   |dk  rD | ||«      j                  «      xs  ||dz   «      }|�D|| _        || _	         |«       r/ |«        n'||   \  }} |
|| |t        ||dz   «      «      dg«        ||«      |	kD  r�Œyy)zUWalk the tree starting at a given node.

        Maintain a stack of nodes.

        Ú_iteméÿÿÿÿÚ_nameNé    éþÿÿÿr   )
r.   Úgetr/   r"   Úappendr   r   r   Úcur_nodeÚcur_name)r%   r&   r   ÚlistÚlenr   r.   r/   r"   Ú
emptystackr;   r   ÚsubnodesÚindexÚhandlerÚcurrentÚpopstacks                    r   r$   zTreeWalk.walkl   s¹  € ð ×(Ñ(×,Ñ,ˆØ×*Ñ*×.Ñ.ˆØ—N‘Nˆ	Ù˜“^ˆ
Ø×&Ñ&¨	¯©�ˆÙ��d™D¤¨4°¸±Ó!@ÓAÀ2ÐFÔGÙ�)‹n˜zÓ)Ø*3°B©-Ñ'ˆD�$˜ %Ø™˜H›Ò%Ù(©¨d«×)<Ñ)<Ó=ò 9Ù(¨°©Ó8ð à�?Ù”EØØ $�”Ø $�”Ù”	Ø#Ò5¨	°"©�Ø"Ò9 w¨q¡z°TÐ'9�Ù ¨¡©s°7¸2±;Ó/?Ò ?Ù”EØØ %¨¡	ˆI�b‰M˜"ÑØ�qŠyÙ'©¨T«
×(;Ñ(;Ó<ò 8Ù'¨¨w©Ó7ð àÐ&Ø$(�D”MØ$(�D”MÙ”yÙ�à% e™_‘
��dÙ˜˜d¡D¬°4¸À¹Ó)HÓ$IÈ2ÐNÔOñ7 �)‹n˜zÖ)r   c                 óH   — | j                   }t        |«      dk  ry|d   d   S )z+Return the parent node of the current node.é   Nr9   r8   ©r"   r?   ©r%   r"   s     r   ÚparentzTreeWalk.parent•   s+   € ð —N‘Nˆ	Üˆy‹>˜AÒØØ˜‰}˜QÑÐr   c                 óH   — | j                   }t        |«      dk  ry|d   dd S )z Return the parent node and name.rG   Nr9   rH   rI   s     r   Úparent_namezTreeWalk.parent_name�   s-   € ð —N‘Nˆ	Üˆy‹>˜AÒØØ˜‰}˜R˜aÐ Ð r   c                 ó  — | j                   }| j                  }|j                  «       }|d   }|d   dz
  }|d   |   \  }}|d   |cxu r|u sn J |d   ||d   |f«       ‚|d   }	t        |	t        «      r||	|<   yt        |	||«       y)z<Replace a node after first checking integrity of node stack.r6   r   r9   r8   N)r<   r"   r   Ú
isinstancer>   Úsetattr)
r%   Únew_noder<   r"   ÚcurÚprevrB   Úoldnoder   rJ   s
             r   ÚreplacezTreeWalk.replace¥   s¢   € à—=‘=ˆØ—N‘Nˆ	Ø�m‰m‹oˆØ˜‰}ˆØ�R‘˜1‘ˆØ˜R™ ™‰ˆ�Ø�1‰v˜Ó, WÓ,ð 	6¨s°1©v°xÀÀbÁØ/4ð/6ó 	6Ð,à�a‘ˆÜ�fœdÔ#Ø$ˆF�5ŠMä�F˜D (Õ+r   r!   )r   r   r   r   r'   r#   r>   r?   r   r$   ÚpropertyrJ   rL   rT   r   r   r   r   r   +   sQ   „ ñ)óVò>ð ! t°¸4ó 'PðR ñ ó ð ð ñ!ó ð!ó,r   r   N)r   Ú	node_utilr   r   r   r	   r   r   r   r   Ú<module>rW      s;   ðñõ !ô>�$ô >ñ, ˜-¨&¨°BÓ7€ôH,ˆ{õ H,r   