
    Wh              
         d Z ddlmZ ddlmZmZ ddlZddlZddlZddl	Z	ddl
Z
ddlmZmZmZmZmZmZ ddlZddlZddlmZ ddlZddlZddlmZmZmZmZmZmZmZm Z m!Z!m"Z" ddl#m$Z$m%Z&m'Z'm(Z(m)Z) ddl*Z*ddl+Z+dd	l,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 dd
l4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z=m>Z>m?Z?m@Z@ ddlAmBZB  eCe)e'z   e(z             ZDeDE                    d            ejF        d          ZG e de-          ZHejI         G d d                      ZJejI         G d dee                               ZKdndZLe"dod            ZMe"dpd             ZMdqd"ZMdrd%ZNe"dsdtd)            ZOe"	 dsdud*            ZO	 dvdwd-ZOd. ZPdxd0ZQ e9eBd1         eBd2         dz  3          	 	 	 	 dydzd;            ZRd{d=ZSd>d>d>d>d?d@dAdBdCdD	ZT eCeTU                                          ZVd|dFZW e9eBd2         dz  G          d}dI            ZXd~dKZYe"d&d&d&d&d&dLddS            ZZe"d&d&d&d&d&d&dTddW            ZZe"d&d&d&d&d&d&dTddY            ZZ e9eBd2         dMz  G          ddd+dZdddTdd[            ZZ G d\ d]ee          Z[ G d^ d_e[          Z\ G d` dae[          Z] G db dc          Z^ G dd de          Z_ddiZ`ddjZaddkZbe	jc        ddm            ZddS )zCommon IO api utilities    )annotations)ABCabstractmethodN)BufferedIOBaseBytesIO	RawIOBaseStringIO
TextIOBaseTextIOWrapper)Path)
IOAnyAnyStrGenericLiteralMappingSequenceTypeVarcastoverload)urljoinurlparseuses_netlocuses_paramsuses_relative)
BaseBufferCompressionDictCompressionOptionsFilePath
ReadBufferStorageOptionsWriteBuffer)get_lzma_file)import_optional_dependency)doc)find_stack_level)is_boolis_file_like
is_integeris_list_like)_shared_docs z^[A-Za-z][A-Za-z0-9+\-+.]*://BaseBufferT)boundc                  J    e Zd ZU dZded<   ded<   ded<   ded<   d	Zd
ed<   dS )IOArgsz?
    Return value of io/common.py:_get_filepath_or_buffer.
    str | BaseBufferfilepath_or_bufferstrencodingmoder   compressionFboolshould_closeN)__name__
__module____qualname____doc____annotations__r8        V/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/pandas/io/common.pyr0   r0   N   sY           )(((MMMIII    Lr?   r0   c                  z    e Zd ZU dZded<   ded<    ej        e          Zded<   d	Z	d
ed<   ddZ
ddZddZdS )	IOHandlesau  
    Return value of io/common.py:get_handle

    Can be used as a context manager.

    This is used to easily close created buffers and to handle corner cases when
    TextIOWrapper is inserted.

    handle: The file handle to be used.
    created_handles: All file handles that are created by get_handle
    is_wrapped: Whether a TextIOWrapper needs to be detached.
    z
IO[AnyStr]handler   r6   )default_factoryzlist[IO[bytes] | IO[str]]created_handlesFr7   
is_wrappedreturnNonec                F   | j         rmt          | j        t                    sJ | j                                         | j                                         | j                            | j                   | j        D ]}|                                 g | _        d| _         dS )z
        Close all created buffers.

        Note: If a TextIOWrapper was inserted, it is flushed and detached to
        avoid closing the potentially user-created buffer.
        FN)	rF   
isinstancerC   r   flushdetachrE   removeclose)selfrC   s     r@   rN   zIOHandles.closep   s     ? 	5dk=99999KK    ''444* 	 	FLLNNNN!r?   IOHandles[AnyStr]c                    | S Nr>   rO   s    r@   	__enter__zIOHandles.__enter__   s    r?   argsr   c                .    |                                   d S rR   )rN   )rO   rU   s     r@   __exit__zIOHandles.__exit__   s    

