
    niE                     >   S SK r S SKrS SKrS SKJr  S SKJrJrJrJ	r	  S SK
JrJrJrJrJrJr  S SKJrJr  SSKJr  \" \\-   \-   5      r\R1                  S5        S	r   SS
\S\\   S\S\\\4   4S jjrS\S\4S jrS
\S\S\4S jrS\S\4S jrS
\S\4S jr g)    N)
gettempdir)BinaryIOOptionalTuplecast)quoteunquoteurlparseuses_netlocuses_paramsuses_relative)Requesturlopen   )FileLikeObj    path_or_buffer
user_agentsuffixreturnc                 Z   [        U 5      n Sn[        U 5      (       Ga&  U(       d  [        [        U 5      US9n U(       a  [	        [        X5      5      nO[	        U 5      n[        UR                  5       5      n[        R                  R                  UR                  5      n[        R                  R                  U5      u  pUS[          U	 3nX:w  a  [        R                  " 5        U 3n[        R                  R                  [!        5       U5      n[#        US5       n
[$        R&                  " XZ5        SSS5        US4$ [)        U 5      (       a  [        R                  R                  [!        5       [        R                  " 5        U 35      n[+        [,        U 5      n U R/                  S5        [#        US5       n
[$        R&                  " X
5        SSS5        US4$ [        R                  R1                  U 5      S4$ ! , (       d  f       US4$ = f! , (       d  f       US4$ = f)a}  Ensure localize target file.

If the target file is remote, this function fetches into local storage.

Args:
    path_or_buffer (str):
        File path or file like object or URL of target file.
    user_agent (str, optional):
        Set a custom user-agent when download a pdf from a url. Otherwise
        it uses the default ``urllib.request`` user-agent.
    suffix (str, optional):
        File extension to check.
    use_raw_url (bool):
        Use `path_or_buffer` without quoting/dequoting.

Returns:
    (str, bool):
        tuple of str and bool, which represents file name in local storage
        and temporary file flag.
z!#$%&'()*+,/:;=?@[]~)safeNwbTr   F)_stringify_path_is_urlr   r	   r   _create_requestr
   geturlospathbasenamesplitextMAX_FILE_SIZEuuiduuid4joinr   openshutilcopyfileobjis_file_liker   r   seek
expanduser)r   r   r   use_raw_urlsafe_with_percentreq
parsed_urlfilenamefnameextfs              L/var/www/html/land-ocr/venv/lib/python3.13/site-packages/tabula/file_util.pylocalize_filer6      s   6 %^4N.~"7>#:ARSN/.EFC.)Ccjjl+
77##JOO4WW%%h/
N]+,SE2=**,x0H77<<
h7(D!Qs& " ~	n	%	%77<<
vh.GHh7A(D!Q~1 " ~ ww!!.1588# "! ~ "! ~s   "HH
H
H*urlc                 \     [        U 5      R                  [        ;   $ ! [         a     gf = f)NF)r
   scheme_VALID_URLS	Exception)r7   s    r5   r   r   Y   s.    }##{22 s    
++c                     SU0n[        XS9$ )Nz
User-Agent)headers)r   )r   r   req_headerss      r5   r   r   a   s    ,K>77    objc                 n    [        U S5      (       d  [        U S5      (       d  g[        U S5      (       d  gg)zmCheck file like object

Args:
    obj:
        file like object.

Returns:
    bool: file like object or not
readwriteF__iter__T)hasattr)r@   s    r5   r*   r*   f   s3     C  GC$9$93
##r?   c                 (    SSK nSn[        U S5      (       a*  [        [        R
                  U 5      n U R                  5       $ U(       a&  [        U WR                  5      (       a  [        U 5      $ [        [        U 5      n U $ ! [         a    Sn Nf = f)zConvert path like object to string

Args:
    path_or_buffer: object to be converted

Returns:
    string_path_or_buffer: maybe string version of path_or_buffer
r   NTF
__fspath__)
pathlibImportErrorrE   r   r   PathLikerG   
isinstancePathstr)r   rH   _PATHLIB_INSTALLEDs      r5   r   r   z   s    #! ~|,,bkk>:((**jFF>""#~.N  #"#s   B BB)Nz.pdfF)!r   r(   r$   tempfiler   typingr   r   r   r   urllib.parser   r	   r
   r   r   r   urllib.requestr   r   utilr   setr:   discardr#   rM   boolr6   r   r   r*   r    r?   r5   <module>rX      s    	    2 2  , -+-;<   B 
 !%	?9?9?9 ?9
 39?9D  8C 8S 8W 8
k d (K C r?   