
    Evg*                     8    d Z ddlZddlmZ  G d d          ZdS )zT
A class for storing a tree graph. Primarily used for filter constructs in the
ORM.
    N)make_hashablec                   |    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dS )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.
    DEFAULTNFc                 V    |r
|dd         ng | _         |p| j        | _        || _        dS )z@Construct a new Node. If no connector is given, use the default.N)childrendefault	connectornegated)selfr   r
   r   s       N/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/utils/tree.py__init__zNode.__init__   s3    '/7R"2dl    c                 D    t          ||p| 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                 t    | j         rdnd}|| j        d                    d | j        D                       fz  S )Nz(NOT (%s: %s))z(%s: %s)z, c              3   4   K   | ]}t          |          V  d S N)str).0cs     r   	<genexpr>zNode.__str__.<locals>.<genexpr>*   s(      4S4SSVV4S4S4S4S4S4Sr   )r   r
   joinr   )r   templates     r   __str__zNode.__str__(   sC    '+|C##4>4994S4ST]4S4S4S+S+STTTr   c                 (    d| j         j        d| dS )N<z: >)r   __name__r   s    r   __repr__zNode.__repr__,   s     !^444ddd;;r   c                 `    |                      | j        | j                  }| j        |_        |S N)r
   r   )r   r
   r   r   )r   r   s     r   __copy__zNode.__copy__/   s)    kkDNDLkII}
r   c                     |                      | j        | j                  }t          j        | j        |          |_        |S r&   )r   r
   r   copydeepcopyr   )r   memodictr   s      r   __deepcopy__zNode.__deepcopy__6   s5    kkDNDLkI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    DM"""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    o/| j        |j        k    o| j        |j        k    o| j        |j        k    S r   )r   r
   r   r   r4   s     r   __eq__zNode.__eq__G   sH    Neo- 0%/10-0 /		
r   c                 n    t          | j        | j        | j        gt	          | j                  R           S r   )hashr   r
   r   r   r   r#   s    r   __hash__zNode.__hash__O   sA     t}--	 
 
 	
r   c                 R   | j         |k    r&|                                 }|| _         ||g| _        |S t          |t                    rF|j        s?|j         |k    st          |          dk    r!| j                            |j                   | S | 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""	L	 9,,D		Q M  ///K M  &&&Kr   c                      | j          | _         dS )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      s	         G    	 	 	 [	U U U< < <  
 D  
" " "# # #& & &
 
 

 
 
! ! !F( ( ( ( (r   r   )rH   r)   django.utils.hashabler   r   rJ   r   r   <module>rL      sh    
  / / / / / /s( s( s( s( s( s( s( s( s( s(r   