r?   NrG   rH   )rG   rP   )rU   r   rG   rH   )r9   r:   r;   r<   r=   dataclassesfieldlistrE   rF   rN   rT   rW   r>   r?   r@   rB   rB   [   s               1B1BSW1X1X1XOXXXXJ       "        r?   rB   urlobjectrG   r7   c                f    t          | t                    sdS t          |           j        t          v S )z
    Check to see if a URL has a valid protocol.

    Parameters
    ----------
    url : str or unicode

    Returns
    -------
    isurl : bool
        If `url` has a valid protocol return True otherwise False.
    F)rJ   r3   	parse_urlscheme_VALID_URLSr\   s    r@   is_urlrc      s/     c3 uS>> K//r?   r2   r3   c                    d S rR   r>   r2   s    r@   _expand_userrf          Cr?   c                    d S rR   r>   re   s    r@   rf   rf      rg   r?   str | BaseBufferTc                n    t          | t                    rt          j                            |           S | S )a]  
    Return the argument with an initial component of ~ or ~user
    replaced by that user's home directory.

    Parameters
    ----------
    filepath_or_buffer : object to be converted if possible

    Returns
    -------
    expanded_filepath_or_buffer : an expanded filepath or the
                                  input if not expandable
    )rJ   r3   ospath
expanduserre   s    r@   rf   rf      s4     $c** 6w!!"4555r?   headerrH   c                   | d S t          |           r,t          t          |           } | dk     rt          d          d S t	          | d          rpt          t
          |           } t          t          t           |                     st          d          t          d | D                       rt          d          d S t          |           rt          d          t          d          )	Nr   zUPassing negative integer to header is invalid. For no header, use header=None insteadF)
allow_setsz*header must be integer or list of integersc              3  "   K   | ]
}|d k     V  dS )r   Nr>   ).0is     r@   	<genexpr>z&validate_header_arg.<locals>.<genexpr>   s&      %%q1u%%%%%%r?   z8cannot specify multi-index header with negative integerszPassing a bool to header is invalid. Use header=None for no header or header=int or list-like of ints to specify the row(s) making up the column names)r)   r   int
ValueErrorr*   r   allmapanyr'   	TypeError)rn   s    r@   validate_header_argr{      s
   ~& c6""A::9   	Fu--- h''3z6**++ 	KIJJJ%%f%%%%% 	YWXXXv 
4
 
 	
 A
