add-determinism 0.7.3

RPM buildroot helper to strip nondeterministic bits in files
Documentation
3

�
�^9c@s�dZddlmZmZddlmZdZdZdZdZ	dZ
dZee	eeee
Zdd	�Z
d
d�Zd d
d�Zdd�Zdd�Zdd�Zdd�Zedd�Zdd�Zdd�Zdd�ZdS)!zVarious utility functions.�)�
namedtuple�OrderedDict)�commonprefixTiPiicCsBt|�||}|tkr>d|d|�||t|�|d�f}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s�	prefixlenZ	suffixlenZskip�r�%/usr/lib64/python3.6/unittest/util.py�_shortens&r
cs�ttt|��}ttt|��}|tkr(|St|��t���t|�tt}|t	krxt
�t|��t��fdd�|D��St
�tt	��t��fdd�|D��S)Nc3s|]}�|�d�VqdS�Nr�Z.0r�Zprefixrrr	�	<genexpr>'sz'_common_shorten_repr.<locals>.<genexpr>c3s&|]}�t|�d�tt�VqdSr)r
�
_MIN_DIFF_LEN�_MIN_END_LENrr
rr	r*s)ZtupleZmap�	safe_reprZmaxr�_MAX_LENGTHr�_MIN_BEGIN_LENr�_MIN_COMMON_LENr
)ZargsZmaxlenZ
common_lenrr
r	�_common_shorten_reprsrFcCsRyt|�}Wntk
r*tj|�}YnX|s>t|�tkrB|S|dt�dS)Nz [truncated]...)ZreprZ	Exception�objectZ__repr__rr)ZobjZshort�resultrrr	r-srcCsd|j|jfS)Nz%s.%s)Z
__module__Z__qualname__)Zclsrrr	�strclass6srcCs*d}}g}g}�xy�||}||}||kr\|j|�|d7}x�|||krX|d7}qBWn�||kr�|j|�|d7}xf|||kr�|d7}qxWnL|d7}zx|||kr�|d7}q�WWd|d7}x|||kr�|d7}q�WXWqtk
�r|j||d��|j||d��PYqXqW||fS)arFinds elements in only one or the other of two, sorted input lists.

    Returns a two-element tuple of lists.    The first list contains those
    elements in the "expected" list but not in the "actual" list, and the
    second contains those elements in the "actual" list but not in the
    "expected" list.    Duplicate elements in either input list are ignored.
    r�N)�appendZ
IndexErrorZextend)�expected�actual�i�j�missingZ
unexpectedZeZarrr	�sorted_list_difference9s:

r cCsLg}x>|rB|j�}y|j|�Wqtk
r>|j|�YqXqW||fS)z�Same behavior as sorted_list_difference but
    for lists of unorderable items (like dicts).

    As it does a linear search per item (remove) it
    has O(n*n) performance.)ZpopZremoveZ
ValueErrorr)rrrZitemrrr	�unorderable_list_differencebsr!cCs||k||kS)z.Return -1 if x < y, 0 if x == y and 1 if x > yr)ZxZyrrr	�
three_way_cmpssr"ZMismatchzactual expected valuecCsDt|�t|�}}t|�t|�}}t�}g}x�t|�D]�\}}	|	|krJq8d}
}x.t||�D] }|||	kr^|
d7}
|||<q^Wx,t|�D] \}}
|
|	kr�|d7}|||<q�W|
|kr8t|
||	�}|j|�q8Wxlt|�D]`\}}	|	|kr�q�d}x2t||�D]$}|||	k�r�|d7}|||<�q�Wtd||	�}|j|�q�W|S)�HReturns list of (cnt_act, cnt_exp, elem) triples where the counts differrr)ZlistrrZ	enumerateZrange�	_Mismatchr)rrr�tZmZnZNULLrr�elem�cnt_s�cnt_trZ
other_elem�diffrrr	�_count_diff_all_purposeys<r*cCs,t�}x |D]}|j|d�d||<qW|S)z@Return dict of element counts, in the order they were first seenrr)r�get)ZiterableZcr&rrr	�_ordered_count�s
r,c	Cs�t|�t|�}}g}x>|j�D]2\}}|j|d�}||kr t|||�}|j|�q Wx2|j�D]&\}}||kr`td||�}|j|�q`W|S)r#r)r,Zitemsr+r$r)	rrrr%rr&r'r(r)rrr	�_count_diff_hashable�sr-N)F)Z__doc__ZcollectionsrrZos.pathrZ
__unittestrrrrrrr
rrrr r!r"r$r*r,r-rrrr	Z<module>s*
	)
#