
    h                     0    d Z ddlZddlmZ  G d d      Zy)zT
A class for storing a tree graph. Primarily used for filter constructs in the
ORM.
    N)make_hashablec                   l    e Zd ZdZdZddZedd       Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZddZd Zy)Nodez
    A single internal node in the tree graph. A Node should be viewed as a
    connection (the root) with the children being either leaf nodes or other
    Node instances.
    DEFAULTNc                 X    |r|dd ng | _         |xs | j                  | _        || _        y)z@Construct a new Node. If no connector is given, use the default.N)childrendefault	connectornegated)selfr   r
   r   s       T/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/django/utils/tree.py__init__zNode.__init__   s(    '/R"2dll    c                 .    t        |||      }| |_        |S )a  
        Create a new instance of this class when new Nodes (or subclasses) are
        needed in the internal code in this class. Normally, it just shadows
        __init__(). However, subclasses with an __init__ signature that aren't
        an extension of Node.__init__ might need to implement this method to
        allow a Node to create a new instance of them (if they have any extra
        setting up to do).
        )r   	__class__)clsr   r
   r   objs        r   _new_instancezNode._new_instance   s     8Y0
r   c                     | j                   rdnd}|| j                  dj                  d | j                  D              fz  S )Nz(NOT (%s: %s))z(%s: %s)z, c              3   2   K   | ]  }t        |        y wN)str).0cs     r   	<genexpr>zNode.__str__.<locals>.<genexpr>-   s     4SSV4Ss   )r   r
   joinr   )r   templates     r   __str__zNode.__str__+   s7    '+||#4>>4994ST]]4S+STTTr   c                 <    d| j                   j                  d| dS )N<z: >)r   __name__r   s    r   __repr__zNode.__repr__/   s    !^^44d;;r   c                     t        | j                  | j                        }| j                  |_        t	        j
                  | j                  |      |_        |S )N)r
   r   )r   r
   r   r   copydeepcopyr   )r   memodictr   s      r   __deepcopy__zNode.__deepcopy__2   s<    T^^T\\B}}T]]H=
r   c                 ,    t        | j                        S )z,Return the number of children this node has.)lenr   r#   s    r   __len__zNode.__len__8   s    4==!!r   c                 ,    t        | j                        S )z-Return whether or not this node has children.)boolr   r#   s    r   __bool__zNode.__bool__<   s    DMM""r   c                     || j                   v S )z:Return True if 'other' is a direct child of this instance.)r   r   others     r   __contains__zNode.__contains__@   s    %%r   c                     | j                   |j                   k(  xrL | j                  | j                  f|j                  |j                  fk(  xr | j                  |j                  k(  S r   )r   r
   r   r   r1   s     r   __eq__zNode.__eq__D   sS    NNeoo- ,^^T\\*u.NN,MMU^^+	
r   c                     t        | j                  | j                  | j                  gt	        | j
                              S r   )hashr   r
   r   r   r   r#   s    r   __hash__zNode.__hash__K   s1    T^^T^^T\\aMRVR_R_D`abbr   c                    || j                   v r|S |s| j                   j                  |       |S | j                  |k(  r}t        |t              rP|j
                  sD|j                  |k(  st        |      dk(  r'| j                   j                  |j                          | S | j                   j                  |       |S | j                  | j                   | j                  | j
                        }|| _        ||g| _         |S )a/  
        Combine this tree and the data represented by data using the
        connector conn_type. The combine is done by squashing the node other
        away if possible.

        This tree (self) will never be pushed to a child node of the
        combined tree, nor will the connector or negated properties change.

        Return a node which can be used in place of data regardless if the
        node other got squashed or not.

        If `squash` is False the data is prepared and added as a child to
        this tree without further logic.
           )	r   appendr
   
isinstancer   r   r+   extendr   )r   data	conn_typesquashr   s        r   addzNode.addN   s     4== KMM  &K>>Y&4&t||^^y0CIN $$T]]3 $$T*$$T]]DNN%)\\3C&DN $KDMKr   c                 (    | j                    | _         y)z'Negate the sense of the root connector.N)r   r#   s    r   negatezNode.negatez   s    <<'r   )NNF)T)r"   
__module____qualname____doc__r	   r   classmethodr   r   r$   r)   r,   r/   r3   r5   r8   rA   rC    r   r   r   r      s\     G  U<"#&
c*X(r   r   )rF   r&   django.utils.hashabler   r   rH   r   r   <module>rJ      s   
  /q( q(r   