B
BBr?   .r   convert_file_likec                    d S rR   r>   r2   r|   s     r@   stringify_pathr      rg   r?   c                    d S rR   r>   r~   s     r@   r   r      s	     Cr?   FFilePath | BaseBufferTc                    |s$t          |           rt          t          |           S t          | t          j                  r|                                 } t          |           S )a  
    Attempt to convert a path-like object to a string.

    Parameters
    ----------
    filepath_or_buffer : object to be converted

    Returns
    -------
    str_filepath_or_buffer : maybe a string version of the object

    Notes
    -----
    Objects supporting the fspath protocol (python 3.6+) are coerced
    according to its __fspath__ method.

    Any other object is passed through unchanged, which includes bytes,
    strings, buffers, or anything else that's not even path-like.
    )r(   r   r-   rJ   rk   PathLike
__fspath__rf   r~   s     r@   r   r      se    .  5.@!A!A 5 K!3444$bk22 =/::<<*+++r?   c                 .    ddl } |j        j        | i |S )z`
    Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of
    the stdlib.
    r   N)urllib.requestrequesturlopen)rU   kwargsurllibs      r@   r   r     s*    
 !6>!426222r?   FilePath | BaseBufferc                    t          | t                    o<t          t                              |                     o|                     d           S )zR
    Returns true if the given URL looks like
    something fsspec can handle
    )zhttp://zhttps://)rJ   r3   r7   _RFC_3986_PATTERNmatch
startswithrb   s    r@   is_fsspec_urlr     sM     	3 	8"((--..	86777r?   storage_optionscompression_options)r   r   utf-8rr4   r6   r   r5   r!   c                (   t          |           } t          |          \  }}t          | |          }|r>t          | d          r.d|vr*t	          j        dt          t                                 d}t          ||          }d|v r5|dv r1|d	v r-t	          j        | d
| t          t                                 |}d|vr	d|vr|dz  }t          | t                    rt          |           r|pi }ddl}|j                            | |          }t!          |          5 }	|	j                            dd          }
|
dk    rddi}t'          |	                                          }ddd           n# 1 swxY w Y   t+          |||d|          S t-          |           rBt          | t                    sJ |                     d          r|                     dd          } |                     d          r|                     dd          } t3          d          }g }	 t3          d           ddlm}m} ||t:          g}n# t<          $ r Y nw xY w	  |j        | fd|i|pi                                 }nW# tA          |          $ rB |ddi}nt          |          }d|d<    |j        | fd|i|pi                                 }Y nw xY wt+          |||d|          S |rtC          d          t          | t          tD          tF          j#        f          r!t+          tI          |           ||d|          S t          | d          s1t          | d          s!dtK          |            }tC          |          t+          | ||d|          S )a%  
    If the filepath_or_buffer is a url, translate and return the buffer.
    Otherwise passthrough.

    Parameters
    ----------
    filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path),
                         or buffer
    {compression_options}

        .. versionchanged:: 1.4.0 Zstandard support.

    encoding : the encoding to use to decode bytes, default is 'utf-8'
    mode : str, optional

    {storage_options}

        .. versionadded:: 1.2.0

    ..versionchange:: 1.2.0

      Returns the dataclass IOArgs.
    writebzDcompression has no effect when passing a non-binary object as input.)
stacklevelN)methodw)bz2xz)zutf-16zutf-32z( will not write the byte order mark for tr   )headerszContent-Encodinggzipr   T)r2   r4   r6   r8   r5   zs3a://zs3://zs3n://fsspecbotocore)ClientErrorNoCredentialsErrorr5   anonz?storage_options passed with file object or non-fsspec file pathFreadz)Invalid file path or buffer object type: )&r   get_compression_methodinfer_compressionhasattrwarningswarnRuntimeWarningr&   dictUnicodeWarningrJ   r3   rc   r   r   Requestr   r   getr   r   r0   r   r   replacer$   botocore.exceptionsr   r   PermissionErrorImportErroropentuplerv   bytesmmaprf   type)r2   r4   r6   r5   r   compression_methodfsspec_moder   req_inforeqcontent_encodingreaderr   err_types_to_retry_with_anonr   r   file_objmsgs                     r@   _get_filepath_or_bufferr     s6   D ((:;; '=[&I&I#*+=?QRR  "g&8'BB "sRVR'))	
 	
 	
 	

 "{+=>>>K
 	t-//,,,NNHNN'))	
 	
 	
 	
 K
+#["8"8s$c** 
v6H/I/I 
 */R 	 >))*<o)VVX 	)#"{/A4HH6))'0SXXZZ((F	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) %#
 
 
 	
 '(( 9

 
 	
 	
 
 ((22 	O!3!;!;Hg!N!N((22 	O!3!;!;Hg!N!N+H55 35$	&z222        ",((
  	 	 	D		"v{" )49H9NB dff H 122 		 		 		&#)4. #'"7"7*.'"v{" )49H9NB dff HH		 '#
 
 
 	
 
 
M
 
 	
 $sE49&=>> 
+,>??#
 
 
 	
 	"F++/67I7/S/S U$?Q:R:RTToo-   s8   "AE55E9<E9#!I 
II$I; ;AKKrl   c                @    ddl m} t          d ||                     S )z
    converts an absolute native path to a FILE URL.

    Parameters
    ----------
    path : a path in native format

    Returns
    -------
    a valid FILE URL
    r   )pathname2urlzfile:)r   r   r   )rl   r   s     r@   file_path_to_urlr     s0     ,+++++7LL..///r?   tarr   r   zipr   zstd)	.tar.tar.gz.tar.bz2.tar.xz.gz.bz2.zip.xzz.zst"tuple[str | None, CompressionDict]c                    t          | t                    rHt          |           }	 |                    d          }n&# t          $ r}t          d          |d}~ww xY wi }| }||fS )a  
    Simplifies a compression argument to a compression method string and
    a mapping containing additional arguments.

    Parameters
    ----------
    compression : str or mapping
        If string, specifies the compression method. If mapping, value at key
        'method' specifies compression method.

    Returns
    -------
    tuple of ({compression method}, Optional[str]
              {compression arguments}, Dict[str, Any])

    Raises
    ------
    ValueError on mapping missing 'method' key
    r   z.If mapping, compression must have key 'method'N)rJ   r   r   popKeyErrorrv   )r6   compression_argsr   errs       r@   r   r     s    . +w'' ),,	X!1!5!5h!?!? 	X 	X 	XMNNTWW	X (///s   < 
AAA)r   
str | Nonec                t   |dS |dk    rtt          | d          } t          | t                    sdS t                                          D ]0\  }}|                                                     |          r|c S 1dS |t          v r|S ddgt          t                    z   }d| d| }t          |          )a/  
    Get the compression method for filepath_or_buffer. If compression='infer',
    the inferred compression method is returned. Otherwise, the input
    compression method is returned unchanged, unless it's invalid, in which
    case an error is raised.

    Parameters
    ----------
    filepath_or_buffer : str or file handle
        File path or object.
    {compression_options}

        .. versionchanged:: 1.4.0 Zstandard support.

    Returns
    -------
    string or None

    Raises
    ------
    ValueError on invalid compression specified.
    NinferT)r|   Unrecognized compression type: z
Valid compression types are )
r   rJ   r3   _extension_to_compressionitemslowerendswith_supported_compressionssortedrv   )r2   r6   	extensionvalidr   s        r@   r   r     s   4 t g+,>RVWWW,c22 	4 '@&E&E&G&G 	# 	#"I{!''))229== #""""#t --- dOf%<===E	/+ 	/ 	/',	/ 	/  S//r?   
Path | strc                |    t          |           j        }|                                st          d| d          dS )z
    Check if parent directory of a file exists, raise OSError if it does not

    Parameters
    ----------
    path: Path or str
        Path to check parent directory of
    z1Cannot save file into a non-existent directory: ''N)r   parentis_dirOSError)rl   r   s     r@   check_parent_directoryr   J  sI     $ZZF==?? VT6TTTUUUV Vr?   )r4   r6   
memory_maperrorsr   path_or_bufr   is_textLiteral[False]r   IOHandles[bytes]c                   d S rR   r>   r   r5   r4   r6   r   r   r   r   s           r@   
get_handler   X  	     Cr?   )r4   r6   r   r   r   r   Literal[True]IOHandles[str]c                   d S rR   r>   r   s           r@   r   r   g  r   r?   !IOHandles[str] | IOHandles[bytes]c                   d S rR   r>   r   s           r@   r   r   v  r   r?   Tc               D   |pd}|pd}t          | |          r	d|vr|dz  }t          j        |           t          |t                    rt          j        |           t          | ||||          }|j        }	t          |	|          \  }	}}
t          |	t                    }t          |j
                  }|                    d          }d|vr|rt          t	          |	                     |r8|dk    r!|j                            dd	          |_        n|dk    rd|j        vr|xj        dz  c_        |d
k    rKt          |	t                    rt          j        d*|	|j        d|}	nt          j        d*|	|j        d|}	nt|dk    rt#          j        |	fd|j        i|}	nS|dk    rt'          |	|j        fi |}	|	j        j        dk    r|
                    |	           |	j                                        }t/          |          dk    r.|	j                            |                                          }	n|st3          d|            t3          d|           n|dk    r|                    d|j                   t          |	t                    rt7          d*d|	i|}	nt7          d*d|	i|}	t          |	t6                    sJ d|	j        j        v r|
                    |	           |	j                                        }t/          |          dk    r'|	j                            |d                   }|J |}	n|st3          d|            t3          d|           n|dk    r t=                      |	|j                  }	ng|dk    rMt?          d          }d|j        v rd |j         d*i |i}nd |j!        d*i |i} |j        |	fd|j        i|}	nd| }t3          |          t          |	t                    rJ |
                    |	           nnt          |	t                    rY|j"        r(d|j        vrt1          |	|j        |j"        |d	          }	nt1          |	|j                  }	|
                    |	           d }|s7|j        d!k    r,t          |	tF                    rtI          |	|j"        "          }	n|r|s|st          |	|j                  rtK          |	d#          r tK          |	d$          rtK          |	d%          stM          |	          }	tO          |	|j"        |d	          }	|
                    |	           t          |j        t                    p|j(         }d|j        v r5tK          |	d&          s%tS          d'tU          |j                   d(          |
+                                 |j(        r6t          |j        t                    rJ |
                    |j                   tY          |	|
||j
        )          S )+a  
    Get file handle for given path/buffer and mode.

    Parameters
    ----------
    path_or_buf : str or file handle
        File path or object.
    mode : str
        Mode to open path_or_buf with.
    encoding : str or None
        Encoding to use.
    {compression_options}

        .. versionchanged:: 1.0.0
           May now be a dict with key 'method' as compression mode
           and other keys as compression options if compression
           mode is 'zip'.

        .. versionchanged:: 1.1.0
           Passing compression options as keys in dict is now
           supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'.

        .. versionchanged:: 1.4.0 Zstandard support.

    memory_map : bool, default False
        See parsers._parser_params for more information. Only used by read_csv.
    is_text : bool, default True
        Whether the type of the content passed to the file/buffer is string or
        bytes. This is not the same as `"b" not in mode`. If a string content is
        passed to a binary file/buffer, a wrapper is inserted.
    errors : str, default 'strict'
        Specifies how encoding and decoding errors are to be handled.
        See the errors argument for :func:`open` for a full list
        of options.
    storage_options: StorageOptions = None
        Passed to _get_filepath_or_buffer

    .. versionchanged:: 1.2.0

    Returns the dataclass IOHandles
    r   strictr   )r4   r6   r5   r   r   r   r   r   r,   r   )filenamer5   )fileobjr5   r   r5   r      zZero files found in ZIP file z9Multiple files found in ZIP file. Only one file per ZIP: r   namer   r   Nz Zero files found in TAR archive zDMultiple files found in TAR archive. Only one file per TAR archive: r   	zstandarddctxcctxr   )r4   r   newlineFrb)r4   readablewritableseekabler   z1Expected file path name or file-like object, got z type)rC   rE   rF   r6   r>   )-_is_binary_modecodecslookuprJ   r3   lookup_errorr   r2   _maybe_memory_mapr   r6   r   r   r5   r   r   GzipFiler   BZ2File_BytesZipFilebufferappendnamelistlenr   rv   
setdefault_BytesTarFilegetnamesextractfiler#   r$   ZstdDecompressorZstdCompressorr4   r
   _BytesIOWrapperr   
_IOWrapperr   r8   rz   r   reverserB   )r   r5   r4   r6   r   r   r   r   ioargsrC   handlesis_pathr   	zip_namesfilesfiler   	open_argsr   rF   s                       r@   r   r     s   l "7HxF {D)) coo M(&# $F### %'  F &F
 #4FJ"G"GFJ%%GF.//"&&x00K $7s6{{+++ B&   +--c266FKKF""s&+'='= KK3KK &  &#&&   #  '    #	 
 '  E!! [ [ # FF E!! # '7 F }!S((v&&&"M2244	y>>Q&&#]//	@@FF" $%R[%R%RSSS$>2;> >   ) E!!''<<<&#&& &GGFG6FGG
 '  "&6  fm44444fm(((v&&&..00u::??!=44U1X>>D+++!FF $%U%U%UVVV$B:?B B   )  D   %]__VV[99FF F""-k::Dfk!!#%:T%:%N%N=M%N%NO		#%8T%8%L%L;K%L%LM	TY [  FF BKAACS//!fc*****v	FC	 	   ? 	/s&+55  FF &&+..Fv J 
v{d**z&*/M/M* _
 
 
 
 

!
%4VV[%I%I
 
++	(6:..	( 6:..	(
  ''F _	
 
 
 	v v0#66M&:M

 fk'&&"9"9:122: : :
 
 	

 OO 2f7=====v0111   &
 
 
 
r?   c                  <     e Zd ZdZedd            Zd fdZ xZS )_BufferedWriterz
    Some objects do not support multiple .write() calls (TarFile and ZipFile).
    This wrapper writes to the underlying buffer on close.
    rG   rH   c                    d S rR   r>   rS   s    r@   write_to_bufferz_BufferedWriter.write_to_buffer  s    r?   c                F   | j         rd S |                                 rI|                     d           | j        5  |                                  d d d            n# 1 swxY w Y   n| j                                         t                                                       d S )Nr   )closedgetvalueseekr  r&  rN   super)rO   	__class__s    r@   rN   z_BufferedWriter.close  s    ; 	F==?? 	 IIaLLL ' '$$&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' Ks   AA #A rX   )r9   r:   r;   r<   r   r&  rN   __classcell__r,  s   @r@   r$  r$    sg         
    ^         r?   r$  c                  B     e Zd Z	 	 	 	 dd fdZddZddZddZ xZS )r  Nr   r   r   r5   Literal['r', 'a', 'w', 'x']r   -ReadBuffer[bytes] | WriteBuffer[bytes] | Nonearchive_namerG   rH   c                    t                                                       || _        || _        t	          j        j        d||                     |          |d|| _        d S )N)r   r5   r   r>   )	r+  __init__r2  r   tarfileTarFiler   extend_moder  )rO   r   r5   r   r2  r   r,  s         r@   r4  z_BytesTarFile.__init__  sq     	(	 o* 
!!$''
 
 	
 
r?   r3   c                    |                     dd          }|dk    r|S | j        ,t          | j                  j        }|dv r| d|dd           }|S )Nr   r,   r   )r   r   r   :r   )r   r   r   suffix)rO   r5   r:  s      r@   r7  z_BytesTarFile.extend_mode  sg    ||C$$3;;K9 $)__+F///----r?   c                    | j         dS t          | j                   }|j        dk    r|                    d          j         S |j        dv r-|                    d                              d          j         S |j         S )z
        If an explicit archive_name is not given, we still want the file inside the zip
        file not to be named something.tar, because that causes confusion (GH39465).
        Nr   r,   )r   r   r   )r   r   r:  with_suffixrO   r   s     r@   infer_filenamez_BytesTarFile.infer_filename  s}    
 94	???f$$''++00_ BBB''++77;;@@}r?   c                    | j         p|                                 pd}t          j        |          }t	          |                                           |_        | j                            ||            d S )Nr   )r   )	r2  r>  r5  TarInfor  r)  sizer  addfile)rO   r2  tarinfos      r@   r&  z_BytesTarFile.write_to_buffer  sg    (JD,?,?,A,AJU/|4444==??++GT*****r?   )Nr   NN)
r   r   r5   r0  r   r1  r2  r   rG   rH   )r5   r3   rG   r3   rG   r   rX   )r9   r:   r;   r4  r7  r>  r&  r-  r.  s   @r@   r  r    s          ,/AE#'
 
 
 
 
 
 
*      + + + + + + + +r?   r  c                  4     e Zd Z	 dd fd
ZddZddZ xZS )r  Nr!  1FilePath | ReadBuffer[bytes] | WriteBuffer[bytes]r5   r3   r2  r   rG   rH   c                    t                                                       |                    dd          }|| _        |                    dt
          j                   t          j        ||fi || _        d S )Nr   r,   r6   )	r+  r4  r   r2  r  zipfileZIP_DEFLATEDZipFiler  )rO   r!  r5   r2  r   r,  s        r@   r4  z_BytesZipFile.__init__  sp     	||C$$(-)=>>> odD;;F;;r?   c                    t          | j        j        t          j        t
          f          rEt          | j        j                  }|j        dk    r|                    d          j	        S |j	        S dS )z
        If an explicit archive_name is not given, we still want the file inside the zip
        file not to be named something.zip, because that causes confusion (GH39465).
        r   r,   N)
rJ   r  r   rk   r   r3   r   r:  r<  r   r=  s     r@   r>  z_BytesZipFile.infer_filename   se    
 dk*R[#,>?? 	!DK011H&((++B//44= tr?   c                    | j         p|                                 pd}| j                            ||                                            d S )Nr   )r2  r>  r  writestrr)  )rO   r2  s     r@   r&  z_BytesZipFile.write_to_buffer  sF    (JD,?,?,A,AJU\4==??;;;;;r?   rR   )r!  rF  r5   r3   r2  r   rG   rH   rD  rX   )r9   r:   r;   r4  r>  r&  r-  r.  s   @r@   r  r    so        
 $(	< < < < < < <"
 
 
 
< < < < < < < <r?   r  c                  6    e Zd ZddZddZdd
ZddZddZdS )r  r  r   rG   rH   c                    || _         d S rR   )r  )rO   r  s     r@   r4  z_IOWrapper.__init__  s    r?   r   r3   c                ,    t          | j        |          S rR   getattrr  )rO   r   s     r@   __getattr__z_IOWrapper.__getattr__      t{D)))r?   r7   c                b    t          | j        d          r| j                                        S dS )Nr  T)r   r  r  rS   s    r@   r  z_IOWrapper.readable  /    4;
++ 	*;'')))tr?   c                b    t          | j        d          r| j                                        S dS )Nr  T)r   r  r  rS   s    r@   r  z_IOWrapper.seekable%  s/    4;
++ 	*;'')))tr?   c                b    t          | j        d          r| j                                        S dS )Nr  T)r   r  r  rS   s    r@   r  z_IOWrapper.writable*  rV  r?   N)r  r   rG   rH   )r   r3   )rG   r7   )r9   r:   r;   r4  rS  r  r  r  r>   r?   r@   r  r    sx           * * * *      
     r?   r  c                  *    e Zd ZdddZdd
ZdddZdS )r  r   r  StringIO | TextIOBaser4   r3   rG   rH   c                0    || _         || _        d| _        d S )Nr?   )r  r4   overflow)rO   r  r4   s      r@   r4  z_BytesIOWrapper.__init__4  s     
 r?   attrc                ,    t          | j        |          S rR   rQ  )rO   r]  s     r@   rS  z_BytesIOWrapper.__getattr__=  rT  r?   n
int | Noner   c                
   | j         J | j                             |                              | j                  }| j        |z   }||dk     s|t          |          k    r	d| _        |S |d |         }||d          | _        |S )Nr   r?   )r  r   encoder4   r\  r  )rO   r`  
