U
    ‡i7g¯  ã                   @   s*   d Z ddlmZ G dd„ dƒZdd„ ZdS )z¦Utilities for storing collections of error messages.

.. warning::

    This module is treated as private API.
    Users should not need to use this module directly.
é    )ÚSCHEMAc                   @   s"   e Zd Zdd„ Zedfdd„ZdS )Ú
ErrorStorec                 C   s
   i | _ d S ©N)Úerrors)Úself© r   ú;/tmp/pip-unpacked-wheel-o_a6af_p/marshmallow/error_store.pyÚ__init__   s    zErrorStore.__init__Nc                 C   s<   |t kst|tƒs||i}|d k	r*||i}t| j|ƒ| _d S r   )r   Ú
isinstanceÚdictÚmerge_errorsr   )r   ÚmessagesÚ
field_nameÚindexr   r   r   Ústore_error   s
    zErrorStore.store_error)Ú__name__Ú
__module__Ú__qualname__r	   r   r   r   r   r   r   r      s   r   c                 C   s:  | s|S |s| S t | tƒr\t |tƒr,| | S t |tƒrRt|ftt| | t¡ƒiŽS | |g S t | tƒrôt |tƒrŒt| ftt|  t¡|ƒiŽS t |tƒrØt| ƒ}| ¡ D ],\}}||krÊt|| |ƒ||< q¦|||< q¦|S t| ftt|  t¡|ƒiŽS t |tƒr
| g| S t |tƒr2t|ftt| | t¡ƒiŽS | |gS )z¬Deeply merge two error messages.

    The format of ``errors1`` and ``errors2`` matches the ``message``
    parameter of :exc:`marshmallow.exceptions.ValidationError`.
    )r
   Úlistr   r   r   ÚgetÚitems)Zerrors1Zerrors2r   ÚkeyÚvalr   r   r   r      s4    








r   N)Ú__doc__Zmarshmallow.exceptionsr   r   r   r   r   r   r   Ú<module>   s   