o
    q!gW                     @   s   d Z zzddlmZ W n ey   ddlmZ Y nw dZW n ey/   ddlmZ dZY nw ze W n e	yA   dd ZY nw G dd	 d	e
eZG d
d deZdS )zvDrop-in replacement for collections.AttributedDict by Raymond Hettinger

http://code.activestate.com/recipes/576693/

    )MutableMapping   )	DictMixin   c                 C   s   | D ]}|s	 dS qdS )NFT )seqelemr   r   a/mnt/skqttb/ctump_chatbot/chatbot/lib/python3.10/site-packages/dirtyjson/attributed_containers.pyall   s
   r
   c                       s   e Zd Z fddZdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
d#ddZdd Zdd ZejZejZejZejZejZdd Zdd Zed$ddZdd  Zd!d" Z  ZS )%AttributedDictc                    s    t t|   i | _|   d S N)superr   __init___AttributedDict__attributesclearself	__class__r   r	   r       s   zAttributedDict.__init__c                 C   s,   g  | _ }|d ||g7 }i | _t|  d S r   )_AttributedDict__end_AttributedDict__mapdictr   )r   endr   r   r	   r   &   s   
zAttributedDict.clearc                 C   s   |  || || j|< d S r   )__setitem__r   )r   keyvalue
attributesr   r   r	   add_with_attributes,   s   z"AttributedDict.add_with_attributesc                 C   s   | j |S r   )r   get)r   r   r   r   r	   r   0   s   zAttributedDict.attributesc                 C   sH   || vr| j }|d }|||g |d<  |d< | j|< t| || d S )N   r   )r   r   r   r   )r   r   r   r   currr   r   r	   r   3   s
    zAttributedDict.__setitem__c                 C   s2   t | | | j|\}}}||d< ||d< d S )Nr   r   )r   __delitem__r   pop)r   r   prev
next_entryr   r   r	   r!   :   s   zAttributedDict.__delitem__c                 c   :    | j }|d }||ur|d V  |d }||usd S d S )Nr   r   r   r   r   r    r   r   r	   __iter__@      
zAttributedDict.__iter__c                 c   r%   )Nr   r   r&   r'   r   r   r	   __reversed__G   r)   zAttributedDict.__reversed__Tc                 C   sd   | st dtdkr|rt|  }nt|  }n|r#tt| }ntt| }| |}||fS )Nzdictionary is emptyr   )KeyErrorpy_levelreversednextiterr"   )r   lastr   r   r   r   r	   popitemN   s   
zAttributedDict.popitemc                    s\    fdd D } j  jf} `  `t  }|\ _  _|r( j|f|fS  j|ffS )Nc                    s   g | ]}| | gqS r   r   ).0kr   r   r	   
<listcomp>c   s    z-AttributedDict.__reduce__.<locals>.<listcomp>)r   r   varscopyr   )r   itemstmp	inst_dictr   r   r	   
__reduce__b   s   zAttributedDict.__reduce__c                 C   s   t | S r   )listr   r   r   r	   keysl   s   zAttributedDict.keysc                 C   s*   | s	d| j jf S d| j jt|  f S )Nz%s()z%s(%s))r   __name__r;   r7   r   r   r   r	   __repr__u   s   zAttributedDict.__repr__c                 C   s
   |  | S r   r   r   r   r   r	   r6   z      
zAttributedDict.copyNc                 C   s   |  }|D ]}|||< q|S r   r   )clsiterabler   dr   r   r   r	   fromkeys~   s   
zAttributedDict.fromkeysc                 C   sN   t |tr!t| t|ko tdd tt|  t| D S t| |S )Nc                 s   s    | ]	\}}||kV  qd S r   r   )r2   pqr   r   r	   	<genexpr>   s    
z(AttributedDict.__eq__.<locals>.<genexpr>)	
isinstancer   lenr
   zipsortedr7   r   __eq__r   otherr   r   r	   rK      s
   
zAttributedDict.__eq__c                 C   s
   | |k S r   r   rL   r   r   r	   __ne__   r?   zAttributedDict.__ne__)Tr   )r=   
__module____qualname__r   r   r   r   r   r!   r(   r*   r1   r:   r<   r   
setdefaultupdater"   valuesr7   r>   r6   classmethodrC   rK   rN   __classcell__r   r   r   r	   r      s.    

r   c                       s2   e Zd Z fddZd fdd	Zdd Z  ZS )	AttributedListc                    s   t t|   g | _d S r   )r   rV   r   _AttributedList__attributesr   r   r   r	   r      s   
zAttributedList.__init__Nc                    s    t t| | | j| d S r   )r   rV   appendrW   )r   r   r   r   r   r	   rX      s   zAttributedList.appendc                 C   s
   | j | S r   )rW   )r   indexr   r   r	   r      r?   zAttributedList.attributesr   )r=   rO   rP   r   rX   r   rU   r   r   r   r	   rV      s    rV   N)__doc__collections.abcr   r   ImportErrorcollectionsr,   UserDictr
   	NameErrorr   r   r;   rV   r   r   r   r	   <module>   s&    	p