bytestringcombined_bytestring	to_returns        r@   r   z_BytesIOWrapper.read@  s    {&&&[%%a((//>>
"mj89Ac*=&>&>!>!>DM&&+BQB/I/3DMr?   N)r   )r  rZ  r4   r3   rG   rH   )r]  r3   )r_  )r`  ra  rG   r   )r9   r:   r;   r4  rS  r   r>   r?   r@   r  r  1  sZ            * * * *      r?   r  rC   r1   /tuple[str | BaseBuffer, bool, list[BaseBuffer]]c                
   g }|t          | d          pt          | t                    z  }|s| ||fS t          | t                    r%t          | d          } |                    |            	 t          t          j        |                                 dt          j                            }t          |          D ]} | 
                                 n+# t          |          D ]} | 
                                 w xY w|||gfS )zTry to memory map file/buffer.filenor  r   )access)r   rJ   r3   r   r  r  r   ri  ACCESS_READreversedrN   )rC   r   r  wrappeds       r@   r  r  N  s    !#G'&(++Fz&#/F/FFJ +z7** &# fd##v I4+;  
 
 w'' 	 	FLLNNNN	hw'' 	 	FLLNNNN	 J	))s   -A C (C<c                    d}t          |           } t          | t                    s|S 	 t          j                            |           }n# t          t          f$ r Y nw xY w|S )zTest whether file exists.F)r   rJ   r3   rk   rl   existsrz   rv   )r2   ro  s     r@   file_existsrp  m  ss    F'(:;;(#..  233z"   Ms   A
 
