a
    P^N`  ã                   @   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eee ef eee  dœ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                   @   sn   e Zd Zeee  ee ddœdd„Zee	dœdd„Z
ee e	dœdd	„Zee	dœd
d„Zee	dœdd„ZdS )ÚMatchInAnyOrderN)ÚmatchersÚmismatch_descriptionÚreturnc                 C   s&   t ttt  |d d … ƒ| _|| _d S ©N)r   r   r   r   r   r   )Úselfr   r   © r   úZlib/python3.9/site-packages/hamcrest/library/collection/issequence_containinginanyorder.pyÚ__init__   s    zMatchInAnyOrder.__init__)Úitemr   c                 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rD| 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                       sn   e Zd Zeee  ddœdd„Zdee ee e	dœ‡ fdd„Z
ee eddœdd	„Zedd
œdd„Z‡  ZS )ÚIsSequenceContainingInAnyOrderN)r   r   c                 C   s
   || _ d S r   )r   )r   r   r   r   r   r   5   s    z'IsSequenceContainingInAnyOrder.__init__)r   r   r   c                    sl   z<t |ƒ}t| j|ƒ}|D ]}| |¡s W dS q| |¡W S  tyf   |r`tt| ƒ ||¡ Y dS 0 d S )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)Údescriptionr   c                 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_to)N)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    %