
    ,h7              	       \   U d Z dZdZddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZmZmZmZmZmZmZmZmZ 	 dd
lmZ ddlmZmZmZ eeeeef   eeeef   eeeef   f   Z ee!d<   eeeeeeef   Z"ee!d<   eZ#ee$e#f   Z%dZ&dZ'dZ(dZ)de*de*de*fdZ+dQde#dee,   de*fdZ-de#de*fdZ.de#de/fdZ0de#ddfdZ1	 dRde#dee*   de/de*fdZ2de#d e,de*fd!Z3de#de*fd"Z4d#e d$e de fd%Z5de#ddfd&Z6i Z7eee$e*f   e*f   e!d'<   d(ee$e*f   de*fd)Z8ed$e$de$fd*       Z9ed$e*de$fd+       Z9d$ee$e*f   de$fd,Z9ed$e$de,fd-       Z:ed$e*de*fd.       Z:ed$e,de,fd/       Z:d$ee,e$e*f   dee,e*f   fd0Z:d$e*de*fd1Z;d2e,de$fd3Z<d4Z=d5e,d6e,d7e,de,fd8Z>dSd9e$d:e,ddfd;Z?d9e$ddfd<Z@	 dTd=e$d>e$d?e$ddfd@ZA	 dTd=e$d>e$d?e$ddfdAZBdTdBe$d?e$ddfdCZCdTdBe$d?e$ddfdDZDd9e$dEe$ddfdFZEdGe$defdHZF	 dRdIe$dJee$ef   dGee$e$f   dKe/fdLZGdMe,de$fdNZHe	 G dO dP             ZIy# e$ r
 dd
lmZ Y w xY w)Uz"Utility functions for PDF library.zMathieu Fenniakzbiziqe@mathieu.fenniak.net    N
getencoder)	dataclass)DEFAULT_BUFFER_SIZE)SEEK_CUR)	IOAnyCallableDictOptionalPatternTupleUnionoverload)	TypeAlias   )STREAM_TRUNCATED_PREMATURELYDeprecationErrorPdfStreamErrorTransformationMatrixTypeCompressedTransformationMatrixz2{} is deprecated and will be removed in PyPDF2 {}.z.{} is deprecated and was removed in PyPDF2 {}.zE{} is deprecated and will be removed in PyPDF2 3.0.0. Use {} instead.z>{} is deprecated and was removed in PyPDF2 {}. Use {} instead.header1header2returnc                     d}g }| |v r |j                  |j                  |              ||v r |j                  |j                  |             t        |      dk(  rt        d| d|d      |t	        |         S )N)s   %PDF-1.3s   %PDF-1.4s   %PDF-1.5s   %PDF-1.6s   %PDF-1.7s   %PDF-2.0r   zneither z nor z are proper headers)appendindexlen
ValueErrormax)r   r   versionspdf_header_indicess       O/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/PyPDF2/_utils.py_get_max_pdf_version_headerr$   O   s    H (!!(.."9:(!!(.."9:
!#8G;eG;>QRSSC*+,,    streammaxcharsc                     d}	 | j                  d      }|j                         s|s	 |S ||z  }t        |      |k(  r	 |S =)z~
    Read non-whitespace characters and return them.

    Stops upon encountering whitespace or when maxchars is reached.
    r%   r   )readisspacer   )r&   r'   txttoks       r#   read_until_whitespacer-   b   sR     C
kk!n;;= J 	s
s8xJ r%   c                 l    | j                  d      }|t        v r| j                  d      }|t        v r|S )zEFind and read the next non-whitespace character (ignores whitespace).r   )r)   WHITESPACESr&   r,   s     r#   read_non_whitespacer1   s   s3    
++a.C

kk!n 
Jr%   c                 p    t         d   }d}|t         v r| j                  d      }|dz  }|t         v r|dkD  S )zr
    Similar to read_non_whitespace, but return a Boolean if more than
    one whitespace character was read.
    r   r   )r/   r)   )r&   r,   cnts      r#   skip_over_whitespacer4   {   sE    
 a.C
C

kk!nq 
 7Nr%   c                     | j                  d      }| j                  dd       |dk(  r|dvr| j                  d      }|dvry y y )Nr      %)   
   )r)   seekr0   s     r#   skip_over_commentr;      sH    
++a.C
KKA
d{'++a.C ' r%   regex
ignore_eofc                    d}	 | j                  d      }|s|r|S t        t              |j                  |      }|E||d|j	                          z  }| j                  |j	                         t        |      z
  d       	 |S ||z  })z
    Read until the regular expression pattern matched (ignore the match).

    :raises PdfStreamError: on premature end-of-file
    :param bool ignore_eof: If true, ignore end-of-line and return immediately
    :param regex: re.Pattern
    r%      Nr   )r)   r   r   searchstartr:   r   )r&   r<   r=   namer,   ms         r#   read_until_regexrD      s     D
kk"o !=>>LL=C!'')$$DKK	CH,a0K 	 r%   to_readc                     | j                         |k  rt        d      | j                  | t               | j	                  |      }| j                  | t               |S )z
    Given a stream at position X, read a block of size to_read ending at position X.

    This changes the stream's position to the beginning of where the block was
    read.
    z!Could not read malformed PDF file)tellr   r:   r   r)   )r&   rE   r)   s      r#   read_block_backwardsrH      sQ     {{}w@AA