AAc                    d|v sd|v rd|v S t           j        t           j        t           j        f}t	          t          |           |          rdS t          | t                                pdt          | d|          v S )z+Whether the handle is opened in binary moder   r   Fr5   )	r  StreamWriterStreamReaderStreamReaderWriter
issubclassr   rJ   _get_binary_io_classesrR  )rC   r5   text_classess      r@   r  r  {  s     d{{cTkkd{
 	!	L $v,,-- uf46677 3'C C < r?   tuple[type, ...]c                     t           t          f} t          dd          }|R|                                                    d          5 }| t          |          fz  } ddd           n# 1 swxY w Y   | S )z!IO classes that that expect bytesr   ignore)r   Nr?   )r   r   r$   r  stream_readerr   )binary_classesr   r   s      r@   rv  rv    s     )7	'BN &k(CCCD""$$22377 	.6tF||o-N	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. s   	A))A-0A-)r\   r]   rG   r7   )r2   r3   rG   r3   )r2   r-   rG   r-   )r2   ri   rG   ri   )rn   r]   rG   rH   ).)r2   r   r|   r7   rG   r3   )r2   r-   r|   r7   rG   r-   )F)r2   r   r|   r7   rG   ri   )r\   r   rG   r7   )r   Nr   N)r2   r   r4   r3   r6   r   r5   r3   r   r!   rG   r0   )rl   r3   rG   r3   )r6   r   rG   r   )r2   r   r6   r   rG   r   )rl   r   rG   rH   )r   r   r5   r3   r4   r   r6   r   r   r7   r   r   r   r   r   r!   rG   r   )r   r   r5   r3   r4   r   r6   r   r   r7   r   r   r   r   r   r!   rG   r   )r   r   r5   r3   r4   r   r6   r   r   r7   r   r7   r   r   r   r!   rG   r   )rC   r1   r   r7   rG   rg  )r2   r   rG   r7   )rC   r   r5   r3   rG   r7   )rG   rx  )er<   
