
    e                     v   d dl 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 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e         Zddededee   ef   dee   fdZedeee   ef   dee   fd       Zedeeeee   ef   f   dee   fd       Zededee   fd       Zd Zy)    )AnyMappingTypeVarUnionoverload)described_as)anything)BaseMatcher)AllOf)Description)wrap_matcher)Matcher)StringDescriptionz
Chris RosezCopyright 2011 hamcrest.orgzBSD, see License.txtVc                   `    e Zd Zdedee   ddfdZdedefdZ	de
ddfd	Zded
e
ddfdZd Zy)IsObjectWithPropertyproperty_namevalue_matcherreturnNc                      || _         || _        y N)r   r   )selfr   r   s      E/usr/lib/python3/dist-packages/hamcrest/library/object/hasproperty.py__init__zIsObjectWithProperty.__init__   s    **    itemc                     |yt        || j                        syt        || j                        }| j                  j	                  |      S )NF)hasattrr   getattrr   matches)r   r   values      r   _matcheszIsObjectWithProperty._matches   sF    <tT//0d001!!))%00r   descriptionc                     |j                  d      j                  | j                        j                  d      j                  | j                         y )Nzan object with a property 'z' matching )append_textr   append_description_ofr   )r   r#   s     r   describe_toz IsObjectWithProperty.describe_to"   s@     =>JJ	

+m
$%:%:4;M;M%Nr   mismatch_descriptionc                    ||j                  d       y t        || j                        sI|j                  |      j                  d      j                  | j                        j                  d       y |j                  d      j                  | j                        j                  d       t	        || j                        }| j
                  j                  ||       y )Nzwas Nonez did not have the z	 propertyz	property  )r%   r   r   r&   r   r   describe_mismatch)r   r   r(   r!   s       r   r+   z&IsObjectWithProperty.describe_mismatch'   s    < ,,Z8tT//0 66t<HH$##D$6$67K8P((5KK	

+c
d001,,U4HIr   c                 N    t               }| j                  |       t        |      S r   )r   r'   str)r   ds     r   __str__zIsObjectWithProperty.__str__8   s!    1vr   )__name__
__module____qualname__r-   r   r   r   objectboolr"   r   r'   r+   r/    r   r   r   r      sm    +c +'!* + +1V 1 1O{ Ot O
Jf JK JTX J"r   r   Nnamematchr   c                 D    |
t               }t        | t        |            S )a  Matches if object has a property with a given name whose value satisfies
    a given matcher.

    :param name: The name of the property.
    :param match: Optional matcher to satisfy.

    This matcher determines if the evaluated object has a property with a given
    name. If no such property is found, ``has_property`` is not satisfied.

    If the property is found, its value is passed to a given matcher for
    evaluation. 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.

    If the ``match`` argument is not provided, the
    :py:func:`~hamcrest.core.core.isanything.anything` matcher is used so that
    ``has_property`` is satisfied if a matching property is found.

    Examples::

        has_property('name', starts_with('J'))
        has_property('name', 'Jon')
        has_property('name')

    )r	   r   wrap_shortcut)r6   r7   s     r   has_propertyr:   >   s"    6 }
mE&:;;r   keys_valuematchersc                       y r   r5   r;   s    r   has_propertiesr>   `       r   c                      y r   r5   r=   s    r   r>   r>   f   r?   r   c                       y r   r5   r=   s    r   r>   r>   l   r?   r   c                     t        |       dk(  r-	 | d   j                         }|D ]  }t        ||         ||<    n]t        |       dz  rt	        d      i }t        t        t        |       dz              D ]  }t        | d|z  dz            || d|z     <   ! |j                         D ]  \  }}t        |      ||<    t        |      dkD  rt               j                  d      }t        t        |j                                     D ]Z  \  }\  }}	|j                  |      j                  d      j                  |	       |t        |      dz
  k  sJ|j                  d       \ t        t        |      t        t        |j                               D 	cg c]  \  }}	t!        ||	       c}	}d	d
d      S |j#                         \  }}	t!        ||	      S # t        $ r t	        d      w xY wc c}	}w )aX  Matches if an object has properties satisfying all of a dictionary
    of string property names and corresponding value matchers.

    :param matcher_dict: A dictionary mapping keys to associated value matchers,
        or to expected values for
        :py:func:`~hamcrest.core.core.isequal.equal_to` matching.

    Note that the keys must be actual keys, not matchers. Any value argument
    that is not a matcher is implicitly wrapped in an
    :py:func:`~hamcrest.core.core.isequal.equal_to` matcher to check for
    equality.

    Examples::

        has_properties({'foo':equal_to(1), 'bar':equal_to(2)})
        has_properties({'foo':1, 'bar':2})

    ``has_properties`` also accepts a list of keyword arguments:

    .. function:: has_properties(keyword1=value_matcher1[, keyword2=value_matcher2[, ...]])

    :param keyword1: A keyword to look up.
    :param valueMatcher1: The matcher to satisfy for the value, or an expected
        value for :py:func:`~hamcrest.core.core.isequal.equal_to` matching.

    Examples::

        has_properties(foo=equal_to(1), bar=equal_to(2))
        has_properties(foo=1, bar=2)

    Finally, ``has_properties`` also accepts a list of alternating keys and their
    value matchers:

    .. function:: has_properties(key1, value_matcher1[, ...])

    :param key1: A key (not a matcher) to look up.
    :param valueMatcher1: The matcher to satisfy for the value, or an expected
        value for :py:func:`~hamcrest.core.core.isequal.equal_to` matching.

    Examples::

        has_properties('foo', equal_to(1), 'bar', equal_to(2))
        has_properties('foo', 1, 'bar', 2)

       r   zHsingle-argument calls to has_properties must pass a dict as the argument   z'has_properties requires key-value pairszan object with properties z
 matching z and TF)describe_all_mismatchesdescribe_matcher_in_mismatch)lencopyr9   AttributeError
ValueErrorrangeintitemsr   r%   	enumeratesortedr&   r   r-   r   r:   popitem)
r;   kv_args	base_dictkeyindexr!   r#   ir   property_value_matchers
             r   r>   r>   q   s   \ !#	*1-224I  ?!.y~!>	#? !"Q&FGG	3s#56:;< 	E7D"1u9q=18I(U34	
 mmo .
U&u-	#. 9~')556RS:CF9??K\D]:^ 	16A65--m<HH##$:;3y>A%%''0	1  BH	HYAZ='= !0FG )--2

 
	
 1:0A0A0C--M+ABBM  	Z 	8s   +G G/G,r   ) typingr   r   r   r   r   hamcrestr   hamcrest.corer	   hamcrest.core.base_matcherr
   hamcrest.core.core.allofr   hamcrest.core.descriptionr   "hamcrest.core.helpers.wrap_matcherr   r9   hamcrest.core.matcherr    hamcrest.core.string_descriptionr   
__author____copyright____license__r   r3   r   r-   r:   r>   r5   r   r   <module>rc      s   9 9 ! " 2 * 1 L ) >
-$CL(;v. (V<s <5wqz1)<#= <QW <D 
wqz1})= '#,  

 
wsE'!*a-4H/H'I gVYl  

 
   
YCr   