
    j5j\                    v   d Z ddlmZ ddlmZ ddlmZ  G d de      Z G d de      Z	 G d	 d
e	      Z
 G d de	      Z G d de	      Z G d de	      Z G d de	      Z G d de	      Z G d de	      Z G d de	      Z G d de	      Z G d de	      Z G d de      Z G d d e      Z G d! d"e
      Zy#)$zOCRmyPDF's exceptions.    )annotations)IntEnum)dedentc                  D    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZy)ExitCodezOCRmyPDF's exit codes.r                           	   
         N)__name__
__module____qualname____doc__okbad_args
input_filemissing_dependencyinvalid_output_pdffile_access_erroralready_done_ocrchild_process_errorencrypted_pdfinvalid_configpdfa_conversion_failedother_errorctrl_c     I/var/www/html/qr/venv/lib/python3.12/site-packages/ocrmypdf/exceptions.pyr   r      sN      
BHJMNKFr&   r   c                  >     e Zd ZdZej
                  ZdZ fdZ xZ	S )ExitCodeExceptionz>An exception which should return an exit code with sys.exit(). c                r    t         |          }| j                  r| j                  j                  |      S |S )z0Return a string representation of the exception.)super__str__messageformat)self	super_msg	__class__s     r'   r-   zExitCodeException.__str__%   s1    GO%	<<<<&&y11r&   )
r   r   r   r   r   r#   	exit_coder.   r-   __classcell__r2   s   @r'   r)   r)      s     H$$IG r&   r)   c                  (    e Zd ZdZej
                  Zy)BadArgsErrorz-Invalid arguments on the command line or API.N)r   r   r   r   r   r   r3   r%   r&   r'   r7   r7   -   s    7!!Ir&   r7   c                  (    e Zd ZdZej
                  Zy)MissingDependencyErrorz$A third-party dependency is missing.N)r   r   r   r   r   r   r3   r%   r&   r'   r9   r9   3   s    .++Ir&   r9   c                  (    e Zd ZdZej
                  Zy)UnsupportedImageFormatErrorz"The image format is not supported.Nr   r   r   r   r   r   r3   r%   r&   r'   r;   r;   9   s    ,##Ir&   r;   c                  (    e Zd ZdZej
                  Zy)DpiErrorz*Missing information about input image DPI.Nr<   r%   r&   r'   r>   r>   ?   s    4##Ir&   r>   c                  (    e Zd ZdZej
                  Zy)OutputFileAccessErrorz,Cannot access the intended output file path.N)r   r   r   r   r   r   r3   r%   r&   r'   r@   r@   E   s    6**Ir&   r@   c                  (    e Zd ZdZej
                  Zy)PriorOcrFoundErrorzThis file already has OCR.N)r   r   r   r   r   r   r3   r%   r&   r'   rB   rB   K   s    $))Ir&   rB   c                  (    e Zd ZdZej
                  Zy)InputFileErrorz'Something is wrong with the input file.Nr<   r%   r&   r'   rD   rD   Q   s    1##Ir&   rD   c                  (    e Zd ZdZej
                  Zy)SubprocessOutputErrorz*A subprocess returned an unexpected error.N)r   r   r   r   r   r   r3   r%   r&   r'   rF   rF   W   s    4,,Ir&   rF   c                  8    e Zd ZdZej
                  Z ed      Zy)EncryptedPdfErrorzInput PDF is encrypted.a/          Input PDF is encrypted. The encryption must be removed to
        perform OCR.

        For information about this PDF's security use
            qpdf --show-encryption infilename

        You can remove the encryption using
            qpdf --decrypt [--password=[password]] infilename
        N)	r   r   r   r   r   r    r3   r   r.   r%   r&   r'   rH   rH   ]   s    !&&I		Gr&   rH   c                  ,    e Zd ZdZej
                  ZdZy)TesseractConfigErrorz!Tesseract config can't be parsed.z;Error occurred while parsing a Tesseract configuration fileN)r   r   r   r   r   r!   r3   r.   r%   r&   r'   rJ   rJ   o   s    +''IKGr&   rJ   c                       e Zd ZdZ ed      Zy)DigitalSignatureErrorzPDF has a digital signature.zu        Input PDF has a digital signature. OCR would alter the document,
        invalidating the signature.
        Nr   r   r   r   r   r.   r%   r&   r'   rL   rL   v   s    &	Gr&   rL   c                       e Zd ZdZ ed      Zy)TaggedPDFErrorzPDF is tagged.z        This PDF is marked as a Tagged PDF. This often indicates
        that the PDF was generated from an office document and does
        not need OCR. Use --force-ocr, --skip-text or --redo-ocr to
        override this error.
        NrM   r%   r&   r'   rO   rO      s    	Gr&   rO   c                  *     e Zd ZdZdZdd fdZ xZS )ColorConversionNeededErrora  PDF needs color conversion to a standard color space.

    Ghostscript reported a DeviceN colorspace with an inappropriate alternate.
    The resulting PDF/A is liable to render incorrectly (often blank) in some
    viewers such as Adobe Reader, so the colorspace must be normalized to a
    common one. RGB, CMYK, and Gray are known to work; LeaveColorUnchanged
    performs no conversion and UseDeviceIndependentColor does not resolve the
    problem (see https://github.com/ocrmypdf/OCRmyPDF/issues/1187).
    zRGB, CMYK, or Grayc                    t         |           |dk(  rt        d| j                   d      | _        yt        d| d| j                   d      | _        y)zABuild guidance tailored to the conversion strategy that was used.LeaveColorUnchangeda                  The input PDF has an unusual DeviceN color space that cannot be
                represented in PDF/A; the output may appear blank in some viewers
                such as Adobe Reader. Convert it to a common color space with
                --color-conversion-strategy (z), or use
                --output-type pdf to skip PDF/A conversion and retain the original
                color space.
                zR                Color conversion with --color-conversion-strategy
                z did not resolve the input PDF's unusual
                DeviceN color space; the output may appear blank in some viewers
                such as Adobe Reader. Try a different --color-conversion-strategy
                (zz), or use --output-type pdf to skip
                PDF/A conversion and retain the original color space.
                N)r,   __init__r   _effective_strategiesr.   )r0   color_conversion_strategyr2   s     r'   rT   z#ColorConversionNeededError.__init__   sw    $(==!. /3.H.H-I J		DL "*+ , ,,- .	DLr&   )rS   )rV   str)r   r   r   r   rU   rT   r4   r5   s   @r'   rQ   rQ      s     1 r&   rQ   N)r   
__future__r   enumr   textwrapr   r   	Exceptionr)   r7   r9   r;   r>   r@   rB   rD   rF   rH   rJ   rL   rO   rQ   r%   r&   r'   <module>r\      s     "  w &	 "$ ",. ,$"3 $$  $+- +** *$& $-- -) $L, LN 
^ 
' 'r&   