File: //usr/lib/python3/dist-packages/django/utils/__pycache__/tree.cpython-310.pyc
o
3�a6 � @ s* d Z ddlZddlmZ G dd� d�ZdS )zT
A class for storing a tree graph. Primarily used for filter constructs in the
ORM.
� N)�
make_hashablec @ s~ e Zd ZdZdZddd�Zeddd��Zd d
� Zdd� Z d
d� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zddd�Zdd� ZdS ) �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 C s, |r|dd� ng | _ |p| j| _|| _dS )z@Construct a new Node. If no connector is given, use the default.N)�children�default� connector�negated)�selfr r r � r
�3/usr/lib/python3/dist-packages/django/utils/tree.py�__init__ s
z
Node.__init__c C s 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 �objr
r
r �
_new_instance s
zNode._new_instancec C s. | j rdnd}|| jd�dd� | jD ��f S )Nz(NOT (%s: %s))z(%s: %s)z, c s s � | ]}t |�V qd S �N)�str)�.0�cr
r
r � <genexpr>- s � zNode.__str__.<locals>.<genexpr>)r r �joinr )r �templater
r
r �__str__+ s zNode.__str__c C s d| j j| f S )Nz<%s: %s>)r
�__name__�r r
r
r �__repr__/ s z
Node.__repr__c C s, t | j| jd�}| j|_t�| j|�|_|S )N)r r )r r r r
�copy�deepcopyr )r �memodictr r
r
r �__deepcopy__2 s zNode.__deepcopy__c C �
t | j�S )z,Return the number of children this node has.)�lenr r r
r
r �__len__8 �
zNode.__len__c C r )z-Return whether or not this node has children.)�boolr r r
r
r �__bool__<