
    e                         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e      Z G d deee            Zdeee   ef   deee      fdZy)    )MutableSequenceOptionalSequenceTypeVarUnioncast)BaseMatcher)Description)wrap_matcher)MatcherzJon ReidzCopyright 2011 hamcrest.orgzBSD, see License.txtTc                   x    e Zd Zdeee      dee   ddfdZdede	fdZ
dee   de	fdZdede	fd	Zdede	fd
Zy)MatchInAnyOrdermatchersmismatch_descriptionreturnNc                 ^    t        t        t        t              |d d        | _        || _        y N)r   r   r   r   r   r   )selfr   r   s      ]/usr/lib/python3/dist-packages/hamcrest/library/collection/issequence_containinginanyorder.py__init__zMatchInAnyOrder.__init__   s'     _WQZ8(1+F$8!    itemc                 J    | j                  |      xr | j                  |      S r   )isnotsurplus	ismatchedr   r   s     r   matcheszMatchInAnyOrder.matches   s!      &?4>>$+??r   c                     | j                   sy| j                  rX| j                  j                  d      j                  ddd| j                         j                  d      j                  ddd|       y)	NTzno item matches:  , z in []F)r   r   append_textappend_listr   s     r   
isfinishedzMatchInAnyOrder.isfinished   s^    }}$$%%112EFRRD"dmmk&!++c4d"Cr   c                     | j                   s7| j                  r*| j                  j                  d      j                  |       yy)Nnot matched: FT)r   r   r$   append_description_ofr   s     r   r   zMatchInAnyOrder.isnotsurplus"   s8    }}(())55oF\\]abr   c                     t        | j                        D ]%  \  }}|j                  |      s| j                  |=  y | j                  r*| j                  j	                  d      j                  |       y)NTr(   F)	enumerater   r   r   r$   r)   )r   r   indexmatchers       r   r   zMatchInAnyOrder.ismatched)   sg    '6 	NE7t$MM%(	
 $$%%11/BXXY]^r   )__name__
__module____qualname__r   r   r   r   r
   r   boolr   r&   r   r    r   r   r   r      s    9 ,9DL[DY9	9@A @$ @x{ t  t a D r   r   c                        e Zd Zdeee      ddfdZ	 ddee   dee   de	f fdZ
dee   deddfdZd	eddfd
Z xZS )IsSequenceContainingInAnyOrderr   r   Nc                     || _         y r   )r   )r   r   s     r   r   z'IsSequenceContainingInAnyOrder.__init__5   s	     r   r   r   c                     	 t        |      }t        | j                  |      }|D ]  }|j                  |      r y |j	                  |      S # t
        $ r |rt        t        | #  ||       Y yw xY w)NF)	listr   r   r   r&   	TypeErrorsuperr4   describe_mismatch)r   r   r   sequencematchsequenceelement	__class__s         r   r   z&IsSequenceContainingInAnyOrder.matches8   s    	DzH+DMM;OPM# !$,,W5 ! !++H55 	#4dM. 	s   7A A A A10A1c                 (    | j                  ||       y r   )r   )r   r   r   s      r   r:   z0IsSequenceContainingInAnyOrder.describe_mismatchI   s    T/0r   descriptionc                 |    |j                  d      j                  ddd| j                        j                  d       y )Nza sequence over r"   r!   r#   z in any order)r$   r%   r   )r   r@   s     r   describe_toz*IsSequenceContainingInAnyOrder.describe_toL   s3     23??sDMM	

+o
&r   r   )r.   r/   r0   r   r   r   r   r   r
   r1   r   r:   rB   __classcell__)r>   s   @r   r4   r4   4   s~    !'!*!5 !$ ! PTQK7?7L	"1hqk 1 1Y] 1'{ 't 'r   r4   itemsr   c                  ^    g }| D ]  }|j                  t        |              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   r4   )rD   r   r   s      r   contains_inanyorderrG   R   s4    $ H ,T*+,)(33r   N)typingr   r   r   r   r   r   hamcrest.core.base_matcherr	   hamcrest.core.descriptionr
   "hamcrest.core.helpers.wrap_matcherr   hamcrest.core.matcherr   
__author____copyright____license__r   objectr   r4   rG   r2   r   r   <module>rQ      sz    L L 2 1 ; )
-$CL"f "J'[!%= '<4gaj!m 4 4!9M 4r   