o
    (]^  ã                   @   s¶   d dl mZmZmZmZmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ dZdZdZed	ƒZG d
d„ deƒZG dd„ deee  ƒZdeee ef deee  fdd„ZdS )é    )ÚMutableSequenceÚOptionalÚSequenceÚTypeVarÚUnionÚcast)ÚBaseMatcher)ÚDescription)Úwrap_matcher)ÚMatcherzJon ReidzCopyright 2011 hamcrest.orgzBSD, see License.txtÚTc                   @   sz   e Zd Zdeee  dee ddfdd„Zdede	fdd	„Z
dee de	fd
d„Zdede	fdd„Zdede	fdd„ZdS )ÚMatchInAnyOrderÚmatchersÚmismatch_descriptionÚreturnNc                 C   s&   t ttt  |d d … ƒ| _|| _d S ©N)r   r   r   r   r   r   )Úselfr   r   © r   ú]/usr/lib/python3/dist-packages/hamcrest/library/collection/issequence_containinginanyorder.pyÚ__init__   s   
zMatchInAnyOrder.__init__Úitemc                 C   s   |   |¡o	|  |¡S r   )ÚisnotsurplusÚ	ismatched©r   r   r   r   r   Úmatches   s   zMatchInAnyOrder.matchesc                 C   s@   | j sdS | jr| j d¡ ddd| j ¡ d¡ ddd|¡ dS )	NTzno item matches: Ú ú, z in ú[ú]F)r   r   Úappend_textÚappend_listr   r   r   r   Ú
isfinished   s   
ÿzMatchInAnyOrder.isfinishedc                 C   s&   | j s| jr| j d¡ |¡ dS dS )Núnot matched: FT)r   r   r   Úappend_description_ofr   r   r   r   r   "   s
   zMatchInAnyOrder.isnotsurplusc                 C   sH   t | jƒD ]\}}| |¡r| j|=  dS q| jr"| j d¡ |¡ dS )NTr"   F)Ú	enumerater   r   r   r   r#   )r   r   ÚindexZmatcherr   r   r   r   )   s   
þzMatchInAnyOrder.ismatched)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r	   r   Úboolr   r!   r   r   r   r   r   r   r      s    
ÿÿ
þ	r   c                       s|   e Zd Zdeee  ddfdd„Z	ddee dee de	f‡ fdd	„Z
dee deddfd
d„Zdeddfdd„Z‡  ZS )ÚIsSequenceContainingInAnyOrderr   r   Nc                 C   s
   || _ d S r   )r   )r   r   r   r   r   r   5   s   
z'IsSequenceContainingInAnyOrder.__init__r   r   c                    sh   zt |ƒ}t| j|ƒ}|D ]}| |¡s W dS q| |¡W S  ty3   |r0tt| ƒ ||¡ Y dS w )NF)	Úlistr   r   r   r!   Ú	TypeErrorÚsuperr*   Údescribe_mismatch)r   r   r   ZsequenceZmatchsequenceÚelement©Ú	__class__r   r   r   8   s   
ÿ
ÿûz&IsSequenceContainingInAnyOrder.matchesc                 C   s   |   ||¡ d S r   )r   )r   r   r   r   r   r   r.   I   s   z0IsSequenceContainingInAnyOrder.describe_mismatchÚdescriptionc                 C   s"   |  d¡ ddd| j¡  d¡ d S )Nza sequence over r   r   r   z in any order)r   r    r   )r   r2   r   r   r   Údescribe_toL   s   

ÿz*IsSequenceContainingInAnyOrder.describe_tor   )r&   r'   r(   r   r   r   r   r   r	   r)   r   r.   r3   Ú__classcell__r   r   r0   r   r*   4   s    ÿÿÿþr*   Úitemsr   c                  G   s$   g }| D ]	}|  t|ƒ¡ qt|ƒS )a­  Matches if sequences's elements, in any order, satisfy a given list of
    matchers.

    :param match1,...: A comma-separated list of matchers.

    This matcher iterates the evaluated sequence, seeing if each element
    satisfies any of the given matchers. The matchers are tried from left to
    right, and when a satisfied matcher is found, it is no longer a candidate
    for the remaining elements. If a one-to-one correspondence is established
    between elements and matchers, ``contains_inanyorder`` is satisfied.

    Any argument that is not a matcher is implicitly wrapped in an
    :py:func:`~hamcrest.core.core.isequal.equal_to` matcher to check for
    equality.

    )Úappendr
   r*   )r5   r   r   r   r   r   Úcontains_inanyorderR   s   r7   N)Útypingr   r   r   r   r   r   Zhamcrest.core.base_matcherr   Zhamcrest.core.descriptionr	   Z"hamcrest.core.helpers.wrap_matcherr
   Zhamcrest.core.matcherr   Ú
__author__Z__copyright__Z__license__r   Úobjectr   r*   r7   r   r   r   r   Ú<module>   s     %*