
    :Qg                      	   d dl Z d dlZ	 d dlmZ dZddlmZm	Z	m
Z
  e j                  d      Zej                  e j                          G d de      Z ej"                  e      Z ej&                  d	       ej(                  e
       ej*                  dddd       ej*                  dddd       ej*                  ddd       ej*                  ddd       ej*                  dd ej,                  g d      d       ej*                  d d!dd"       ej*                  d#d$dd%       ej*                  d&d'dd(       ej*                  d)d*d+       ej*                  d,d-d.d/d01      ej.                  d2                                                                                            Zej3                  d3       ej*                  d4d5g dd67       ej*                  d8d9g dd:7       ej*                  d;d<dd=       ej*                  d>d?d@dA       ej*                  dBdCg  ej,                  dDdEg      ddFG       ej*                  dHdIdJdKg ej,                  g dL      ddMG       ej*                  dNdOdPdQ       ej*                  dRdSdPdT       ej*                  dUdVd@dW       ej*                  dXdYdZd[       ej*                  d\d]d d^       ej*                  d_d`dadb       ej*                  dcdd ej,                  g de      df       ej4                  dg ej6                  dh      i      edj                                                                                                                 Zej3                  dk       ej*                  d4d5g dd67       ej*                  d8d9g dd:7       ej*                  dldmg ddn7       ej*                  dodpdqdr       ej*                  dsdtdPdu       ej*                  dvdwd dx       ej*                  dcdd ej,                  g dy      df       ej4                  dg ej6                  dh      i      edz                                                                       Zy# e$ r dZY vw xY w){    NTF   )__version__read_pdfplotcamelotc                       e Zd Zd Zd Zy)Configc                     i | _         y Nconfig)selfs    H/var/www/html/answerous/venv/lib/python3.12/site-packages/camelot/cli.py__init__zConfig.__init__   s	        c                 "    || j                   |<   y r   r   )r   keyvalues      r   
set_configzConfig.set_config   s     Cr   N)__name__
__module____qualname__r   r    r   r   r	   r	      s    !r   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jsonexcelhtml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                     t               | _        |j                         D ]!  \  }}| j                  j                  ||       # y)z(Camelot: PDF Table Extraction for HumansN)r	   objitemsr   )ctxargskwargsr   r   s        r   clir.       s;    \ hCGlln '
U3&'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%   r0   r   z-shiftz--shift_textlt) r4   rr5   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                 >   | j                   }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }	|j                  d      }
|j                  |       t        |d         }|sd	n||d<   t        |d
         }|sd	n||d
<   t        |d         }|sd	n||d<   t        |d         |d<   |	t        s9t        d      |t        j                  d      |t        j                  d      t        |
f|d|d|}t        j                  d|j                   d       |	)|D ]#  }t        ||	       t        j                          % y	|j                  |||       y	)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/   rC   flavorsuppress_stdoutFound  tableskindfcompressr   popupdatelist_HAS_MPLImportErrorclick
UsageErrorr   echonr   pltshowexport)cr,   r-   confrC   rD   rX   rY   rG   rH   r@   rI   rJ   rK   tablestables                   r   r/   r/   S   s   | 88DHHWEXXhFAxxHHHWE

;'Izz*%H
MM$01M*7d]F?vm,-K(3DF=VK()I&/$YF;| 45F<DEE>""#STT9""#UVViJPF 
JJz)* 	EY'HHJ	 	fH5r   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.)r;   r<   r=   textedgec                    | j                   }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }	|j                  d      }
|j                  |       t        |d         }|sd	n||d<   t        |d
         }|sd	n||d
<   t        |d         }|sd	n||d<   |	t        s9t        d      |t        j                  d      |t        j                  d      t        |
f|d|d|}t        j                  d|j                   d       |	)|D ]#  }t        ||	       t        j                          % y	|j                  |||       y	)z+Use spaces between text to parse the table.rC   rD   rE   rF   rG   rH   r@   rI   NrJ   columnsrM   rN   rO   rk   rP   rS   rT   rU   rW   rZ   )rg   r,   r-   rh   rC   rD   rX   rY   rG   rH   r@   rI   rJ   ro   ri   rj   s                   r   rk   rk      s   j 88DHHWEXXhFAxxHHHWE

;'Izz*%H
MM$01M*7d]F?vm,-K(3DF=6)$%G$+F9DEE>""#STT9""#UVVhIOF 
JJz)* 	EY'HHJ	 	fH5r   )loggingr`   matplotlib.pyplotpyplotrd   r^   r_   r6   r   r   r   	getLoggerloggersetLevelINFOobjectr	   make_pass_decoratorpass_configgroupversion_optionoptionChoicepass_contextr.   commandargumentPathr/   rk   r   r   r   <module>r      s    # H ) ) 
		9	%  !V ! (e''/ )k*dIu3PQ	M	 e\(BCdJ%89	@	A		 dGT0EF	7	 	N	 
 
	= '  G : D R + X' Y
< 
< #T8S 
'	 	sCj	!	M #J	.	/	@ 	T	 
>	 
/	 
(	 	@	 
	5	 	B	C	@	 
4!89&6  : x&6R X
< 
< 	. 	E	 	T	 
?	 	=	>	@	 
4!89%6  : f%6E  Hs   Q> >R	R	