
    h*                     0    S r SSKrSSKJr   " S S5      rg)zT
A class for storing a tree graph. Primarily used for filter constructs in the
ORM.
    N)make_hashablec                       \ rS rSrSrSrSS jr\SS j5       rS r	S r
S	 r\rS
 rS rS rS rS rS rS rS rSrg)Node   z
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                 j    U(       a  USS O/ U l         U=(       d    U R                  U l        X0l        g)z@Construct a new Node. If no connector is given, use the default.N)childrendefault	connectornegated)selfr	   r   r   s       C/var/www/html/env/lib/python3.13/site-packages/django/utils/tree.py__init__Node.__init__   s&    '/R"2dll    c                 P    [        X=(       d    U R                  U5      nXl        U$ )z
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   createNode.create   s#     85#++w?
r   c                     U R                   (       a  SOSnXR                  SR                  S U R                   5       5      4-  $ )Nz(NOT (%s: %s))z(%s: %s)z, c              3   8   #    U  H  n[        U5      v   M     g 7fN)str).0cs     r   	<genexpr>Node.__str__.<locals>.<genexpr>*   s     4S]SVV]s   )r   r   joinr	   )r   templates     r   __str__Node.__str__(   s5    '+||#>>4994ST]]4S+STTTr   c                 @    SU R                   R                  < SU < S3$ )N<z: >)r   __name__r   s    r   __repr__Node.__repr__,   s    !^^44d;;r   c                 p    U R                  U R                  U R                  S9nU R                  Ul        U$ N)r   r   )r   r   r   r	   )r   r   s     r   __copy__Node.__copy__/   s,    kkDNNDLLkI}}
r   c                     U R                  U R                  U R                  S9n[        R                  " U R
                  U5      Ul        U$ r,   )r   r   r   copydeepcopyr	   )r   memodictr   s      r   __deepcopy__Node.__deepcopy__6   s7    kkDNNDLLkI}}T]]H=
r   c                 ,    [        U R                  5      $ )z,Return the number of children this node has.)lenr	   r(   s    r   __len__Node.__len__;   s    4==!!r   c                 ,    [        U R                  5      $ )z-Return whether or not this node has children.)boolr	   r(   s    r   __bool__Node.__bool__?   s    DMM""r   c                     XR                   ;   $ )z:Return True if 'other' is a direct child of this instance.)r	   r   others     r   __contains__Node.__contains__C   s    %%r   c                     U R                   UR                   :H  =(       aY    U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R                  UR                  :H  $ r   )r   r   r   r	   r>   s     r   __eq__Node.__eq__G   sX    NNeoo- 0%//10-0 /		
r   c                     [        U R                  U R                  U R                  /[	        U R
                  5      Q75      $ r   )hashr   r   r   r   r	   r(   s    r   __hash__Node.__hash__O   s<     t}}-	
 	
r   c                 t   U R                   U:w  a   U R                  5       nX l         X1/U l        U$ [        U[        5      (       aW  UR
                  (       dF  UR                   U:X  d  [        U5      S:X  a'  U R                  R                  UR                  5        U $ U R                  R                  U5        U$ )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   r0   r	   
isinstancer   r   r6   extendappend)r   data	conn_typer   s       r   addNode.addY   s     >>Y&))+C&N KDMKtT""LL9,D	Q MM  /K MM  &Kr   c                 0    U R                   (       + U l         g)z'Negate the sense of the root connector.N)r   r(   s    r   negateNode.negate|   s    <<'r   )r	   r   r   )NNF)r'   
__module____qualname____firstlineno____doc__r
   r   classmethodr   r"   r)   r-   r0   r3   r7   r;   r@   rC   rG   rP   rS   __static_attributes__ r   r   r   r      sg     G 	 	U<
 D
"#&

!F(r   r   )rX   r0   django.utils.hashabler   r   r[   r   r   <module>r]      s   
  /s( s(r   