U
    òÀMfð  ã                   @   sl   d dl mZ d dlmZ d dlmZ dZdZdZe	e	dœdd	„Z
G d
d„ dee	 ƒZe	ee	 dœdd„ZdS )é    )ÚBaseMatcher)ÚDescription)ÚMatcherzJon ReidzCopyright 2011 hamcrest.orgzBSD, see License.txt)ÚstringÚreturnc                 C   s@   d}d}| D ]*}|  ¡ r*|s$|d7 }d}q||7 }d}q| ¡ S )NÚ Tú F)ÚisspaceÚstrip)r   ÚresultZlast_was_spaceÚ	character© r   úU/tmp/pip-unpacked-wheel-97nlcpo6/hamcrest/library/text/isequal_ignoring_whitespace.pyÚ
stripspace
   s    r   c                   @   s:   e Zd Zddœdd„Zeedœdd„Zeddœd	d
„ZdS )ÚIsEqualIgnoringWhiteSpaceN)r   c                 C   s&   t |tƒstdƒ‚|| _t|ƒ| _d S )Nz)IsEqualIgnoringWhiteSpace requires string)Ú
isinstanceÚstrÚ	TypeErrorÚoriginal_stringr   Ústripped_string)Úselfr   r   r   r   Ú__init__   s    
z"IsEqualIgnoringWhiteSpace.__init__)Úitemr   c                 C   s   t |tƒsdS | jt|ƒkS )NF)r   r   r   r   )r   r   r   r   r   Ú_matches   s    
z"IsEqualIgnoringWhiteSpace._matches)Údescriptionr   c                 C   s   |  | j¡ d¡ d S )Nz ignoring whitespace)Zappend_description_ofr   Zappend_text)r   r   r   r   r   Údescribe_to$   s    z%IsEqualIgnoringWhiteSpace.describe_to)	Ú__name__Ú
__module__Ú__qualname__r   r   Úboolr   r   r   r   r   r   r   r      s   r   c                 C   s   t | ƒS )a¶  Matches if object is a string equal to a given string, ignoring
    differences in whitespace.

    :param string: The string to compare against as the expected value.

    This matcher first checks whether the evaluated object is a string. If so,
    it compares it with ``string``, ignoring differences in runs of whitespace.

    Example::

        equal_to_ignoring_whitespace("hello world")

    will match ``"hello   world"``.

    )r   )r   r   r   r   Úequal_to_ignoring_whitespace(   s    r    N)Zhamcrest.core.base_matcherr   Zhamcrest.core.descriptionr   Zhamcrest.core.matcherr   Ú
__author__Ú__copyright__Ú__license__r   r   r   r    r   r   r   r   Ú<module>   s   