
    g*                     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                   t    e Zd ZdZdZddZedd       Zd Zd Z	d Z
e
Zd	 Zd
 Zd Zd Zd Zd Z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       i/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/utils/tree.py__init__zNode.__init__   s(    '/R"2dll    c                 J    t        ||xs | j                  |      }| |_        |S )a  
        Create a new instance using Node() instead of __init__() as some
        subclasses, e.g. django.db.models.query_utils.Q, may implement a custom
        __init__() with a signature that conflicts with the one defined in
        Node.__init__().
        )r   r	   	__class__)clsr   r
   r   objs        r   createzNode.create   s'     8Y5#++w?
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V]s   )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                 v    | j                  | j                  | j                        }| j                  |_        |S N)r
   r   )r   r
   r   r   )r   r   s     r   __copy__zNode.__copy__/   s,    kkDNNDLLkI}}
r   c                     | j                  | j                  | j                        }t        j                  | j
                  |      |_        |S r&   )r   r
   r   copydeepcopyr   )r   memodictr   s      r   __deepcopy__zNode.__deepcopy__6   s7    kkDNNDLLkI}}T]]H=
r   c                 ,    t        | j                        S )z,Return the number of children this node has.)lenr   r#   s    r   __len__zNode.__len__;   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__C   s    %%r   c                     | j                   |j                   k(  xrO | j                  |j                  k(  xr4 | j                  |j                  k(  xr | j                  |j                  k(  S r   )r   r
   r   r   r4   s     r   __eq__zNode.__eq__G   sX    NNeoo- 0%//10-0 /		
r   c                     t        | j                  | j                  | j                  gt	        | j
                              S r   )hashr   r
   r   r   r   r#   s    r   __hash__zNode.__hash__O   s<     t}}-	
 	
r   c                 ^   | j                   |k7  r"| j                         }|| _         ||g| _        |S t        |t              rP|j
                  sD|j                   |k(  st        |      dk(  r'| j                  j                  |j                         | S | j                  j                  |       |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.
           )	r
   r)   r   
isinstancer   r   r.   extendappend)r   data	conn_typer   s       r   addzNode.addY   s     >>Y&))+C&DN $KDMKtT"LL9,D	Q MM  /K MM  &Kr   c                 (    | j                    | _         y)z'Negate the sense of the root connector.N)r   r#   s    r   negatezNode.negate|   s    <<'r   )NNF)r"   
__module____qualname____doc__r	   r   classmethodr   r   r$   r'   r)   r,   r/   r2   r6   r8   r;   rC   rE    r   r   r   r      sg     G 	 	U<
 D
"#&

!F(r   r   )rH   r)   django.utils.hashabler   r   rJ   r   r   <module>rL      s   
  /s( s(r   