o
    jb                     @   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 		ddee	e j
eef dee	 deee	e j
f  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e f
ddZdS )    N)BufferedReaderBytesIO)OptionalUnion
path_or_fppasswordgs_pathreturnc                 C   s   |pt dpt dpt d}|d u rtd|ddddg}|r*|d	| g7 }t| ttjfrAd }|tt|  g7 }n| }|dg7 }tj	||rPtj
nd tj
tj
d
|r^| nd \}}t|rot|d t|S )Ngsgswin32cgswin64czyCannot find Ghostscript, which is required for repairs.
Visit https://www.ghostscript.com/ for installation instructions.z-o-z-sDEVICE=pdfwritez-dPDFSETTINGS=/prepressz-sPDFPassword=)stdinstdoutstderrzutf-8)shutilwhich	Exception
isinstancestrpathlibPathabsolute
subprocessPopenPIPEcommunicatereadlendecoder   )r   r   r   
executablerepair_argsr   r   r    r"   W/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/pdfplumber/repair.py_repair   sF   
r$   outfilec                 C   sT   t | ||d}|r(t|d}||  W d    d S 1 s!w   Y  d S |S )N)r   wb)r$   openwriter   )r   r%   r   r   repairedfr"   r"   r#   repair9   s   
r+   )NN)NNN)r   r   r   ior   r   typingr   r   r   r   r$   r+   r"   r"   r"   r#   <module>   s<    
3