B
    v9a_  ã               @   s¤   d dl mZmZ d dlmZ dZdZdZdZdZ	dZ
eee e
 e e	  Zdd„ Zd	d
„ Zddd„Zdd„ Zdd„ Zdd„ Zdd„ ZeddƒZdd„ Zdd„ ZdS )é    )Ú
namedtupleÚCounter)ÚcommonprefixTéP   é   é   c             C   sB   t | ƒ| | }|tkr>d| d |… || t | ƒ| d … f } | S )Nz%s[%d chars]%s)ÚlenÚ_PLACEHOLDER_LEN)ÚsÚ	prefixlenZ	suffixlenÚskip© r   ú/usr/lib/python3.7/util.pyÚ_shorten   s    &r   c                 sœ   t tt| ƒƒ} ttt| ƒƒ}|tkr(| S t| ƒ‰ tˆ ƒ‰t|ˆ t t  }|t	krxt
ˆ t|ƒ‰ t ‡ ‡fdd„| D ƒƒS t
ˆ tt	ƒ‰ t ‡ ‡fdd„| D ƒƒS )Nc             3   s   | ]}ˆ |ˆd …  V  qd S )Nr   )Ú.0r
   )Úprefixr   r   r   ú	<genexpr>'   s    z'_common_shorten_repr.<locals>.<genexpr>c             3   s&   | ]}ˆ t |ˆd … ttƒ V  qd S )N)r   Ú_MIN_DIFF_LENÚ_MIN_END_LEN)r   r
   )r   r   r   r   r   *   s   )ÚtupleÚmapÚ	safe_reprÚmaxr   Ú_MAX_LENGTHr   Ú_MIN_BEGIN_LENr	   Ú_MIN_COMMON_LENr   )ÚargsÚmaxlenZ
common_lenr   )r   r   r   Ú_common_shorten_repr   s    r   Fc             C   sP   yt | ƒ}W n tk
r*   t | ¡}Y nX |r<t|ƒtk r@|S |d t… d S )Nz [truncated]...)ÚreprÚ	ExceptionÚobjectÚ__repr__r   r   )ÚobjZshortÚresultr   r   r   r   -   s    r   c             C   s   d| j | jf S )Nz%s.%s)Ú
__module__Ú__qualname__)Úclsr   r   r   Ústrclass6   s    r(   c             C   s*  d }}g }g }xyÌ| | }|| }||k r\|  |¡ |d7 }xœ| | |krX|d7 }qBW n‚||kr’|  |¡ |d7 }xf|| |krŽ|d7 }qxW nL|d7 }zx| | |kr´|d7 }qžW W d |d7 }x|| |krÚ|d7 }qÄW X W q tk
r   | | |d … ¡ | ||d … ¡ P Y qX qW ||fS )Nr   é   )ÚappendÚ
IndexErrorÚextend)ÚexpectedÚactualÚiÚjÚmissingZ
unexpectedÚeÚar   r   r   Úsorted_list_difference9   s:    

r4   c             C   sL   g }x>| rB|   ¡ }y| |¡ W q tk
r>   | |¡ Y qX qW ||fS )N)ÚpopÚremoveÚ
ValueErrorr*   )r-   r.   r1   Úitemr   r   r   Úunorderable_list_differenceb   s    r9   c             C   s   | |k| |k  S )Nr   )ÚxÚyr   r   r   Úthree_way_cmps   s    r<   ZMismatchzactual expected valuec             C   sD  t | ƒt |ƒ }}t|ƒt|ƒ }}tƒ }g }x¢t|ƒD ]–\}}	|	|krJq8d }
}x.t||ƒD ] }|| |	kr^|
d7 }
|||< q^W x,t|ƒD ] \}}||	krŒ|d7 }|||< qŒW |
|kr8t|
||	ƒ}| |¡ q8W xlt|ƒD ]`\}}	|	|krîqÜd}x2t||ƒD ]$}|| |	k rþ|d7 }|||<  qþW td||	ƒ}| |¡ qÜW |S )Nr   r)   )Úlistr   r!   Ú	enumerateÚrangeÚ	_Mismatchr*   )r.   r-   r
   ÚtÚmÚnZNULLr$   r/   ÚelemÚcnt_sÚcnt_tr0   Z
other_elemÚdiffr   r   r   Ú_count_diff_all_purposey   s<    rH   c       	      C   sŽ   t | ƒt |ƒ }}g }x>| ¡ D ]2\}}| |d¡}||kr t|||ƒ}| |¡ q W x2| ¡ D ]&\}}||kr`td||ƒ}| |¡ q`W |S )Nr   )r   ÚitemsÚgetr@   r*   )	r.   r-   r
   rA   r$   rD   rE   rF   rG   r   r   r   Ú_count_diff_hashableœ   s    rK   N)F)Úcollectionsr   r   Zos.pathr   Z
__unittestr   r	   r   r   r   r   r   r   r   r(   r4   r9   r<   r@   rH   rK   r   r   r   r   Ú<module>   s&   
	)
#