
    SAi;                         S SK r S SKrS SKJr  S SKJr  S SKJrJrJ	r	J
r
JrJr  SSKJr  SSKJrJr  SSKJrJrJr   " S	 S
\5      rg)    N)StringIO)chain)AnyDictListOptionalSetTextIO   )utils)T_obj
T_obj_list)CSV_COLS_REQUIREDCSV_COLS_TO_PREPEND
Serializerc                      \ rS rSr/ SQr\S\\\      4S j5       r	\S\
\\4   4S j5       r S!S\\\      S\
\\4   4S jjrS!S	\\\      SS4S
 jjr\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r      S"S\\   S\\\      S\\\      S\\\      S\\   S\\   S\\   4S jjr      S#S\\   S\\\      S\\   S\\\      S\\\      S\\   4S jjr!S r"g)$	Container   )_rect_edges_curve_edges_edges_objectsreturnc                     [         eNNotImplementedErrorselfs    P/var/www/html/land-ocr/venv/lib/python3.13/site-packages/pdfplumber/container.pypagesContainer.pages       !!    c                     [         er   r   r   s    r    objectsContainer.objects   r#   r$   Nobject_typesc                     [         er   r   )r   r(   s     r    to_dictContainer.to_dict   s
     "!r$   
propertiesc                 r    Uc  U R                   OUnU H   n[        X5      (       d  M  [        X5        M"     g r   )cached_propertieshasattrdelattr)r   r,   propsps       r    flush_cacheContainer.flush_cache   s1    *4*<&&*At  r$   c                 :    U R                   R                  S/ 5      $ )Nrectr&   getr   s    r    rectsContainer.rects"       ||++r$   c                 :    U R                   R                  S/ 5      $ )Nliner7   r   s    r    linesContainer.lines&   r;   r$   c                 :    U R                   R                  S/ 5      $ )Ncurver7   r   s    r    curvesContainer.curves*       ||,,r$   c                 :    U R                   R                  S/ 5      $ )Nimager7   r   s    r    imagesContainer.images.   rD   r$   c                 :    U R                   R                  S/ 5      $ )Ncharr7   r   s    r    charsContainer.chars2   r;   r$   c                 :    U R                   R                  S/ 5      $ )Ntextboxverticalr7   r   s    r    textboxverticalsContainer.textboxverticals6   s    || 1266r$   c                 :    U R                   R                  S/ 5      $ )Ntextboxhorizontalr7   r   s    r    textboxhorizontalsContainer.textboxhorizontals:   s    || 3R88r$   c                 :    U R                   R                  S/ 5      $ )Ntextlineverticalr7   r   s    r    textlineverticalsContainer.textlineverticals>   s    || 2B77r$   c                 :    U R                   R                  S/ 5      $ )Ntextlinehorizontalr7   r   s    r    textlinehorizontalsContainer.textlinehorizontalsB   s    || 4b99r$   c                     [        U S5      (       a  U R                  $ S U R                   5       n[        [	        U6 5      U l        U R                  $ )Nr   c              3   N   #    U  H  n[         R                  " U5      v   M     g 7fr   )r   rect_to_edges.0rs     r    	<genexpr>'Container.rect_edges.<locals>.<genexpr>J   s     E*Q%--a00*   #%)r/   r   r9   listr   )r   rect_edges_gens     r    
rect_edgesContainer.rect_edgesF   sG    4''###E$**E'+E>,B'Cr$   c                     [        U S5      (       a  U R                  $ S U R                   5       n[        [	        U6 5      U l        U R                  $ )Nr   c              3   N   #    U  H  n[         R                  " U5      v   M     g 7fr   )r   curve_to_edgesr`   s     r    rc   (Container.curve_edges.<locals>.<genexpr>R   s     HKq5//22Kre   )r/   r   rB   rf   r   )r   curve_edges_gens     r    curve_edgesContainer.curve_edgesN   sG    4(($$$HDKKH(,UO-D(E   r$   c                     [        U S5      (       a  U R                  $ [        [        [        R
                  U R                  5      5      nXR                  -   U R                  -   U l        U R                  $ )Nr   )	r/   r   rf   mapr   line_to_edger>   rh   ro   )r   
