← Back
Editing: tree.cpython-311.pyc
� �|�e6 � �8 � d Z ddlZddlmZ G d� d� � ZdS )zT A class for storing a tree graph. Primarily used for filter constructs in the ORM. � N)� make_hashablec �t � e Zd ZdZdZdd�Zedd�� � Zd� Zd� Z d � Z d � Zd� Zd� Z d � Zd� Zdd�Zd� 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 �V � |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 s �3/usr/lib/python3/dist-packages/django/utils/tree.py�__init__z Node.__init__ s3 � �'/�7�������R�� �"�2�d�l�������� 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_instancezNode._new_instance s! � � �8�Y��0�0���� �� r c �t � | j rdnd}|| j d� d� | j D � � � � fz S )Nz(NOT (%s: %s))z(%s: %s)z, c 3 �4 K � | ]}t |� � V � �d S �N)�str)�.0�cs r � <genexpr>zNode.__str__.<locals>.<genexpr>- s( � � � �4S�4S��S��V�V�4S�4S�4S�4S�4S�4Sr )r r �joinr )r �templates r �__str__zNode.__str__+ sC � �'+�|�C�#�#����4�>�4�9�9�4S�4S�T�]�4S�4S�4S�+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�4�d�d�d�;�;r c � � t | j | j �� � }| j |_ t j | j |� � |_ |S )N)r r )r r r r �copy�deepcopyr )r �memodictr s r �__deepcopy__zNode.__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__zNode.__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__<