B
    νΉ`έ  γ               @   s  d dl mZ d dlmZ G dd dej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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G d+d, d,eZG d-d. d.eZG d/d0 d0eZd1S )2ι    )Ϊ
exceptions)Ϊ
SetupErrorc                   s   e Zd Z fddZ  ZS )ΪCannotReReadErrorc                s"   t   |d| dd| ‘ d S )NzCannot re-open (z) to read db datazThe error is: )ΪsuperΪ__init__)ΪselfΪfilenameΪlinenoΪexp)Ϊ	__class__© ϊd/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/pgwui_bulk_upload/exceptions.pyr      s    
zCannotReReadError.__init__)Ϊ__name__Ϊ
__module__Ϊ__qualname__r   Ϊ__classcell__r   r   )r   r   r      s   r   c                   s   e Zd Z fddZ  ZS )ΪNotAZipfileErrorc                s   t   dd| d‘ d S )NzNo zip file uploadedzThe uploaded file (z!) is not recognized as a zip file)r   r   )r   r   )r   r   r   r   (   s    zNotAZipfileError.__init__)r   r   r   r   r   r   r   )r   r   r   '   s   r   c                   s   e Zd Z fddZ  ZS )ΪCannotUnarchiveErrorc                s   t   dd| d‘ d S )NzCannot unzipzThe uploaded file (z0) cannot be unzipped, the error reported is: err)r   r   )r   r   Ϊerr)r   r   r   r   /   s    zCannotUnarchiveError.__init__)r   r   r   r   r   r   r   )r   r   r   .   s   r   c                   s   e Zd Z fddZ  ZS )ΪNotADirectoryErrorc                s"   t   dd| d| dd‘ d S )NzNot a directoryzThe uploaded file (z) has a top-level entry (z) that is not a directoryz:The entries at the top of the zip file must be directories)r   r   )r   r   Ϊname)r   r   r   r   7   s    zNotADirectoryError.__init__)r   r   r   r   r   r   r   )r   r   r   6   s   r   c                   s   e Zd Z fddZ  ZS )ΪEmptyArchiveErrorc                s   t   dd| d‘ d S )NzEmpty zip filezThe uploaded file (z) has no content)r   r   )r   r   r   )r   r   r   r   @   s    zEmptyArchiveError.__init__)r   r   r   r   r   r   r   )r   r   r   ?   s   r   c                   s   e Zd Z fddZ  ZS )ΪNotAFileErrorc                s"   t   dd| d| dd‘ d S )Nz
Not a filezThe uploaded file (z) has a 2nd-level entry (z) that is not a filez6The directories in the zip file may only contain files)r   r   )r   r   r   )r   r   r   r   G   s    zNotAFileError.__init__)r   r   r   r   r   r   r   )r   r   r   F   s   r   c                   s   e Zd Z fddZ  ZS )ΪNoMapfileErrorc                s"   t   dd| d| dd‘ d S )NzMissing map filezThe map file (z") not found in the uploaded file (ϊ)zXThe directories in the zip file must contain a file which maps file names to table names)r   r   )r   r   Ϊmap_file)r   r   r   r   P   s    zNoMapfileError.__init__)r   r   r   r   r   r   r   )r   r   r   O   s   r   c                   s   e Zd Z fddZ  ZS )ΪCannotReadErrorc                s    t   d| dd| ‘ d S )NzCannot open (z) for readingzThe error is: )r   r   )r   r   r
   )r   r   r   r   Z   s    
zCannotReadError.__init__)r   r   r   r   r   r   r   )r   r   r   Y   s   r   c                   s   e Zd Z fddZ  ZS )ΪCannotRollbackErrorc                s   t   ddd| d‘ d S )Nz(Cannot roll back the current transactionzxThe transaction has failed and must roll back before the database can again be queried about relations and their columnszThe error from psycopg2 is: (r   )r   r   )r   r
   )r   r   r   r   a   s    zCannotRollbackError.__init__)r   r   r   r   r   r   r   )r   r   r   `   s   r   c               @   s   e Zd ZdS )ΪBadMapFileErrorN)r   r   r   r   r   r   r   r   j   s   r   c                   s   e Zd Z fddZ  ZS )ΪBadMapfileYAMLErrorc          	      s&   t   dd| d| d| d‘ d S )NzBad YAML in map filezThe map file (z) in the uploaded file (z) cannot be parsed as YAML: zhThe directories in the zip file must contain a map file in YAML format to maps file names to table names)r   r   )r   r   r   r
   )r   r   r   r   o   s    zBadMapfileYAMLError.__init__)r   r   r   r   r   r   r   )r   r   r   n   s   r   c                   s   e Zd Z fddZ  ZS )ΪNoMapListErrorc                s   t   d| dd‘ d S )Nz$Missing "map_list" tag in map file (r   z8The map file does not have "map_list" as a top-level tag)r   r   )r   r   )r   r   r   r   y   s    
