o
    (]^ð  ã                   @   sp   d dl mZ d dlmZ d dlmZ dZdZdZde	de	fd	d
„Z
G dd„ dee	 ƒZde	dee	 f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   ÚresultÚlast_was_spaceÚ	character© r   úS/usr/lib/python3/dist-packages/hamcrest/library/text/isequal_ignoring_whitespace.pyÚ
stripspace
   s   r   c                   @   s:   e Zd Zddd„Zdedefdd„Zdeddfd	d
„ZdS )ÚIsEqualIgnoringWhiteSpacer   Nc                 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__Úitemc                 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Údescriptionc                 C   s   |  | j¡ d¡ d S )Nz ignoring whitespace)Úappend_description_ofr   Úappend_text)r   r   r   r   r   Údescribe_to$   s   z%IsEqualIgnoringWhiteSpace.describe_to)r   N)	Ú__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)Úhamcrest.core.base_matcherr   Úhamcrest.core.descriptionr   Úhamcrest.core.matcherr   Ú
__author__Ú__copyright__Ú__license__r   r   r   r#   r   r   r   r   Ú<module>   s    