
    ^j                     :    d dl mZ  G d d      Z G d de      Zy)   )
ASSERTIONSc                   0    e Zd ZdZed        Zed        Zy)WalkerzWalk from one node to another.c                 l   | j                   }|j                   }| j                  |j                  ur| d|d}t        |      t        j	                  ||      }t
        r|d   | j                  u sJ t        |      }| |d   u rd}nt        t        ||d             }||d   u rd}n||d }||d   |fS )a  
        Walk from `start` node to `end` node.

        Returns:
            (upwards, common, downwards): `upwards` is a list of nodes to go upward to.
            `common` top node. `downwards` is a list of nodes to go downward to.

        Raises:
            WalkError: on no common root node.

        Example:

        >>> from anytree import Node, RenderTree, AsciiStyle
        >>> f = Node("f")
        >>> b = Node("b", parent=f)
        >>> a = Node("a", parent=b)
        >>> d = Node("d", parent=b)
        >>> c = Node("c", parent=d)
        >>> e = Node("e", parent=d)
        >>> g = Node("g", parent=f)
        >>> i = Node("i", parent=g)
        >>> h = Node("h", parent=i)
        >>> print(RenderTree(f, style=AsciiStyle()))
        Node('/f')
        |-- Node('/f/b')
        |   |-- Node('/f/b/a')
        |   +-- Node('/f/b/d')
        |       |-- Node('/f/b/d/c')
        |       +-- Node('/f/b/d/e')
        +-- Node('/f/g')
            +-- Node('/f/g/i')
                +-- Node('/f/g/i/h')

        Create a walker:

        >>> w = Walker()

        This class is made for walking:

        >>> w.walk(f, f)
        ((), Node('/f'), ())
        >>> w.walk(f, b)
        ((), Node('/f'), (Node('/f/b'),))
        >>> w.walk(b, f)
        ((Node('/f/b'),), Node('/f'), ())
        >>> w.walk(h, e)
        ((Node('/f/g/i/h'), Node('/f/g/i'), Node('/f/g')), Node('/f'), (Node('/f/b'), Node('/f/b/d'), Node('/f/b/d/e')))
        >>> w.walk(d, e)
        ((), Node('/f/b/d'), (Node('/f/b/d/e'),))

        For a proper walking the nodes need to be part of the same tree:

        >>> w.walk(Node("a"), Node("b"))
        Traceback (most recent call last):
          ...
        anytree.walker.WalkError: Node('/a') and Node('/b') are not part of the same tree.
        z and z are not part of the same tree.     N)	pathroot	WalkErrorr   _Walker__calc_commonr   lentuplereversed)	startend	startpathendpathmsgcommon
len_commonupwardsdowns	            G/opt/ringagent/.cad-venv/lib/python3.12/site-packages/anytree/walker.pywalkzWalker.walk   s    v JJ	((::SXX%IU3')HICC. %%i9!9

***[
F2JGHYz{%;<=G&*D:;'Dr
D((    c                 :    t        d t        | |      D              S )Nc              3   0   K   | ]  \  }}||u s|  y w)Nr	   ).0sieis      r   	<genexpr>z'Walker.__calc_common.<locals>.<genexpr>Z   s     BFBrRBs   )r   zip)r   r   s     r   __calc_commonzWalker.__calc_commonX   s    Bc%oBBBr   N)__name__
__module____qualname____doc__staticmethodr   r   r	   r   r   r   r      s0    (N) N)` C Cr   r   c                       e Zd ZdZy)r   zWalk Error.N)r%   r&   r'   r(   r	   r   r   r   r   ]   s    r   r   N)configr   r   RuntimeErrorr   r	   r   r   <module>r-      s#    VC VCr r   