o
    (]^1  ã                   @   s¦   d dl 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 dlmZ dZdZd	Zed
ƒ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 )é    )ÚSequenceÚTypeVarÚUnion)ÚBaseMatcher)Úany_of)ÚDescription)Úwrap_matcher)ÚMatcherzJon ReidzCopyright 2011 hamcrest.orgzBSD, see License.txtÚTc                   @   sJ   e Zd Zdee ddfdd„Zdee defdd„Zd	e	ddfd
d„Z
dS )ÚIsSequenceOnlyContainingÚmatcherÚreturnNc                 C   s
   || _ d S )N)r   )Úselfr   © r   úW/usr/lib/python3/dist-packages/hamcrest/library/collection/issequence_onlycontaining.pyÚ__init__   s   
z!IsSequenceOnlyContaining.__init__Úitemc                 C   sT   zt |ƒ}t|ƒdkrW dS |D ]}| j |¡s W dS qW dS  ty)   Y dS w )Nr   FT)ÚlistÚlenr   ÚmatchesÚ	TypeError)r   r   ÚsequenceÚelementr   r   r   Ú_matches   s   ÿÿz!IsSequenceOnlyContaining._matchesÚdescriptionc                 C   s   |  d¡ | j¡ d S )Nz%a sequence containing items matching )Úappend_textÚappend_description_ofr   )r   r   r   r   r   Údescribe_to    s   
ÿz$IsSequenceOnlyContaining.describe_to)Ú__name__Ú
__module__Ú__qualname__r	   r
   r   r   Úboolr   r   r   r   r   r   r   r      s    r   Úitemsr   c                  G   s(   g }| D ]	}|  t|ƒ¡ qtt|Ž ƒS )aò  Matches if each element of sequence satisfies any of the given matchers.

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

    This matcher iterates the evaluated sequence, confirming whether each
    element satisfies any of the given matchers.

    Example::

        only_contains(less_than(4))

    will match ``[3,1,2]``.

    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   r   )r"   Úmatchersr   r   r   r   Úonly_contains&   s   r%   N)Útypingr   r   r   Úhamcrest.core.base_matcherr   Úhamcrest.core.core.anyofr   Úhamcrest.core.descriptionr   Ú"hamcrest.core.helpers.wrap_matcherr   Úhamcrest.core.matcherr	   Ú
__author__Ú__copyright__Ú__license__r
   r   r%   r   r   r   r   Ú<module>   s    *