o
    -hV                     @   s   d dl Z d dlZd dlZd dlmZmZ d dlmZmZm	Z	 ed Z
			dde	ee jeef dee dee	ee jf  d	e
d
ef
ddZ				dde	ee jeef dee	ee jf  dee dee	ee jf  d	e
d
ee fddZdS )    N)BufferedReaderBytesIO)LiteralOptionalUnion)defaultprepressprinterebookscreenr   
path_or_fppasswordgs_pathsettingreturnc           
      C   s   |pt dpt dpt d}|d u rtd|ddddd	| g}|r.|d
| g7 }t| ttjfrEd }|tt|  g7 }n| }|dg7 }tj	||rTtj
nd tj
tj
d}||rd| nd \}}	|jrtt|	d t|S )Ngsgswin32cgswin64czyCannot find Ghostscript, which is required for repairs.
Visit https://www.ghostscript.com/ for installation instructions.z-sstdout=%stderrz-o-z-sDEVICE=pdfwritez-dPDFSETTINGS=/z-sPDFPassword=)stdinstdoutstderrzutf-8)shutilwhich	Exception
isinstancestrpathlibPathabsolute
subprocessPopenPIPEcommunicateread
returncodedecoder   )
r   r   r   r   
executablerepair_argsr   procr   r    r*   J/var/www/html/govbot/env/lib/python3.10/site-packages/pdfplumber/repair.py_repair
   sF   	
r,   outfilec                 C   sV   t | |||d}|r)t|d}||  W d    d S 1 s"w   Y  d S |S )N)r   r   wb)r,   openwriter$   )r   r-   r   r   r   repairedfr*   r*   r+   repair?   s   
r3   )NNr   )NNNr   )r   r   r    ior   r   typingr   r   r   T_repair_settingr   r   r,   r3   r*   r*   r*   r+   <module>   sJ    
7