__future__r   abcr   r   r   r  rY   	functoolsr   ior   r   r   r	   r
   r   r   rk   pathlibr   rer5  typingr   r   r   r   r   r   r   r   r   r   urllib.parser   r   r_   r   r   r   r   rH  pandas._typingr   r   r   r   r    r!   r"   pandas.compatr#   pandas.compat._optionalr$   pandas.util._decoratorsr%   pandas.util._exceptionsr&   pandas.core.dtypes.commonr'   r(   r)   r*   pandas.core.shared_docsr+   setra   discardcompiler   r-   	dataclassr0   rB   rc   rf   r{   r   r   r   r   r   r   valuesr   r   r   r   r   r$  r  r  r  r  r  rp  r  	lru_cacherv  r>   r?   r@   <module>r     s     " " " " " "        


                           				       				                                                         ( ' ' ' ' ' > > > > > > ' ' ' ' ' ' 4 4 4 4 4 4            1 0 0 0 0 0c-+-;<<   B   BJ?@@ gm:666 	 	 	 	 	 	 	 	 ) ) ) ) ) ) ) )X0 0 0 0$ 
   
 
   
   &C C C C: 
    
 
?B    
 $, , , , ,D3 3 3	 	 	 	  !23$%:;>RR   &*&*o o o o	 od0 0 0 0& 
 
  #7>>@@AA  0  0  0  0F &;<?SSTTT5 5 5 UT5pV V V V 

 &)&)     
 

 &) &)     
 

 &)&)     
 &;<}LMMM
  &*&*R R R R R NMRn    gs   44+ 4+ 4+ 4+ 4+O 4+ 4+ 4+n!< !< !< !< !<O !< !< !<H       >       :* * * *>      *      r?   