KK(#;;wD
KK(#Kr%   c                    g }d}| j                         dk(  rt        t              	 t        t        | j                               }|dk(  rnt        | |      }t        |      dz
  }|s%|dk\  r||   dvr|dz  }|dk\  r||   dvr|dk\  rd}|r6|j                  ||dz   d        |dk\  r+||   dv r$|dz  }|dk\  r||   dv rn|j                  |       |dk\  r| j                  |dz   t               ndj                  |ddd         S )	a  
    Given a byte stream with current position X, return the previous line.

    All characters between the first CR/LF byte found before X
    (or, the start of the file, if no such byte is found) and position X
    After this call, the stream will be positioned one byte after the
    first non-CRLF character found beyond the first CR/LF byte before X,
    or, if no such byte is found, at the beginning of the stream.
    Fr   Tr   s   
Nr%   r6   )rG   r   r   minr   rH   r   r   r:   r   join)r&   line_content
found_crlfrE   blockidxs         r#   read_previous_linerP      s?    LJ{{}9::
)6;;=9a< %VW5%j1n (uSz8q (uSz8ax!

 cAgi 01(uSzW4q (uSzW4
 &!8 KKa*A D 88L2&''r%   abc                 ,    t        fd| D              S )Nc              3   T   K   | ]  t        fd t         D                 yw)c              3   V   K   | ]   }t        d  t        |      D               " yw)c              3   P   K   | ]  \  }}t        |      t        |      z     y wN)float).0ijs      r#   	<genexpr>z6matrix_multiply.<locals>.<genexpr>.<genexpr>.<genexpr>   s!     @$!Q%(U1X%@s   $&N)sumzip)rY   colrows     r#   r\   z,matrix_multiply.<locals>.<genexpr>.<genexpr>   s"     TSc@#c3-@@Ts   &)N)tupler^   )rY   r`   rR   s    @r#   r\   z"matrix_multiply.<locals>.<genexpr>   s)       	TCQRGTTs   $()ra   )rQ   rR   s    `r#   matrix_multiplyrb      s        r%   c                 8   d}| j                  | d       t        dd      5 }|j                  | j                  |             |j                  d       |j                  | j                  |             ddd       | j                  | d       y# 1 sw Y   xY w)z5Create text file showing current location in context.i  r   zPyPDF2_pdfLocation.txtwbs   HEREN)r:   openwriter)   )r&   radius	output_fhs      r#   mark_locationri      s     F
KK	&	- -F+, F+,- KK	- -s   ABBB_CACHEsc                     t         }| |v r||    S t        | t              r| S 	 | j                  d      }t	        |       dk  r||| <   |S # t
        $ r) | j                  d      }t	        |       dk  r||| <   |cY S w xY w)Nlatin-1   zutf-8)rj   
isinstancebytesencoder   	Exception)rk   bcrs      r#   b_ru     s    	BBw!u!U	HHYq6A:BqE HHWq6A:BqE	s   %A	 	/A;:A;c                      y rW    rR   s    r#   str_ry         r%   c                      y rW   rw   rx   s    r#   ry   ry     rz   r%   c                 H    t        | t              r| j                  d      S | S )Nrm   )ro   rp   decoderx   s    r#   ry   ry   "  s     !Uxx	""r%   c                      y rW   rw   rx   s    r#   ord_r   )  rz   r%   c                      y rW   rw   rx   s    r#   r   r   .  rz   r%   c                      y rW   rw   rx   s    r#   r   r   3  rz   r%   c                 <    t        | t              rt        |       S | S rW   )ro   strordrx   s    r#   r   r   8  s    !S1vHr%   c                 2    t        d      } ||       }|d   S )N	hex_codecr   r   )rR   codercodeds      r#   	hexencoder   >  s    {#E!HE8Or%   numc                 8    t        |       j                  dd      S )NL )hexreplace)r   s    r#   hex_strr   E  s    s8C$$r%   )    r8   r9      	    leftupup_leftc                     | |z   |z
  }t        || z
        }t        ||z
        }t        ||z
        }||k  r||k  r| S ||k  r|S |S rW   )abs)r   r   r   p	dist_leftdist_updist_up_lefts          r#   paeth_predictorr   L  s^    r	GAAHI!b&kGq7{#LG	\ 9	L	 	r%   msg