zNoMapListError.__init__)r   r   r   r   r   r   r   )r   r   r    x   s   r    c                   s   e Zd Z fddZ  ZS )ΪBadMapListErrorc                s   t   d| dd‘ d S )Nz The "map_list" tag in map file (z) is not a listz7The map file does not have a list in the "map_list" tag)r   r   )r   r   )r   r   r   r      s    
zBadMapListError.__init__)r   r   r   r   r   r   r   )r   r   r!      s   r!   c                   s   e Zd Z fddZ  ZS )ΪBadMapListEntryErrorc                s"   t   d| dd| d‘ d S )Nz The "map_list" tag of map file (z&) contains an entry which is not a mapzThe list item (z) is not a map)r   r   )r   r   Ϊitem)r   r   r   r      s    
zBadMapListEntryError.__init__)r   r   r   r   r   r   r   )r   r   r"      s   r"   c                   s   e Zd Z fddZ  ZS )ΪMustBeStringErrorc          
      s.   t   d| dd| d| d| d‘ d S )Nz The "map_list" tag of map file (z&) contains a map with an invalid valuezThe value (z
) of key (z) of map_list item number z is not a string)r   r   )r   r   ΪcountΪkeyΪvalue)r   r   r   r      s    
zMustBeStringError.__init__)r   r   r   r   r   r   r   )r   r   r$      s   r$   c                   s   e Zd Z fddZ  ZS )ΪMissingMapListTagErrorc                s&   t   d| dd| d| ‘ d S )Nz The "map_list" tag of map file (z') contains a map missing a required tagz	The tag (z') is missing from map_list item number )r   r   )r   r   r%   r&   )r   r   r   r      s    
zMissingMapListTagError.__init__)r   r   r   r   r   r   r   )r   r   r(      s   r(   c                   s   e Zd Z fddZ  ZS )ΪExtraMapListTagErrorc                s&   t   d| dd| d| ‘ d S )Nz The "map_list" tag of map file (z$) contains a map with an unknown tagz	The tag (z,) is not recognized in map_list item number )r   r   )r   r   r%   r&   )r   r   r   r       s    
zExtraMapListTagError.__init__)r   r   r   r   r   r   r   )r   r   r)      s   r)   c                   s   e Zd Z fddZ  ZS )ΪBadTrimValueErrorc                s&   t   d| dd| d| ‘ d S )Nz The "map_list" tag of map file (zH) contains a map with a file_map value that has a non-boolean trim valuez(The trim value must be a YAML boolean, (z0) was supplied for trim in map_list item number )r   r   )r   r   r%   r'   )r   r   r   r   ©   s    
zBadTrimValueError.__init__)r   r   r   r   r   r   r   )r   r   r*   ¨   s   r*   c                   s   e Zd Z fddZ  ZS )ΪMissingFileMapTagErrorc                s&   t   d| dd| d| ‘ d S )Nz The "map_list" tag of map file (z0) contains a file_map map missing a required tagz	The tag (z') is missing from map_list item number )r   r   )r   r   r%   r&   )r   r   r   r   ²   s    
zMissingFileMapTagError.__init__)r   r   r   r   r   r   r   )r   r   r+   ±   s   r+   c                   s   e Zd Z fddZ  ZS )ΪExtraFileMapTagErrorc                s&   t   d| dd| d| ‘ d S )Nz The "map_list" tag of map file (z-) contains a file_map map with an unknown tagz	The tag (z,) is not recognized in map_list item number )r   r   )r   r   r%   r&   )r   r   r   r   Ί   s    
zExtraFileMapTagError.__init__)r   r   r   r   r   r   r   )r   r   r,   Ή   s   r,   c                   s   e Zd Z fddZ  ZS )ΪDuplicateMappingErrorc                s4   t   d| dd| d| d| d| d	‘ d S )Nz The "map_list" tag of map file (z) specifies duplicate uploadszThe list entries z and z both upload file (z) into relation (r   )r   r   )r   r   Zpos0Zpos1ΪfileZrelation)r   r   r   r   Γ   s    
zDuplicateMappingError.__init__)r   r   r   r   r   r   r   )r   r   r-   Β   s   r-   c                   s   e Zd Z fddZ  ZS )ΪMissingFileErrorc                s"   t   d| dd| d‘ d S )Nz The "map_list" tag of map file (z3) references a file not in the zip file's directoryzMissing file (r   )r   r   )r   r   r#   )r   r   r   r   Μ   s    
zMissingFileError.__init__)r   r   r   r   r   r   r   )r   r   r/   Λ   s   r/   c                   s   e Zd Z fddZ  ZS )ΪExtraFileErrorc                s"   t   d| dd| d‘ d S )Nz$The "map_list" tag of the map file (z6) does not contain an entry for a file in the zip filezExtra file (r   )r   r   )r   r   Z	extrafile)r   r   r   r   Τ   s    
zExtraFileError.__init__)r   r   r   r   r   r   r   )r   r   r0   Σ   s   r0   N)Z
pgwui_corer   Zcore_exZpgwui_core.exceptionsr   ZDataLineErrorr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r$   r(   r)   r*   r+   r,   r-   r/   r0   r   r   r   r   Ϊ<module>   s0   
		


					