o
    j                      @   sb  d dl Z d dlZzd dlmZ W n ey   dZY nw dZddlmZm	Z	m
Z
 e dZee j G dd deZeeZejdd	ejed
ejdddddejdddddejddddejddddejddeg dddejd d!dd"dejd#d$dd%dejd&d'dd(dejd)d*d+dejd,d-d.d/d0d1ejd2d3 Zed4ejd5d6g dd7d8ejd9d:g dd;d8ejd<d=dd>dejd?d@dAdBdejdCdDg edEdFgddGdHejdIdJdKdLgeg dMddNdHejdOdPdQdRdejdSdTdQdUdejdVdWdAdXdejdYdZd[d\dejd]d^d d_dejd`dadbdcdejdddeeg dfdgdejdhejddidjedkd4 Zedlejd5d6g dd7d8ejd9d:g dd;d8ejdmdng ddod8ejdpdqdrdsdejdtdudQdvdejdwdxd dydejdddeeg dzdgdejdhejddidjed{dl ZdS )|    NFT   )__version__read_pdfplotcamelotc                   @   s   e Zd Zdd Zdd ZdS )Configc                 C   s
   i | _ d S Nconfig)self r   Q/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/camelot/cli.py__init__   s   
zConfig.__init__c                 C   s   || j |< d S r   r	   )r   keyvaluer   r   r   
set_config   s   zConfig.set_configN)__name__
__module____qualname__r   r   r   r   r   r   r      s    r   )name)versionz-qz--quietzSuppress logs and warnings.)is_flaghelpz-pz--pages1z?Comma-separated page numbers. Example: 1,3,4 or 1,4-end or all.)defaultr   z-pwz
--passwordzPassword for decryption.)r   z-oz--outputzOutput file path.z-fz--format)csvexcelhtmljsonmarkdownsqlitezOutput file format.)typer   z-zz--zipzCreate ZIP archive.z-splitz--split_textz,Split text that spans across multiple cells.z-flagz--flag_sizez@Flag text based on font size. Useful to detect super/subscripts.z-stripz--strip_textzOCharacters that should be stripped from a string before assigning it to a cell.z-Mz	--margins   )g      ?g      ?g?z2PDFMiner char_margin, line_margin and word_margin.)nargsr   r   c                 O   s,   t  | _| D ]\}}| j|| qdS )z(Camelot: PDF Table Extraction for HumansN)r   objitemsr   )ctxargskwargsr   r   r   r   r   cli    s   .r)   latticez-Rz--table_regionszbPage regions to analyze. Example: x1,y1,x2,y2 where x1, y1 -> left-top and x2, y2 -> right-bottom.)r   multipler   z-Tz--table_areaszaTable areas to process. Example: x1,y1,x2,y2 where x1, y1 -> left-top and x2, y2 -> right-bottom.z-backz--process_backgroundzProcess background lines.z-scalez--line_scale   zOLine size scaling factor. The larger the value, the smaller the detected lines.z-copyz--copy_texthvz?Direction in which text in a spanning cell will be copied over.)r   r!   r+   r   z-shiftz--shift_textlt) r/   rr0   bz5Direction in which text in a spanning cell will flow.z-lz
--line_tol   zFTolerance parameter used to merge close vertical and horizontal lines.z-jz--joint_tolzaTolerance parameter used to decide whether the detected lines and points lie close to each other.z-blockz--threshold_blocksizezFor adaptive thresholding, size of a pixel neighborhood that is used to calculate a threshold value for the pixel. Example: 3, 5, 7, and so on.z-constz--threshold_constantzFor adaptive thresholding, constant subtracted from the mean or weighted mean. Normally, it is positive but may be zero or negative as well.z-Iz--iterationsz5Number of times for erosion/dilation will be applied.z-resz--resolutioni,  z*Resolution used for PDF to PNG conversion.z-plotz--plot_type)textgridcontourjointlinez5Plot elements found on PDF page for visual debugging.filepath)exists)r!   c                 O   s^  | j }|d}|d}|d}|d}|d}|d}	|d}
|| t|d }|s5d	n||d< t|d
 }|sCd	n||d
< t|d }|sQd	n||d< t|d |d< |	d	urhtsgtdn|d	u rqtd|d	u rztdt|
f|d|d|}t	d|j
 d |	d	ur|D ]}t||	d t  qd	S |j|||d d	S )z*Use lines between text to parse the table.pagesoutputformatzipquiet	plot_typer;   table_regionsNtable_areas	copy_text
shift_text$matplotlib is required for plotting..Please specify output file path using --output0Please specify output file format using --formatr*   r=   flavorsuppress_stdoutFound  tableskindfcompressr
   popupdatelist_HAS_MPLImportErrorclick
UsageErrorr   echonr   pltshowexport)cr'   r(   confr=   r>   rR   rS   rA   rB   r;   rC   rD   rE   tablestabler   r   r   r*   S   sL   ^










streamz-Cz	--columnsz#X coordinates of column separators.z-ez
--edge_tol2   z7Tolerance parameter for extending textedges vertically.z-rz	--row_tolzFTolerance parameter used to combine text vertically, to generate rows.z-cz--column_tolzKTolerance parameter used to combine text horizontally, to generate columns.)r6   r7   r8   textedgec                 O   sN  | j }|d}|d}|d}|d}|d}|d}	|d}
|| t|d }|s5d	n||d< t|d
 }|sCd	n||d
< t|d }|sQd	n||d< |	d	ur`ts_tdn|d	u ritd|d	u rrtdt|
f|d|d|}t	d|j
 d |	d	ur|D ]}t||	d t  qd	S |j|||d d	S )z+Use spaces between text to parse the table.r=   r>   r?   r@   rA   rB   r;   rC   NrD   columnsrG   rH   rI   re   rJ   rM   rN   rO   rQ   rT   )ra   r'   r(   rb   r=   r>   rR   rS   rA   rB   r;   rC   rD   rh   rc   rd   r   r   r   re      sJ   5










)loggingrZ   matplotlib.pyplotpyplotr^   rY   rX   r1   r   r   r   	getLoggerloggersetLevelINFOobjectr   make_pass_decoratorpass_configgroupversion_optionoptionChoicepass_contextr)   commandargumentPathr*   re   r   r   r   r   <module>   s~  



"() 