a
    w=ic	                     @   s   d Z dgZG dd deZdS )zMisc dict tools.hashdictc                   @   sh   e Zd Z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 Zdd Zdd Zdd ZdS )r   a<  
    hashable dict implementation, suitable for use as a key into
    other dicts.

        >>> h1 = hashdict({"apples": 1, "bananas":2})
        >>> h2 = hashdict({"bananas": 3, "mangoes": 5})
        >>> h1+h2
        hashdict(apples=1, bananas=3, mangoes=5)
        >>> d1 = {}
        >>> d1[h1] = "salad"
        >>> d1[h1]
        'salad'
        >>> d1[h2]
        Traceback (most recent call last):
        ...
        KeyError: hashdict(bananas=3, mangoes=5)

    based on answers from
       http://stackoverflow.com/questions/1151658/python-hashable-dicts

    c                 C   s   t t|  S N)tuplesorteditemsself r   i/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/fontTools/misc/dictTools.pyZ__key   s    zhashdict.__keyc                 C   s$   d | jjddd |  D S )Nz{0}({1})z, c                 s   s*   | ]"}d  t|d t|d V  qdS )z{0}={1}       N)formatstrrepr).0ir   r   r	   	<genexpr>!   s   z$hashdict.__repr__.<locals>.<genexpr>)r   	__class____name__join_hashdict__keyr   r   r   r	   __repr__   s
    

zhashdict.__repr__c                 C   s   t |  S r   )hashr   r   r   r   r	   __hash__$   s    zhashdict.__hash__c                 C   s   t d| jjd S Nz${0} does not support item assignment	TypeErrorr   r   r   )r   keyvaluer   r   r	   __setitem__&   s    zhashdict.__setitem__c                 C   s   t d| jjd S r   r   )r   r   r   r   r	   __delitem__)   s    zhashdict.__delitem__c                 C   s   t d| jjd S r   r   r   r   r   r	   clear,   s    zhashdict.clearc                 O   s   t d| jjd S r   r   r   argskwargsr   r   r	   pop/   s    zhashdict.popc                 O   s   t d| jjd S r   r   r!   r   r   r	   popitem2   s    zhashdict.popitemc                 O   s   t d| jjd S r   r   r!   r   r   r	   
setdefault5   s    zhashdict.setdefaultc                 O   s   t d| jjd S r   r   r!   r   r   r	   update8   s    zhashdict.updatec                 C   s   t | }t|| |S r   )r   dictr'   )r   rightresultr   r   r	   __add__>   s    zhashdict.__add__N)r   
__module____qualname____doc__r   r   r   r   r   r    r$   r%   r&   r'   r+   r   r   r   r	   r      s   N)r.   __all__r(   r   r   r   r   r	   <module>   s   