o
    QDi`                     @  s   d dl mZ d dlmZmZ d dlZddlmZ ddlm	Z	 er&ddl
mZ ejd	d
dG dd de	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G dd de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dS )     )annotations)TYPE_CHECKINGAnyN   )FrictionlessException   )RowError)RowTF)kw_onlyreprc                   @  sr   e Zd ZU dZdZdZdZdZg dZde	d< 	 de	d< 	 de	d	< 	 e
dddZdddiddiddidiZdS )	CellErrorz_Cell error representation.

    A base class for all the errors related to the cell value.
    z
cell-errorz
Cell Error)z#tablez#rowz#cellstrcell
field_nameintfield_numberrowr	   notec             	   C  sj   t |jddD ]%\}}||kr,|| }dd }| |tt||j|jt|||d  S qtd| d)zCreate and error from a cell

        Parameters:
            row (Row): row
            note (str): note
            field_name (str): field name

        Returns:
            CellError: error
        r   )startc                 S  s   | d urt | S dS )N )r   )v r   Q/var/www/Datamplify/venv/lib/python3.10/site-packages/frictionless/errors/cell.py<lambda>=   s    z$CellError.from_row.<locals>.<lambda>)r   cells
row_numberr   r   r   zField z is not in the row)	enumeratefield_nameslistmapr   r   r   r   )clsr   r   r   r   namer   to_strr   r   r   from_row,   s   
zCellError.from_row
propertiestypestringinteger)r   	fieldNamefieldNumberN)r   r	   r   r   r   r   )__name__
__module____qualname____doc__r%   titledescriptiontemplatetags__annotations__classmethodr#   metadata_profile_patchr   r   r   r   r      s*   
 r   c                   @     e Zd ZdZdZdZdZdS )ExtraCellErrorz
extra-cellz
Extra CellzThis row has more values compared to the header row (the first row in the data source). A key concept is that all the rows in tabular data must have the same number of columns.zURow at position "{rowNumber}" has an extra value in field at position "{fieldNumber}"Nr*   r+   r,   r%   r.   r/   r0   r   r   r   r   r6   S   
    r6   c                   @  r5   )MissingCellErrorzmissing-cellzMissing CellzThis row has less values compared to the header row (the first row in the data source). A key concept is that all the rows in tabular data must have the same number of columns.zcRow at position "{rowNumber}" has a missing cell in field "{fieldName}" at position "{fieldNumber}"Nr7   r   r   r   r   r9   Z   r8   r9   c                   @  r5   )	TypeErrorz
type-errorz
Type ErrorzCThe value does not match the schema type and format for this field.zpType error in the cell "{cell}" in row "{rowNumber}" and field "{fieldName}" at position "{fieldNumber}": {note}Nr7   r   r   r   r   r:   a   r8   r:   c                   @  r5   )ConstraintErrorzconstraint-errorzConstraint Errorz/A field value does not conform to a constraint.zThe cell "{cell}" in row at position "{rowNumber}" and field "{fieldName}" at position "{fieldNumber}" does not conform to a constraint: {note}Nr7   r   r   r   r   r;   h   r8   r;   c                   @  r5   )UniqueErrorzunique-errorzUnique ErrorzWThis field is a unique field but it contains a value that has been used in another row.zxRow at position "{rowNumber}" has unique constraint violation in field "{fieldName}" at position "{fieldNumber}": {note}Nr7   r   r   r   r   r<   o   r8   r<   c                   @  r5   )TruncatedValueErrorztruncated-valuezTruncated Valuez The value is possible truncated.sThe cell {cell} in row at position {rowNumber} and field {fieldName} at position {fieldNumber} has an error: {note}Nr7   r   r   r   r   r=   v   r8   r=   c                   @  r5   )ForbiddenValueErrorzforbidden-valuezForbidden ValuezThe value is forbidden.r>   Nr7   r   r   r   r   r?   }   r8   r?   c                   @  r5   )SequentialValueErrorzsequential-valuezSequential ValuezThe value is not sequential.r>   Nr7   r   r   r   r   r@      r8   r@   c                   @  r5   )AsciiValueErrorzascii-valuezAscii Valuez'The cell contains non-ascii characters.r>   Nr7   r   r   r   r   rA      r8   rA   )
__future__r   typingr   r   attrs	exceptionr   r   r   tabler	   definer   r6   r9   r:   r;   r<   r=   r?   r@   rA   r   r   r   r   <module>   s$    D