Ë
    Ñwìi†  ã                   ó`   — d Z ddlmZ dd„Zdd„Zdd„Zdd„Zdd„Zdd	„Zd
„ Z	 G d„ de
«      Zy)z˜
Node Searching.

.. note:: You can speed-up node searching, by installing https://pypi.org/project/fastcache/ and
          using :any:`cachedsearch`.
é    )ÚPreOrderIterNc                 ó$   — t        | |||||¬«      S )a  
    Search nodes matching `filter_` but stop at `maxlevel` or `stop`.

    Return tuple with matching nodes.

    Args:
        node: top node, start searching.

    Keyword Args:
        filter_: function called with every `node` as argument, `node` is returned if `True`.
        stop: stop iteration at `node` if `stop` function returns `True` for `node`.
        maxlevel (int): maximum descending in the node hierarchy.
        mincount (int): minimum number of nodes.
        maxcount (int): maximum number of nodes.

    Example tree:

    >>> 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()).by_attr())
    f
    |-- b
    |   |-- a
    |   +-- d
    |       |-- c
    |       +-- e
    +-- g
        +-- i
            +-- h

    >>> findall(f, filter_=lambda node: node.name in ("a", "b"))
    (Node('/f/b'), Node('/f/b/a'))
    >>> findall(f, filter_=lambda node: d in node.path)
    (Node('/f/b/d'), Node('/f/b/d/c'), Node('/f/b/d/e'))

    The number of matches can be limited:

    >>> findall(f, filter_=lambda node: d in node.path, mincount=4)  # doctest: +ELLIPSIS
    Traceback (most recent call last):
      ...
    anytree.search.CountError: Expecting at least 4 elements, but found 3. ... Node('/f/b/d/e'))
    >>> findall(f, filter_=lambda node: d in node.path, maxcount=2)  # doctest: +ELLIPSIS
    Traceback (most recent call last):
      ...
    anytree.search.CountError: Expecting 2 elements at maximum, but found 3. ... Node('/f/b/d/e'))
    )Úfilter_ÚstopÚmaxlevelÚmincountÚmaxcount©Ú_findall)Únoder   r   r   r   r	   s         ú_/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/anytree/search.pyÚfindallr      s   € ôn �D '°¸xÐRZÐemÔnÐnó    c                 ó.   ‡‡— t        | ˆˆfd„|||¬«      S )a  
    Search nodes with attribute `name` having `value` but stop at `maxlevel`.

    Return tuple with matching nodes.

    Args:
        node: top node, start searching.
        value: value which need to match

    Keyword Args:
        name (str): attribute name need to match
        maxlevel (int): maximum descending in the node hierarchy.
        mincount (int): minimum number of nodes.
        maxcount (int): maximum number of nodes.

    Example tree:

    >>> 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()).by_attr())
    f
    |-- b
    |   |-- a
    |   +-- d
    |       |-- c
    |       +-- e
    +-- g
        +-- i
            +-- h

    >>> findall_by_attr(f, "d")
    (Node('/f/b/d'),)
    c                 ó   •— t        | ‰‰«      S ©N©Ú_filter_by_name©ÚnÚnameÚvalues    €€r   Ú<lambda>z!findall_by_attr.<locals>.<lambda>q   s   ø€ œ/¨!¨T°5Ô9r   )r   r   r   r	   r
   )r   r   r   r   r   r	   s    ``   r   Úfindall_by_attrr   E   s"   ù€ ôT ØÜ9ØØØôð r   c                 ó    — t        | |||¬«      S )a  
    Search for *single* node matching `filter_` but stop at `maxlevel` or `stop`.

    Return matching node.

    Args:
        node: top node, start searching.

    Keyword Args:
        filter_: function called with every `node` as argument, `node` is returned if `True`.
        stop: stop iteration at `node` if `stop` function returns `True` for `node`.
        maxlevel (int): maximum descending in the node hierarchy.

    Example tree:

    >>> 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()).by_attr())
    f
    |-- b
    |   |-- a
    |   +-- d
    |       |-- c
    |       +-- e
    +-- g
        +-- i
            +-- h

    >>> find(f, lambda node: node.name == "d")
    Node('/f/b/d')
    >>> find(f, lambda node: node.name == "z")
    >>> find(f, lambda node: b in node.path)  # doctest: +ELLIPSIS
    Traceback (most recent call last):
        ...
    anytree.search.CountError: Expecting 1 elements at maximum, but found 5. (Node('/f/b')... Node('/f/b/d/e'))
    )r   r   r   ©Ú_find)r   r   r   r   s       r   Úfindr   x   s   € ôZ �˜w¨T¸HÔEÐEr   c                 ó*   ‡‡— t        | ˆˆfd„|¬«      S )a$  
    Search for *single* node with attribute `name` having `value` but stop at `maxlevel`.

    Return matching node.

    Args:
        node: top node, start searching.
        value: value which need to match


    Keyword Args:
        name (str): attribute name need to match
        maxlevel (int): maximum descending in the node hierarchy.

    Example tree:

    >>> 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, foo=4)
    >>> 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()).by_attr())
    f
    |-- b
    |   |-- a
    |   +-- d
    |       |-- c
    |       +-- e
    +-- g
        +-- i
            +-- h

    >>> find_by_attr(f, "d")
    Node('/f/b/d')
    >>> find_by_attr(f, name="foo", value=4)
    Node('/f/b/d/c', foo=4)
    >>> find_by_attr(f, name="foo", value=8)
    c                 ó   •— t        | ‰‰«      S r   r   r   s    €€r   r   zfind_by_attr.<locals>.<lambda>Ô   s   ø€ ¬¸¸DÀ%Ô)Hr   )r   r   r   )r   r   r   r   s    `` r   Úfind_by_attrr!   ¨   s   ù€ ôX �ÔHÐS[Ô\Ð\r   c                 ó4   — t        | |||d¬«      }|r|d   S d S )Né   )r   r   r	   r   r
   )r   r   r   r   Úitemss        r   r   r   ×   s%   € Ü�T˜7¨¸È1ÔM€EÙˆ5�‰8Ð& $Ð&r   c                 ó²   — t        t        | |||«      «      }t        |«      }|�||k  rd}t        |||fz  |«      ‚|�||kD  rd}t        |||fz  |«      ‚|S )Nz-Expecting at least %d elements, but found %d.z/Expecting %d elements at maximum, but found %d.)Útupler   ÚlenÚ
CountError)	r   r   r   r   r   r	   ÚresultÚ	resultlenÚmsgs	            r   r   r   Ü   sw   € Ü”<  g¨t°XÓ>Ó?€FÜ�F“€IØÐ 	¨HÒ 4Ø=ˆÜ˜ ¨)Ð4Ñ4°fÓ=Ð=ØÐ 	¨HÒ 4Ø?ˆÜ˜ ¨)Ð4Ñ4°fÓ=Ð=Ø€Mr   c                 ó@   — 	 t        | |«      |k(  S # t        $ r Y yw xY w)NF)ÚgetattrÚAttributeError)r   r   r   s      r   r   r   è   s+   € ðÜ�t˜TÓ" eÑ+Ð+øÜò Ùðús   ‚ ‘	œc                   ó   ‡ — e Zd Zˆ fd„Zˆ xZS )r(   c                 óJ   •— |r|dt        |«      z   z  }t        ‰| �	  |«       y)z2Error raised on `mincount` or `maxcount` mismatch.Ú N)ÚreprÚsuperÚ__init__)Úselfr+   r)   Ú	__class__s      €r   r4   zCountError.__init__ð   s&   ø€ áØ�3œ˜f›Ñ%Ñ%ˆCÜ‰Ñ˜Õr   )Ú__name__Ú
__module__Ú__qualname__r4   Ú__classcell__)r6   s   @r   r(   r(   ï   s   ø„ ÷ð r   r(   )NNNNN)r   NNN)NNN)r   N)NN)NNNN)Ú__doc__Úanytree.iteratorsr   r   r   r   r!   r   r   r   ÚRuntimeErrorr(   © r   r   Ú<module>r?      sE   ðñõ +ó7oót0óf-Fó`,]ó^'ó
	òô�õ r   