line_edgess     r    edgesContainer.edgesV   sW    4"";;#e00$**=>
",">AQAQ"Q{{r$   c                 `    S[         S[        4S jn[        [        XR                  5      5      $ )Nxr   c                 $    [        U S   S:H  5      $ )Norientationhboolrx   s    r    test(Container.horizontal_edges.<locals>.test`       -(C/00r$   r   r}   rf   filterru   r   r   s     r    horizontal_edgesContainer.horizontal_edges^   +    	1E 	1d 	1 F4,--r$   c                 `    S[         S[        4S jn[        [        XR                  5      5      $ )Nrx   r   c                 $    [        U S   S:H  5      $ )Nrz   vr|   r~   s    r    r   &Container.vertical_edges.<locals>.testg   r   r$   r   r   s     r    vertical_edgesContainer.vertical_edgese   r   r$   streaminclude_attrsexclude_attrs	precisionindentc                     U R                  U5      n[        UUUS9R                  U5      nUc  [        R                  " XS9$ [        R
                  " XUS9  g )Nr   r   r   )r   )r*   r   	serializejsondumpsdump)	r   r   r(   r   r   r   r   data
serializeds	            r    to_jsonContainer.to_jsonl   sZ     ||L)''
 )D/	 	 >::j88IIj8r$   c           
         Uc  [        5       nSnOSnUc'  [        U R                  R                  5       5      S/-   n/ n[	        5       nU R
                  c  U /OU R
                  n	[        UUUS9n
U	 H  nU H  n[        XS-   5      n[        U5      (       d  M#  XzR                  U5      -  nUS   R                  5        VVs/ s H  u  p[        U5      [        Ld  M  UPM     nnnUR                  [	        U5      5      nM     M     [        [        [        [	        U5      [	        [         [        -   5      -
  5      5      -   n[         [        [#        U
R$                  U5      5      -   n[&        R(                  " UUS[&        R*                  SS	9nUR-                  5         UR/                  U5        U(       a!  UR1                  S5        UR3                  5       $ g s  snnf )
NTFannotr   sr   ignore\)
fieldnamesextrasactionquoting
escapechar)r   rf   r&   keyssetr!   r   getattrlenr   itemstypedictunionr   sortedr   r   attr_filtercsv
DictWriterQUOTE_MINIMALwriteheader	writerowsseekread)r   r   r(   r   r   r   	to_stringr   fieldsr!   
serializerpagetobjskr   new_keysnon_req_colscolsws                       r    to_csvContainer.to_csv   s    >ZFII 1 1 34y@L
5**,$**''


 D!tW-t99"6"6t"<<J.21gmmoUodaaPTAToHU#\\#h-8F "  +T3v;%69L%L!MMN.
 
 !4z/E/E|(T#UUNN!%%
 	
	JKKN;;= /  Vs   G
G
)r   r   r   r   )NNNNNN)NNNNN)#__name__
__module____qualname____firstlineno__r.   propertyr   r   r   r!   r   strr   r&   r*   r3   r9   r>   rB   rG   rK   rO   rS   rW   r[   rh   ro   ru   r   r   r
   intr   r   __static_attributes__ r$   r    r   r      s   M"xS	* " " "c:o. " " 37"$T#Y/"	c3h"
!htCy&9 !T ! ,z , , ,z , , -
 - - -
 - - ,z , , 7* 7 7 9J 9 9 8: 8 8 :Z : :  J     !Z ! ! z   .* . . .
 . . $(,0-1-1#' $  tCy)  S	*	
  S	* C=  
#4 $(,0#'-1-17 7 tCy)7 C=	7
  S	*7  S	*7 
#7 7r$   r   )r   r   ior   	itertoolsr   typingr   r   r   r   r	   r
    r   _typingr   r   convertr   r   r   objectr   r   r$   r    <module>r      s1    
    9 9  & G Go or$   