U
    ôbÛV¹  ã                   @   sp   d Z dZdZddlmZ ddlmZ ddlmZ ddl	m
Z
 G dd	„ d	eƒZG d
d„ deƒZdd„ Zdd„ ZdS )zJon ReidzCopyright 2011 hamcrest.orgzBSD, see License.txté    )ÚBaseMatcher)Úall_of)Ú	hasmethod)Úwrap_matcherc                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚIsSequenceContainingc                 C   s
   || _ d S ©N)Úelement_matcher)Úselfr   © r
   úS/usr/lib/python3/dist-packages/hamcrest/library/collection/issequence_containing.pyÚ__init__   s    zIsSequenceContaining.__init__c                 C   s>   z"|D ]}| j  |¡r W dS qW n tk
r8   Y dS X d S )NTF)r   ÚmatchesÚ	TypeError)r	   ÚsequenceÚitemr
   r
   r   Ú_matches   s    zIsSequenceContaining._matchesc                 C   s   |  d¡ | j¡ d S )Nza sequence containing )Zappend_textZappend_description_ofr   ©r	   Zdescriptionr
   r
   r   Údescribe_to   s    
ÿz IsSequenceContaining.describe_toN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r
   r
   r
   r   r      s   r   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚIsSequenceContainingEveryc                 G   s   dd„ |D ƒ}t |Ž | _d S )Nc                 S   s   g | ]}t |ƒ‘qS r
   )Úhas_item)Ú.0Úer
   r
   r   Ú
<listcomp>$   s     z6IsSequenceContainingEvery.__init__.<locals>.<listcomp>)r   Úmatcher)r	   Zelement_matchersZ	delegatesr
   r
   r   r   #   s    z"IsSequenceContainingEvery.__init__c                 C   s.   z| j  t|ƒ¡W S  tk
r(   Y dS X d S )NF)r   r   Úlistr   )r	   r   r
   r
   r   r   '   s    z"IsSequenceContainingEvery._matchesc                 C   s   | j  ||¡ d S r   )r   Údescribe_mismatch)r	   r   Zmismatch_descriptionr
   r
   r   r   -   s    z+IsSequenceContainingEvery.describe_mismatchc                 C   s   | j  |¡ d S r   )r   r   r   r
   r
   r   r   0   s    z%IsSequenceContainingEvery.describe_toN)r   r   r   r   r   r   r   r
   r
   r
   r   r   !   s   r   c                 C   s   t t| ƒƒS )a   Matches if any element of sequence satisfies a given matcher.

    :param match: The matcher to satisfy, or an expected value for
        :py:func:`~hamcrest.core.core.isequal.equal_to` matching.

    This matcher iterates the evaluated sequence, searching for any element
    that satisfies a given matcher. If a matching element is found,
    ``has_item`` is satisfied.

    If the ``match`` argument is not a matcher, it is implicitly wrapped in an
    :py:func:`~hamcrest.core.core.isequal.equal_to` matcher to check for
    equality.

    )r   r   )Úmatchr
   r
   r   r   5   s    r   c                  G   s$   g }| D ]}|  t|ƒ¡ qt|Ž S )aò  Matches if all of the given matchers are satisfied by any elements of
    the sequence.

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

    This matcher iterates the given matchers, searching for any elements in the
    evaluated sequence that satisfy them. If each matcher is satisfied, then
    ``has_items`` 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   )ÚitemsZmatchersr   r
   r
   r   Ú	has_itemsG   s    r"   N)Ú
__author__Z__copyright__Z__license__Zhamcrest.core.base_matcherr   Zhamcrest.core.core.allofr   Zhamcrest.core.helpers.hasmethodr   Z"hamcrest.core.helpers.wrap_matcherr   r   r   r   r"   r
   r
   r
   r   Ú<module>   s   