U
    
Ha1  ã                   @   s2   d Z ddlZddlmZmZmZ G dd„ dƒZdS )zUtilities for defining models
é    N)ÚAnyÚCallableÚTypec                   @   sX   e Zd ZdZddg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 )ÚKeyBasedCompareMixinz7Provides comparison capabilities that is based on a keyÚ_compare_keyÚ_defining_classc                 C   s   || _ || _d S ©N)r   r   )ÚselfÚkeyÚdefining_class© r   ú>/tmp/pip-unpacked-wheel-tx790h60/pip/_internal/utils/models.pyÚ__init__   s    zKeyBasedCompareMixin.__init__c                 C   s
   t | jƒS r   )Úhashr   )r	   r   r   r   Ú__hash__   s    zKeyBasedCompareMixin.__hash__c                 C   s   |   |tj¡S r   )Ú_compareÚoperatorÚ__lt__©r	   Úotherr   r   r   r      s    zKeyBasedCompareMixin.__lt__c                 C   s   |   |tj¡S r   )r   r   Ú__le__r   r   r   r   r      s    zKeyBasedCompareMixin.__le__c                 C   s   |   |tj¡S r   )r   r   Ú__gt__r   r   r   r   r      s    zKeyBasedCompareMixin.__gt__c                 C   s   |   |tj¡S r   )r   r   Ú__ge__r   r   r   r   r   "   s    zKeyBasedCompareMixin.__ge__c                 C   s   |   |tj¡S r   )r   r   Ú__eq__r   r   r   r   r   &   s    zKeyBasedCompareMixin.__eq__c                 C   s   t || jƒstS || j|jƒS r   )Ú
isinstancer   ÚNotImplementedr   )r	   r   Úmethodr   r   r   r   *   s    zKeyBasedCompareMixin._compareN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   r   r   r   r   r   r   r   r   r   r      s   r   )r    r   Útypingr   r   r   r   r   r   r   r   Ú<module>   s   