stacklevelc                 <    t        j                  | t        |       y )N)r   )warningswarnDeprecationWarning)r   r   s     r#   	deprecater   Z  s    MM#)jAr%   c                     t        |       rW   )r   )r   s    r#   deprecationr   ^  s    
3
r%   old_namenew_name
removed_inc                 F    t        t        j                  | ||      d       y)zS
    Raise an exception that a feature will be removed, but has a replacement.
       N)r   DEPR_MSGformatr   r   r   s      r#   deprecate_with_replacementr   b  s     hooh*=qAr%   c                 D    t        t        j                  | ||             y)zW
    Raise an exception that a feature was already removed, but has a replacement.
    N)r   DEPR_MSG_HAPPENEDr   r   s      r#   deprecation_with_replacementr   k  s     !((:xHIr%   rB   c                 D    t        t        j                  | |      d       y)zP
    Raise an exception that a feature will be removed without replacement.
    r   N)r   DEPR_MSG_NO_REPLACEMENTr   rB   r   s     r#   deprecate_no_replacementr   t  s     %,,T:>Br%   c                 B    t        t        j                  | |             y)zT
    Raise an exception that a feature was already removed without replacement.
    N)r    DEPR_MSG_NO_REPLACEMENT_HAPPENEDr   r   s     r#   deprecation_no_replacementr   {  s     077jIJr%   srcc                 L    t        j                  |      j                  |        y)a  
    Use this instead of logger.warning directly.

    That allows people to overwrite it more easily.

    ## Exception, warnings.warn, logger_warning
    - Exceptions should be used if the user should write code that deals with
      an error case, e.g. the PDF being completely broken.
    - warnings.warn should be used if the user needs to fix their code, e.g.
      DeprecationWarnings
    - logger_warning should be used if the user needs to know that an issue was
      handled by PyPDF2, e.g. a non-compliant PDF being read in a way that
      PyPDF2 could apply a robustness fix to still read it. This applies mainly
      to strict=False mode.
    N)logging	getLoggerwarning)r   r   s     r#   logger_warningr     s      c""3'r%   aliasesc                        dt         f fd}|S )z
    Decorator for deprecated term "bookmark"
    To be used for methods and function arguments
        outline_item = a bookmark
        outline = a collection of outline items
    funcc                 F     t        j                          fd       }|S )Nc                  F    t        j                  |d        | i |S )NT)fail)rename_kwargs__name__)argskwargsr   r   s     r#   wrapperz9deprecation_bookmark.<locals>.decoration.<locals>.wrapper  s%    $--tD(((r%   )	functoolswraps)r   r   r   s   ` r#   
decorationz(deprecation_bookmark.<locals>.decoration  s%    			) 
	) r%   )r
   )r   r   s   ` r#   deprecation_bookmarkr     s      r%   	func_namer   r   c                 
   |j                         D ]p  \  }}||v s|rt        | d| d      ||v rt        |  d| d| d| d| d
      |j                  |      ||<   t	        j
                  | d| dt               r y	)
z1
    Helper function to deprecate arguments.
    z# is deprecated as an argument. Use z insteadz received both z and z as an argument. z is deprecated. Use z	 instead.)messagecategoryN)itemsr   	TypeErrorpopr   r   r   )r   r   r   r   old_termnew_terms         r#   r   r     s     &mmo (v&j CH:XV  6! k
%zIZj 4XJiI   &zz(3F8MMj CH:XV+	r%   rp   c                 `    | dk  r|  dS | dk  r	| dz  ddS | dk  r	| dz  ddS | dz  ddS )	Ni  z Bytei@B z.1fz kBi ʚ;z MBz GBrw   )rp   s    r#   _human_readable_bytesr     s_    u}	%-$C((	%-$C((%-$C((r%   c                   :    e Zd ZU eed<   eed<   defdZdefdZy)FilerB   datar   c                 `    d| j                    dt        t        | j                               dS )N
File(name=, data: ))rB   r   r   r   selfs    r#   __str__zFile.__str__  s+    DII;h/DS^/T.UUVWWr%   c                     d| j                    dt        t        | j                               dt	        | j                         dS )Nr   r   z, hash: r   )rB   r   r   r   hashr   s    r#   __repr__zFile.__repr__  s@    DII;h/DS^/T.UU]^bcgclcl^m]nnoppr%   N)r   
__module____qualname__r   __annotations__rp   r   r   rw   r%   r#   r   r     s(    
I
KX Xq# qr%   r   rW   )F)   )z3.0.0)J__doc__
__author____author_email__r   r   r   codecsr   dataclassesr   ior   osr   typingr   r	   r
   r   r   r   r   r   r   r   ImportErrortyping_extensionserrorsr   r   r   rX   r   r   r   
StreamTyper   StrByteTyper   r   r   r   rp   r$   intr-   r1   boolr4   r;   rD   rH   rP   rb   ri   rj   ru   ry   r   r   r   r/   r   r   r   r   r   r   r   r   r   r   r   r   rw   r%   r#   <module>r      s  8 )
/      ! " 
 
 
,   ',	%
eUE&9 :E%PUBU<VV' )  -2	5%u,- 	  
CO$N #S  RT - - -5 -&*  QV "
 u 
 
 
!j !T ! CH&u~;?
4 c e "0(z 0(e 0(f$<	* 	 	 +-eCJ&	' ,%U

  $ 
C C  
 
E c  
E#u* #  
C C  
 
E e  
 
C C  
E#sE/" uS%Z'8  5 % % % 3# 3   B3 BC B B S  T  
 5<BB B.1B	B 5<JJ J.1J	JC3 CC Cd CKS Kc K K( (# ($ (&C H ( SX cN59#s(^KO6) ) ) q q qs  ,++,s   H H+*H+