o
    .d                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ e	 Z
G dd	 d	eee	f ZG d
d deZG dd deZG dd deZde	defddZdS )zManage undefined template variables.

When rendering a Liquid template, if a variable name can not be resolved, an instance of
liquid.Undefined, or a subclass, is used instead.
    )Any)Iterable)Iterator)Mapping)Optional)UndefinedErrorc                   @   s   e Zd ZdZdZedfdededee fddZ	d	ed
e
fddZded
e
fddZded
efddZd
efddZd
ee fddZd
efddZd
efddZd
efddZd
efddZd
ee fdd ZdS )!	UndefinedzzThe default undefined type.

    Always evaluates to an empty string. Can be iterated over and indexed without error.
    nameobjhintNr
   r   r   c                 C   s   || _ || _|| _d S Nr	   selfr
   r   r    r   H/var/www/Matress/matenv/lib/python3.10/site-packages/liquid/undefined.py__init__   s   
zUndefined.__init__itemreturnc                 C      dS )NFr   r   r   r   r   r   __contains__      zUndefined.__contains__otherc                 C   s   t |tp|d u S r   
isinstancer   r   r   r   r   r   __eq__!   s   zUndefined.__eq__keyc                 C   s   | S r   r   r   r   r   r   r   __getitem__$   r   zUndefined.__getitem__c                 C   r   Nr   r   r   r   r   r   __len__'   r   zUndefined.__len__c                 C   s   t g S r   )iterr"   r   r   r   __iter__*   s   zUndefined.__iter__c                 C   r   )N r   r"   r   r   r   __str__-   r   zUndefined.__str__c                 C      d| j  dS Nz
Undefined()r
   r"   r   r   r   __repr__0      zUndefined.__repr__c                 C   r   r!   r   r"   r   r   r   __int__3   r   zUndefined.__int__c                 C   s
   t | jS r   )hashr
   r"   r   r   r   __hash__6      
zUndefined.__hash__c                 C   s   g S r   r   r"   r   r   r   __reversed__9   r   zUndefined.__reversed__)__name__
__module____qualname____doc__	__slots__	UNDEFINEDstrobjectr   r   boolr   r   r    intr#   r   r   r%   r'   r,   r.   r0   r   r2   r   r   r   r   r      s     r   c                   @   s0   e Zd ZdZdZdefddZdefddZdS )	DebugUndefinedz:An undefined that returns debug information when rendered.r   r   c                 C   sD   | j r	d| j  S | jturt| jj d| j dS d| j dS )Nzundefined: z has no attribute ''' is undefined)r   r   r8   typer3   r
   r"   r   r   r   r'   B   s
   
zDebugUndefined.__str__c                 C   r(   r)   r+   r"   r   r   r   r,   I   r-   zDebugUndefined.__repr__N)r3   r4   r5   r6   r7   r9   r'   r,   r   r   r   r   r=   =   s
    r=   c                       s  e Zd ZdZdZeg dZedfdede	de
e f fdd	Zded
e	fddZde	d
efddZde	d
efddZded
e	fddZd
efddZd
ee fddZd
efddZd
efddZd
efddZd
efd d!Zd
efd"d#Zd
ee fd$d%Z  ZS )&StrictUndefinedzGAn undefined that raises an exception for everything other than `repr`.)msg)r,   r
   r   r   rB   Nr
   r   r   c                    s8   t  j|||d | jr| j| _d S d| j d| _d S )N)r   r   r>   r?   )superr   r   r
   rB   r   	__class__r   r   r   ]   s   &zStrictUndefined.__init__r   c                 C   s,   |t | dv rt | |S tt | d)Nallowed_propertiesrB   )r:   __getattribute__r   )r   r
   r   r   r   rG   a   s   z StrictUndefined.__getattribute__r   c                 C   
   t | jr   r   rB   r   r   r   r   r   f   r1   zStrictUndefined.__contains__r   c                 C   rH   r   rI   r   r   r   r   r   i   r1   zStrictUndefined.__eq__r   c                 C   rH   r   rI   r   r   r   r   r    l   r1   zStrictUndefined.__getitem__c                 C   rH   r   rI   r"   r   r   r   r#   o   r1   zStrictUndefined.__len__c                 C   rH   r   rI   r"   r   r   r   r%   r   r1   zStrictUndefined.__iter__c                 C   rH   r   rI   r"   r   r   r   r'   u   r1   zStrictUndefined.__str__c                 C   r(   )NzStrictUndefined(r*   r+   r"   r   r   r   r,   x   r-   zStrictUndefined.__repr__c                 C   rH   r   rI   r"   r   r   r   __bool__{   r1   zStrictUndefined.__bool__c                 C   rH   r   rI   r"   r   r   r   r.   ~   r1   zStrictUndefined.__int__c                 C   rH   r   rI   r"   r   r   r   r0      r1   zStrictUndefined.__hash__c                 C   rH   r   rI   r"   r   r   r   r2      r1   zStrictUndefined.__reversed__)r3   r4   r5   r6   r7   	frozensetrF   r8   r9   r:   r   r   rG   r;   r   r   r    r<   r#   r   r   r%   r'   r,   rJ   r.   r0   r   r2   __classcell__r   r   rD   r   rA   M   s&    $
rA   c                   @   s    e Zd ZdZdZeg dZdS )StrictDefaultUndefinedz9An undefined that plays nicely with the `default` filter.T)r,   force_liquid_defaultr
   r   r   rB   N)r3   r4   r5   r6   rN   rK   rF   r   r   r   r   rM      s    rM   r   r   c                 C   s
   t | tS )z7Return `True` if `obj` is undefined. `False` otherwise.r   )r   r   r   r   is_undefined   s   
rO   N)r6   typingr   r   r   r   r   liquid.exceptionsr   r:   r8   r   r=   rA   rM   r;   rO   r   r   r   r   <module>   s    ,;