U
    ~da                     @   sd  d dl mZmZmZmZmZmZmZ ddlm	Z	 e	  d dl
mZ d dlmZmZ d dlmZ d dlmZ zd dlZW n& ek
r Z zdZW 5 dZ[X Y nX dd	lmZ dd
lmZmZmZmZ G dd deZG dd deZG dd deZ G dd de!Z"e#e$e%eeeeee&e'ej(ej)ej*eehZ+G dd deZ,G dd de,e-Z.G dd de,e!Z"dS )    )nested_scopes
generatorsdivisionabsolute_importwith_statementprint_functionunicode_literals   )backport)
native_str)datedatetime)Decimal)NumberN)Model)qualified_namecollectionscollections_abc	Generatorc                   @   s   e Zd ZdS )ValidationErrorN__name__
__module____qualname__ r   r   J/var/www/html/myproject/myenv/lib/python3.8/site-packages/serial/errors.pyr      s   r   c                   @   s   e Zd ZdS )VersionErrorNr   r   r   r   r   r      s   r   c                   @   s   e Zd ZdS )DefinitionExistsErrorNr   r   r   r   r   r       s   r   c                   @   s   e Zd ZdS UnmarshalValueErrorNr   r   r   r   r   r   %   s   r   c                       st   e Zd ZdddZedd Zejdd Zedd Zejd	d Zed
d Zejdd Z fddZ	  Z
S )UnmarshalErrorNc                 C   sn  d| _ d| _d| _d| _dg}d}|r,d}n|r:d}|}n|rFd}|}g }t| d}t|dkrx||d  n"|d |D ]}	|d	|	  q|dkr|d
 n
|d |dd	|  |dkrt
}d}dg}
|D ]T}t|trt|f}nt|d}|D ]}	|
d	|	  q|
d  d7  < q|
d |d|d	|
f  d	|| _dS )z
        Generate a comprehensible error message for data which could not be un-marshalled according to spec, and raise
        the appropriate exception
        N types
item_typesvalue_types
r	   r   z     z@The data provided is not an instance of an un-marshallable type:zWThe data provided does not match any of the expected types and/or property definitions:z - data: %szun-marshallable types(,z   )z	 - %s: %s)_message
_parameter_index_keyreprstripsplitlenappendjoinUNMARSHALLABLE_TYPES
isinstancetyper   message)selfdatar"   r#   r$   Zerror_message_linesZtypes_labelZ
data_lineslineslineZtypes_linestype_r   r   r   __init__4   sb    

zUnmarshalError.__init__c                 C   s   | j S N)r*   r7   r   r   r   	paramater   s    zUnmarshalError.paramaterc                 C   s   || j kr|| _|   d S r=   )r?   r*   assemble_message)r7   Zparamater_namer   r   r   r?      s    
c                 C   s   | j S r=   r)   r>   r   r   r   r6      s    zUnmarshalError.messagec                 C   s   || j kr|| _|   d S r=   )r6   r)   r@   )r7   message_textr   r   r   r6      s    
c                 C   s   | j S r=   rA   r>   r   r   r   index   s    zUnmarshalError.indexc                 C   s   || j kr|| _|   d S r=   )rC   r+   r@   )r7   Zindex_or_keyr   r   r   rC      s    
c                    s`   g }| j r|d| j   | jd k	r8|dt| j  | jrJ|| j t d| d S )Nz2Errors encountered in attempting to un-marshal %s:zEErrors encountered in attempting to un-marshal the value at index %s:r%   )r?   r1   rC   r-   r6   superr<   r2   )r7   messages	__class__r   r   r@      s    
zUnmarshalError.assemble_message)NNN)r   r   r   r<   propertyr?   setterr6   rC   r@   __classcell__r   r   rF   r   r    2   s"      
c





r    c                   @   s   e Zd ZdS )UnmarshalTypeErrorNr   r   r   r   r   rK      s   rK   c                   @   s   e Zd ZdS r   r   r   r   r   r   r      s   )/
__future__r   r   r   r   r   r   r   Zutilities.compatibilityr
   Zfuture.utilsr   r   r   decimalr   numbersr   typingImportErroreZ	abc.modelr   Z	utilitiesr   r   r   r   	Exceptionr   AttributeErrorr   r   
ValueErrorr   tuplestrbytesbooldictOrderedDictSetSequencer3   r    	TypeErrorrK   r   r   r   r   <module>   sH   $           