HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/hamcrest/library/object/__pycache__/hasproperty.cpython-38.pyc
U

�b�Vl�@szddlmZddlmZddlmZddlmZddlm	Z	ddl
mZdZ
dZd	ZGd
d�de�Zdd
d�Zdd�ZdS)�)�BaseMatcher)�anything)�all_of)�StringDescription)�	hasmethod)�wrap_matcherz
Chris RosezCopyright 2011 hamcrest.orgzBSD, see License.txtc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�IsObjectWithPropertycCs||_||_dS�N)�
property_name�
value_matcher)�selfr
r�r
�E/usr/lib/python3/dist-packages/hamcrest/library/object/hasproperty.py�__init__szIsObjectWithProperty.__init__cCs4|dkrdSt||j�sdSt||j�}|j�|�S)NF)�hasattrr
�getattrrZmatches)r�o�valuer
r
r�_matchesszIsObjectWithProperty._matchescCs$|�d��|j��d��|j�dS)Nzan object with a property 'z' matching )�append_textr
Zappend_description_ofr)rZdescriptionr
r
r�describe_tos
���z IsObjectWithProperty.describe_tocCsz|dkr|�d�dSt||j�sD|�|��d��|j��d�dS|�d��|j��d�t||j�}|j�||�dS)Nzwas Nonez did not have the z	 propertyz	property � )rrr
Zappend_valuerr�describe_mismatch)r�itemZmismatch_descriptionrr
r
rr#s

���z&IsObjectWithProperty.describe_mismatchcCst�}|�|�t|�Sr	)rr�str)r�dr
r
r�__str__3s
zIsObjectWithProperty.__str__N)�__name__�
__module__�__qualname__rrrrrr
r
r
rr
s

rNcCs|dkrt�}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')

    N)rr�
wrap_shortcut)�name�matchr
r
r�has_property9sr#cOs�t|�dkrVz*|d��}|D]}t||�||<qWq�tk
rRtd��Yq�XnRt|�drjtd��i}ttt|�d��D]$}t|d|d�||d|<q�|��D]\}}t|�||<q�tdd�|��D��S)aXMatches 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)

    �rzHsingle-argument calls to has_properties must pass a dict as the argument�z'has_properties requires key-value pairscSsg|]\}}t||��qSr
)r#)�.0r
Zproperty_value_matcherr
r
r�
<listcomp>�s�z"has_properties.<locals>.<listcomp>)	�len�copyr �AttributeError�
ValueError�range�int�itemsr)Zkeys_valuematchersZkv_argsZ	base_dict�key�indexrr
r
r�has_propertiesZs"."�r1)N)Zhamcrest.core.base_matcherrZ
hamcrest.corerZhamcrest.core.core.allofrZ hamcrest.core.string_descriptionrZhamcrest.core.helpers.hasmethodrZ"hamcrest.core.helpers.wrap_matcherrr �
__author__Z
__copyright__Z__license__rr#r1r
r
r
r�<module>s,
!