B
    \                 @   sD   d dl ZddlmZ e ZG dd deZe Z	G dd deZ
dS )    N   )excc               @   s   e Zd Zdd Zdd ZdS )BasicEntityc             K   s&   x |  D ]\}}t| || q
W d S )N)itemssetattr)selfkwkeyvalue r   :lib/python3.7/site-packages/sqlalchemy/testing/entities.py__init__   s    zBasicEntity.__init__c          
      sh   t  tkrt S tt   z.d jjd fddt j	
 D f S tt   X d S )Nz%s(%s)z, c                s(   g | ] }| d sd|t |f qS )_z%s=%r)
startswithgetattr).0r	   )r   r   r   
<listcomp>   s   z(BasicEntity.__repr__.<locals>.<listcomp>)id_repr_stackobject__repr__add	__class____name__joinsorted__dict__keysremove)r   r   )r   r   r      s    

zBasicEntity.__repr__N)r   
__module____qualname__r   r   r   r   r   r   r      s   r   c               @   s$   e Zd Zdd Zdd Zdd ZdS )ComparableEntityc             C   s
   t | jS )N)hashr   )r   r   r   r   __hash__+   s    zComparableEntity.__hash__c             C   s   |  | S )N)__eq__)r   otherr   r   r   __ne__.   s    zComparableEntity.__ne__c          
   C   sr  || krdS | j |j ksdS t| tkr,dS tt|  z ytjj| j}W n tjj	j
k
rp   d}Y nX |dkr| }|}n|dk	r|}| }n| }|}xt|jD ]}|drqt||}yt||}W n ttjfk
r   dS X t|drBt|dr*t|ds*t|t|kr@dS nt|t|krVdS q|dk	r||krdS qW dS tt|  X dS )z'Deep, sparse compare.

        Deeply compare two entities, following the non-None attributes of the
        non-persisted object, if possible.

        TFNr   __iter____getitem__r   )r   r   _recursion_stackr   saZormZ
attributesZinstance_stater	   r   ZNO_STATElistr   r   r   AttributeErrorsa_excZUnboundExecutionErrorhasattrsetr   )r   r%   Zself_keyabattrr
   Zbattrr   r   r   r$   1   sN    



zComparableEntity.__eq__N)r   r   r    r#   r&   r$   r   r   r   r   r!   *   s   r!   )Z
sqlalchemyr*    r   r-   r/   r   r   r   r)   r!   r   r   r   r   <module>   s
   