
    P}bgh                     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                   r    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 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       d/home/e360mart.nyusoft.in/public_html/e360mart_env/lib/python3.11/site-packages/django/utils/tree.py__init__zNode.__init__   s3    '/7R"2dl    c                 6    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0
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                     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B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    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__@   s    %%r   c                     | j         |j         k    o/| j        |j        k    o| j        |j        k    o| j        |j        k    S r   )r   r
   r   r   r1   s     r   __eq__zNode.__eq__D   sH    Neo- ,Neo-,LEM), MU^+		
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__L   s1    T^T^T\aMRVR_D`D`aabbbr   c                 v   | j         |k    r8|                     | j        | j         | j                  }|| _         ||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   r   
isinstancer   r+   extendappend)r   data	conn_typer   s       r   addzNode.addO   s     >Y&&$$T]DNDLQQC&DN $KDMKtT""		 ^y((CIINN M  ///K M  &&&Kr   c                      | j          | _         dS )z'Negate the sense of the root connector.N)r   r#   s    r   negatezNode.negater   s    <'r   )NNF)r"   
__module____qualname____doc__r	   r   classmethodr   r   r$   r)   r,   r/   r3   r5   r8   r@   rB    r   r   r   r      s          G       [U U U< < <  " " "# # #& & &
 
 
c c c! ! !F( ( ( ( (r   r   )rE   r&   django.utils.hashabler   r   rG   r   r   <module>rI      sh    
  / / / / / /i( i( i( i( i( i( i( i( i( i(r   