
    d              
         d Z ddlmZ ddlmZmZ ddlZddlm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#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/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z> ddl?m@Z@ ddlAmBZB ddlCmDZDmEZEmFZFmGZG ddlHmIZI ddlJmKZK  eLe,e*z   e+z             ZMeMN                    d            ejO        d          ZP e#de0          ZQe	jR         G d d                      ZSe	jR         G d dee                               ZTdzdZUe%d{d"            ZVe%d|d#            ZVd}d%ZVd~d(ZWe%ddd,            ZXe%	 ddd-            ZX	 ddd0ZXd1 ZYdd3ZZ e@eKd4         eKd5         d z  6          	 	 	 	 ddd>            Z[dd@Z\dAdAdAdAdBdCdDdEdFdG	Z] eLe]^                                          Z_ddIZ` e@eKd5         d z  J          ddL            ZaddNZbe%d)d)d)d)d)dOddV            Zce%d)d)d)d)d)d)dWddZ            Zce%d)d)d)d)d)d)dWdd\            Zc e@eKd5         dPz  J          ddd.d]dddWdd^            Zc G d_ d`ee          Zd G da dbed          Ze G dc dded          Zf G de df          Zg G dg dh          ZhddlZiddmZjddnZke
jl        ddp            Zm	 ddduZnddyZodS )zCommon IO api utilities    )annotations)ABCabstractmethodN)defaultdict)BufferedIOBaseBytesIO	RawIOBaseStringIO
TextIOBaseTextIOWrapper)Path)IOAnyAnyStrDefaultDictGenericHashableLiteralMappingSequenceTypeVarcastoverload)urljoinurlparseuses_netlocuses_paramsuses_relative)
BaseBufferCompressionDictCompressionOptionsFilePath
ReadBufferReadCsvBufferStorageOptionsWriteBuffer)get_lzma_file)import_optional_dependency)BZ2File)doc)find_stack_level)is_boolis_file_like
is_integeris_list_like)
MultiIndex)_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__r>        L/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/pandas/io/common.pyr6   r6   S   sY           )(((MMMIII    LrE   r6   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    r<   )default_factoryzlist[IO[bytes] | IO[str]]created_handlesFr=   
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)	rL   
isinstancerI   r   flushdetachrK   removeclose)selfrI   s     rF   rT   zIOHandles.closeu   s     ? 	5dk=99999KK    ''444* 	 	FLLNNNN!rE   IOHandles[AnyStr]c                    | S NrD   rU   s    rF   	__enter__zIOHandles.__enter__   s    rE   argsr   c                .    |                                   d S rX   )rT   )rU   r[   s     rF   __exit__zIOHandles.__exit__   s    

rE   NrM   rN   )rM   rV   )r[   r   rM   rN   )r?   r@   rA   rB   rC   dataclassesfieldlistrK   rL   rT   rZ   r]   rD   rE   rF   rH   rH   `   s               1B1BSW1X1X1XOXXXXJ       "        rE   rH   urlobjectrM   r=   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)rP   r9   	parse_urlscheme_VALID_URLSrb   s    rF   is_urlri      s/     c3 uS>> K//rE   r8   r9   c                    d S rX   rD   r8   s    rF   _expand_userrl          CrE   c                    d S rX   rD   rk   s    rF   rl   rl      rm   rE   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
    )rP   r9   ospath
expanduserrk   s    rF   rl   rl      s4     $c** 6w!!"4555rE   headerrN   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   NrD   ).0is     rF   	<genexpr>z&validate_header_arg.<locals>.<genexpr>   s&      %%q1u%%%%%%rE   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)rt   s    rF   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BrE   .r"   convert_file_likec                    d S rX   rD   r8   r   s     rF   stringify_pathr      rm   rE   c                    d S rX   rD   r   s     rF   r   r      s	     CrE   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   r3   rP   rq   PathLike
__fspath__rl   r   s     rF   r   r      se    .  5.@!A!A 5 K!3444$bk22 =/::<<*+++rE   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)r[   kwargsurllibs      rF   r   r     s*    
 !6>!426222rE   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://)rP   r9   r=   _RFC_3986_PATTERNmatch
startswithrh   s    rF   is_fsspec_urlr     sM     	3 	8"((--..	86777rE   storage_optionscompression_options)r   r   utf-8rr:   r<   r!   r;   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)r8   r:   r<   r>   r;   zs3a://zs3://zs3n://fsspecbotocore)ClientErrorNoCredentialsErrorr;   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UnicodeWarningrP   r9   ri   r   r   Requestr   r   getr   r   r6   r   r   replacer(   botocore.exceptionsr   r   PermissionErrorImportErroropentupler|   bytesmmaprl   type)r8   r:   r<   r;   r   compression_methodfsspec_moder   req_inforeqcontent_encodingreaderr   err_types_to_retry_with_anonr   r   file_objmsgs                     rF   _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rr   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   )rr   r   s     rF   file_path_to_urlr     s0     ,+++++7LL..///rE   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)rP   r   r   popKeyErrorr|   )r<   compression_argsr   errs       rF   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   rP   r9   extension_to_compressionitemslowerendswith_supported_compressionssortedr|   )r8   r<   	extensionvalidr   s        rF   r   r     s    4 t g+,>RVWWW,c22 	4 '?&D&D&F&F 	# 	#"I{!''))229== #""""#t ---dOf%<===E	/+ 	/ 	/',	/ 	/  S//rE   
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)rr   r   s     rF   check_parent_directoryr   M  sI     $ZZF==?? VT6TTTUUUV VrE   )r:   r<   
memory_maperrorsr   path_or_bufr   is_textLiteral[False]r   IOHandles[bytes]c                   d S rX   rD   r   r;   r:   r<   r   r   r   r   s           rF   
get_handler   [  	     CrE   )r:   r<   r   r   r   r   Literal[True]IOHandles[str]c                   d S rX   rD   r   s           rF   r   r   j  r   rE   !IOHandles[str] | IOHandles[bytes]c                   d S rX   rD   r   s           rF   r   r   y  r   rE   Tc               :   |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	          |	                     |r3|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|}	no|dk    rt#          |	fd|j        i|}	nS|dk    rt%          |	|j        fi |}	|	j        j        dk    r|
                    |	           |	j                                        }t-          |          dk    r.|	j                            |                                          }	n|st1          d|            t1          d|           n|dk    r|                    d|j                   t          |	t                    rt5          d*d|	i|}	nt5          d*d|	i|}	t          |	t4                    sJ d|	j        j        v r|
                    |	           |	j                                        }t-          |          dk    r'|	j                            |d                   }|J |}	n|st1          d|            t1          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| }t1          |          t          |	t                    rJ |
                    |	           nnt          |	t                    rY|j!        r(d|j        vrt/          |	|j        |j!        |d	          }	nt/          |	|j                  }	|
                    |	           d }|s7|j        d!k    r,t          |	tD                    rtG          |	|j!        "          }	n|r|s|st          |	|j                  rtI          |	d#          r tI          |	d$          rtI          |	d%          stK          |	          }	tM          |	|j!        |d	          }	|
                    |	           t          |j        t                    p|j'         }d|j        v r5tI          |	d&          s%tQ          d'tS          |j                   d(          |
*                                 |j'        r6t          |j        t                    rJ |
                    |j                   tW          |	|
||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   )r:   r<   r;   r   r   r   r   r   r2   r   )filenamer;   )fileobjr;   r   r;   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   )r:   r   newlineFrb)r:   readablewritableseekabler   z1Expected file path name or file-like object, got z type)rI   rK   rL   r<   rD   ),_is_binary_modecodecslookuprP   r9   lookup_errorr   r8   _maybe_memory_mapr   r<   r   r   r;   r   r   GzipFile_BZ2File_BytesZipFilebufferappendnamelistlenr   r|   
setdefault_BytesTarFilegetnamesextractfiler'   r(   ZstdDecompressorZstdCompressorr:   r   _BytesIOWrapperr   
_IOWrapperr   r>   r   r   reverserH   )r   r;   r:   r<   r   r   r   r   ioargsrI   handlesis_pathr   	zip_namesfilesfiler   	open_argsr   rL   s                       rF   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   &
 
 
 
rE   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.
    rM   rN   c                    d S rX   rD   rY   s    rF   write_to_bufferz_BufferedWriter.write_to_buffer  s    rE   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,  rT   super)rU   	__class__s    rF   rT   z_BufferedWriter.close  s    ; 	F==?? 	 IIaLLL ' '$$&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' Ks   AA #A r^   )r?   r@   rA   rB   r   r,  rT   __classcell__r2  s   @rF   r*  r*    sg         
    ^         rE   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   r;   Literal['r', 'a', 'w', 'x']r  -ReadBuffer[bytes] | WriteBuffer[bytes] | Nonearchive_namerM   rN   c                    t                                                       || _        || _        t	          j        j        d||                     |          |d|| _        d S )N)r  r;   r  rD   )	r1  __init__r8  r  tarfileTarFiler   extend_moder  )rU   r  r;   r  r8  r   r2  s         rF   r:  z_BytesTarFile.__init__  sq     	(	 o* 
!!$''
 
 	
 
rE   r9   c                    |                     dd          }|dk    r|S | j        ,t          | j                  j        }|dv r| d|dd           }|S )Nr   r2   r   )r   r   r   :r  )r   r  r   suffix)rU   r;   r@  s      rF   r=  z_BytesTarFile.extend_mode  sg    ||C$$3;;K9 $)__+F///----rE   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   r2   )r   r   r   )r  r   r@  with_suffixrU   r  s     rF   infer_filenamez_BytesTarFile.infer_filename  s}    
 94	???f$$''++00_ BBB''++77;;@@}rE   c                    | j         p|                                 pd}t          j        |          }t	          |                                           |_        | j                            ||            d S )Nr   )r  )	r8  rD  r;  TarInfor  r/  sizer  addfile)rU   r8  tarinfos      rF   r,  z_BytesTarFile.write_to_buffer  sg    (JD,?,?,A,AJU/|4444==??++GT*****rE   )Nr   NN)
r  r   r;   r6  r  r7  r8  r   rM   rN   )r;   r9   rM   r9   rM   r   r^   )r?   r@   rA   r:  r=  rD  r,  r3  r4  s   @rF   r  r    s          ,/AE#'
 
 
 
 
 
 
*      + + + + + + + +rE   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]r;   r9   r8  r   rM   rN   c                    t                                                       |                    dd          }|| _        |                    dt
          j                   t          j        ||fi || _        d S )Nr   r2   r<   )	r1  r:  r   r8  r  zipfileZIP_DEFLATEDZipFiler  )rU   r'  r;   r8  r   r2  s        rF   r:  z_BytesZipFile.__init__  sp     	||C$$(-)=>>> odD;;F;;rE   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   r2   N)
rP   r  r  rq   r   r9   r   r@  rB  r  rC  s     rF   rD  z_BytesZipFile.infer_filename  se    
 dk*R[#,>?? 	!DK011H&((++B//44= trE   c                    | j         p|                                 pd}| j                            ||                                            d S )Nr   )r8  rD  r  writestrr/  )rU   r8  s     rF   r,  z_BytesZipFile.write_to_buffer  sF    (JD,?,?,A,AJU\4==??;;;;;rE   rX   )r'  rL  r;   r9   r8  r   rM   rN   rJ  r^   )r?   r@   rA   r:  rD  r,  r3  r4  s   @rF   r  r    so        
 $(	< < < < < < <"
 
 
 
< < < < < < < <rE   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   rM   rN   c                    || _         d S rX   )r  )rU   r  s     rF   r:  z_IOWrapper.__init__  s    rE   r  r9   c                ,    t          | j        |          S rX   getattrr  )rU   r  s     rF   __getattr__z_IOWrapper.__getattr__      t{D)))rE   r=   c                b    t          | j        d          r| j                                        S dS )Nr
  T)r   r  r
  rY   s    rF   r
  z_IOWrapper.readable"  /    4;
++ 	*;'')))trE   c                b    t          | j        d          r| j                                        S dS )Nr  T)r   r  r  rY   s    rF   r  z_IOWrapper.seekable'  r\  rE   c                b    t          | j        d          r| j                                        S dS )Nr  T)r   r  r  rY   s    rF   r  z_IOWrapper.writable,  r\  rE   N)r  r   rM   rN   )r  r9   )rM   r=   )r?   r@   rA   r:  rY  r
  r  r  rD   rE   rF   r   r     sx           * * * *   
   
     rE   r   c                  *    e Zd ZdddZdd
ZdddZdS )r  r   r  StringIO | TextIOBaser:   r9   rM   rN   c                0    || _         || _        d| _        d S )NrE   )r  r:   overflow)rU   r  r:   s      rF   r:  z_BytesIOWrapper.__init__5  s     
 rE   attrc                ,    t          | j        |          S rX   rW  )rU   rc  s     rF   rY  z_BytesIOWrapper.__getattr__>  rZ  rE   n
int | Noner   c                
   | j         J | j                             |                              | j                  }| j        |z   }||dk     s|t          |          k    r	d| _        |S |d |         }||d          | _        |S )Nr   rE   )r  r   encoder:   rb  r  )rU   rf  
bytestringcombined_bytestring	to_returns        rF   r   z_BytesIOWrapper.readA  s    {&&&[%%a((//>>
"mj89Ac*=&>&>!>!>DM&&+BQB/I/3DMrE   N)r   )r  r`  r:   r9   rM   rN   )rc  r9   )re  )rf  rg  rM   r   )r?   r@   rA   r:  rY  r   rD   rE   rF   r  r  2  sZ            * * * *      rE   r  rI   r7   /tuple[str | BaseBuffer, bool, list[BaseBuffer]]c                4   g }|t          | d          pt          | t                    z  }|s| ||fS t          t          |           } 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   rP   r9   r   r$   r   r  r   r   ro  ACCESS_READreversedrT   )rI   r   r#  wrappeds       rF   r  r  O  s/    !#G'&(++Fz&#/F/FFJ +z7** -((F &# fd##v I4+;  
 
 w'' 	 	FLLNNNN	hw'' 	 	FLLNNNN	 J	))s   A C) )(D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   rP   r9   rq   rr   existsr   r|   )r8   ru  s     rF   file_existsrv  q  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   Fr;   )	r  StreamWriterStreamReaderStreamReaderWriter
issubclassr   rP   _get_binary_io_classesrX  )rI   r;   text_classess      rF   r  r    s     d{{cTkkd{
 	!	L $v,,-- uf46677 3'C C < rE   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   NrE   )r   r	   r(   r  stream_readerr   )binary_classesr   r   s      rF   r|  r|    s     )7	'BN &k(CCCD""$$22377 	.6tF||o-N	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. s   	A))A-0A-columnsSequence[Hashable] | MultiIndex	index_colbool | Sequence[int] | Nonec                    t          t                    rg t          t          |           o0t          | t                     ot	          fd| D                                 S )a  
    Check whether or not the `columns` parameter
    could be converted into a MultiIndex.

    Parameters
    ----------
    columns : array-like
        Object which may or may not be convertible into a MultiIndex
    index_col : None, bool or list, optional
        Column or columns to use as the (possibly hierarchical) index

    Returns
    -------
    bool : Whether or not columns could become a MultiIndex
    Nc              3  d   K   | ]*}|t                    vt          |t                    V  +d S rX   )ra   rP   r   )rx   cr  s     rF   rz   z+is_potential_multi_index.<locals>.<genexpr>  s=      RR$y//9Q9Q
1e$$9Q9Q9Q9QRRrE   )rP   r=   r  r0   r}   )r  r  s    `rF   is_potential_multi_indexr    sv    & Jy$77	G 	S7J///	SRRRRgRRRRR  rE   namesSequence[Hashable]is_potential_multiindexc                L   t          |           } t          t                    }t          |           D ]p\  }}||         }|dk    rP|dz   ||<   |r1t	          |t
                    sJ |dd         |d          d| fz   }n| d| }||         }|dk    P|| |<   |dz   ||<   q| S )a:  
    Rename column names if duplicates exist.

    Currently the renaming is done by appending a period and an autonumeric,
    but a custom pattern may be supported in the future.

    Examples
    --------
    >>> dedup_names(["x", "y", "x", "x"], is_potential_multiindex=False)
    ['x', 'y', 'x.1', 'x.2']
    r   r  Nre  .)ra   r   r{   	enumeraterP   r   )r  r  countsry   col	cur_counts         rF   dedup_namesr    s     KKE)4S)9)9FE"" $ $33K	!mm#a-F3K& +!#u-----#2#hSW":":y":":!<<**y**sI !mm a!msLrE   )rb   rc   rM   r=   )r8   r9   rM   r9   )r8   r3   rM   r3   )r8   ro   rM   ro   )rt   rc   rM   rN   ).)r8   r"   r   r=   rM   r9   )r8   r3   r   r=   rM   r3   )F)r8   r   r   r=   rM   ro   )rb   r   rM   r=   )r   Nr   N)r8   r   r:   r9   r<   r!   r;   r9   r   r%   rM   r6   )rr   r9   rM   r9   )r<   r!   rM   r   )r8   r   r<   r   rM   r   )rr   r   rM   rN   )r   r   r;   r9   r:   r   r<   r!   r   r=   r   r   r   r   r   r%   rM   r   )r   r   r;   r9   r:   r   r<   r!   r   r=   r   r   r   r   r   r%   rM   r   )r   r   r;   r9   r:   r   r<   r!   r   r=   r   r=   r   r   r   r%   rM   r   )rI   r7   r   r=   rM   rm  )r8   r   rM   r=   )rI   r   r;   r9   rM   r=   )rM   r~  rX   )r  r  r  r  rM   r=   )r  r  r  r=   rM   r  )prB   
__future__r   abcr   r   r  collectionsr   r_   	functoolsr   ior   r   r	   r
   r   r   r   rq   pathlibr   rer;  typingr   r   r   r   r   r   r   r   r   r   r   r   urllib.parser   r   re   r   r   r   r   rN  pandas._typingr   r    r!   r"   r#   r$   r%   r&   pandas.compatr'   pandas.compat._optionalr(   pandas.compat.compressorsr)   r  pandas.util._decoratorsr*   pandas.util._exceptionsr+   pandas.core.dtypes.commonr,   r-   r.   r/   pandas.core.indexes.apir0   pandas.core.shared_docsr1   setrg   discardcompiler   r3   	dataclassr6   rH   ri   rl   r   r   r   r   r   r   r   valuesr   r   r   r   r   r*  r  r  r   r  r  rv  r  	lru_cacher|  r  r  rD   rE   rF   <module>r     s     " " " " " "         # # # # # #                          				       				                                           	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ( ' ' ' ' ' > > > > > > 9 9 9 9 9 9 ' ' ' ' ' ' 4 4 4 4 4 4            / . . . . . 0 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& 
 
  #6==??@@  0  0  0  0F &;<?SSTTT3 3 3 UT3l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       :       :* * * *D      *    & .2    :" " " " " "rE   