
    `Vg              
         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         ZDeDj                  d        ej                  d      ZG e de-      ZHej                   G d d             ZJej                   G d dee                ZKdKdZLe"dLd       ZMe"dMd       ZMdNdZMdOdZNe"dPdQd       ZOe"	 dP	 	 	 	 	 dRd        ZO	 dS	 	 	 	 	 dTd"ZOd# ZPdUd$ZQ e9eBd%   eBd&   dz  '      	 	 	 	 dV	 	 	 	 	 	 	 	 	 	 	 dWd(       ZRdXd)ZSd*d*d*d*d+d,d-d.d/d0	ZT eCeTj                               ZV	 	 	 	 dYd1ZW e9eBd&   dz  2      	 	 	 	 	 	 dZd3       ZXd[d4ZYe"dddddd5	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d\d7       ZZe"ddddddd8	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d]d9       ZZe"ddddddd8	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d^d:       ZZ e9eBd&   d6z  2      ddd!d;ddd8	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d^d<       ZZ G d= d>ee      Z[ G d? d@e[      Z\ G dA dBe[      Z] G dC dD      Z^ G dE dF      Z_	 	 	 	 	 	 d_dGZ`d`dHZadadIZbe	j                  dbdJ       Zdy)cz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                  H    e Zd ZU dZded<   ded<   ded<   ded<   d	Zd
ed<   y)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        Q/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/pandas/io/common.pyr0   r0   N   s)     )(M
I  L$r?   r0   c                  |    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y)	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_wrappedc                d   | j                   rut        | j                  t              sJ | j                  j	                          | j                  j                          | j                  j                  | j                         | j                  D ]  }|j                           g | _        d| _         y)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@   rL   zIOHandles.closep   s     ??dkk=999KKKK   ''4** 	FLLN	!r?   c                    | S Nr>   rM   s    r@   	__enter__zIOHandles.__enter__   s    r?   c                $    | j                          y rO   )rL   )rM   argss     r@   __exit__zIOHandles.__exit__   s    

r?   NreturnNone)rV   zIOHandles[AnyStr])rS   r   rV   rW   )r9   r:   r;   r<   r=   dataclassesfieldlistrE   rF   rL   rQ   rT   r>   r?   r@   rB   rB   [   sG       1B1B1BSW1XO.XJ "r?   rB   c                Z    t        | t              sy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)rH   r3   	parse_urlscheme_VALID_URLSurls    r@   is_urlra      s&     c3S>  K//r?   r2   c                     y rO   r>   r2   s    r@   _expand_userrd          r?   c                     y rO   r>   rc   s    r@   rd   rd      re   r?   c                d    t        | t              rt        j                  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
    )rH   r3   ospath
expanduserrc   s    r@   rd   rd      s+     $c*ww!!"455r?   c                `   | y t        |       r!t        t        |       } | dk  rt        d      y t	        | d      rRt        t
        |       } t        t        t         |             st        d      t        d | D              rt        d      y 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    yw)r   Nr>   ).0is     r@   	<genexpr>z&validate_header_arg.<locals>.<genexpr>   s     %q1u%s   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)headers    r@   validate_header_argrx      s    ~&c6"A:9  	Fu-h'3z6*+IJJ%f%%WXXv4
 	
 A
BBr?   .c                     y rO   r>   r2   convert_file_likes     r@   stringify_pathr|      re   r?   c                     y rO   r>   rz   s     r@   r|   r|      s     r?   Fc                    |st        |       rt        t        |       S t        | t        j
                        r| j                         } 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-   rH   rh   PathLike
__fspath__rd   rz   s     r@   r|   r|      sI    . .@!A K!344$bkk2/::<*++r?   c                 B    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)rS   kwargsurllibs      r@   r   r     s#    
 !6>>!!42622r?   c                    t        | t              xr2 t        t        j	                  |             xr | j                  d       S )zR
    Returns true if the given URL looks like
    something fsspec can handle
    )zhttp://zhttps://)rH   r3   r7   _RFC_3986_PATTERNmatch
startswithr_   s    r@   is_fsspec_urlr     sA     	3 	8"((-.	8677r?   storage_optionscompression_options)r   r   c                &   t        |       } t        |      \  }}t        | |      }|r6t        | d      r*d|vr&t	        j
                  dt        t                      d}t        ||      }d|v r1|dv r-|d	v r)t	        j
                  | d
| t        t                      |}d|vr	d|vr|dz  }t        | t              rt        |       r|xs i }ddl}|j                  j                  | |      }t!        |      5 }	|	j"                  j%                  dd      }
|
dk(  rddi}t'        |	j)                               }ddd       t+        ||d|      S t-        |       rt        | t              sJ | j/                  d      r| j1                  dd      } | j/                  d      r| j1                  dd      } t3        d      }g }	 t3        d       ddlm}m} ||t:        g}	  |j>                  | fd|i|xs i j?                         }t+        |||d|      S |rtC        d      t        | t        tD        tF        jF                  f      rt+        tI        |       ||d|      S t        | d      s%t        | d      sdtK        |        }tC        |      t+        | ||d|      S # 1 sw Y   kxY w# t<        $ r Y w xY w# tA        |      $ rB |ddi}nt        |      }d|d<    |j>                  | fd|i|xs i j?                         }Y w xY w)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UnicodeWarningrH   r3   ra   r   r   Requestr   r   getr   r   r0   r   r   replacer$   botocore.exceptionsr   r   PermissionErrorImportErroropentuplerr   bytesmmaprd   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     s   D ((:; '=[&I#*+=?QR g&8'BsRVR')	

 "{+=>K
 	t-/,,mCH:N')	
 K
+#["8s$c*v6H/I */R 	 >>))*<o)VX 	)#"{{/A4H6)'0SXXZ(F	) %#
 	
 '(
 	
 
 ((2!3!;!;Hg!N((2!3!;!;Hg!N+H5 35$	&z2 ",(	"v{{")49H9NBdf  '#
 	
 
M
 	
 $sE499&=>+,>?#
 	
 	"F+w7I7/S9$?Q:R9STo- u	) 	)T  		 12 		&#)4. #'"7*.'"v{{")49H9NBdf 		s1   <?J$J1 !'K  $J.1	J=<J= ALLc                2    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   )ri   r   s     r@   file_path_to_urlr     s     ,7L.//r?   tarr   r   zipr   zstd)	.tar.tar.gz.tar.bz2.tar.xz.gz.bz2.zip.xzz.zstc                    t        | t              r!t        |       }	 |j                  d      }||fS i }| }||fS # t        $ r}t        d      |d}~ww xY w)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)rH   r   r   popKeyErrorrr   )r6   compression_argsr   errs       r@   r   r     s{    . +w',	X!1!5!5h!? /// (///  	XMNTWW	Xs   : 	AAA)r   c                0   |y|dk(  r^t        | d      } t        | t              syt        j	                         D ](  \  }}| j                         j                  |      s&|c S  y|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|   rH   r3   _extension_to_compressionitemslowerendswith_supported_compressionssortedrr   )r2   r6   	extensionvalidr   s        r@   r   r     s    4  g+,>RVW,c2 '@&E&E&G 	#"I{!'')229=""	#  -- dOf%<==E
)+ 7'',g	/  S/r?   c                l    t        |       j                  }|j                         st        d| d      y)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)ri   r   s     r@   check_parent_directoryr   J  s7     $ZF==?J6(RSTUU r?   )r4   r6   
memory_maperrorsr   path_or_bufc                    y rO   r>   r   r5   r4   r6   r   is_textr   r   s           r@   
get_handler   X       r?   )r4   r6   r   r   r   r   c                    y rO   r>   r   s           r@   r   r   g  r   r?   c                    y rO   r>   r   s           r@   r   r   v  r   r?   Tc                  |xs d}|xs d}t        | |      r	d|vr|dz  }t        j                  |       t        |t              rt        j
                  |       t        | ||||      }|j                  }	t        |	|      \  }	}}
t        |	t              }t        |j                        }|j                  d      }d|vr|rt        t	        |	             |r<|dk7  r"|j                  j                  dd	      |_        n(|dk(  r#d|j                  vr|xj                  dz  c_        |d
k(  rXt        |	t              r$t        j                   d)|	|j                  d|}	nt        j                   d)|	|j                  d|}	nl|dk(  r$t#        j$                  |	fd|j                  i|}	nC|dk(  rt'        |	|j                  fi |}	|	j(                  j                  dk(  r|
j+                  |	       |	j(                  j-                         }t/        |      dk(  r+|	j(                  j1                  |j                               }	n|st3        d|        t3        d|       |dk(  r|j5                  d|j                         t        |	t              rt7        d)d|	i|}	nt7        d)d|	i|}	t        |	t6              sJ d|	j(                  j                  v r|
j+                  |	       |	j(                  j9                         }t/        |      dk(  r%|	j(                  j;                  |d         }|J |}	n|st3        d|        t3        d|       |dk(  r t=               |	|j                        }	nw|dk(  rbt?        d      }d|j                  v rd |j@                  d)i |i}nd |jB                  d)i |i} |j0                  |	fd|j                  i|}	nd| }t3        |      t        |	t              rJ |
j+                  |	       nvt        |	t              rf|jD                  r3d|j                  vr%t1        |	|j                  |jD                  |d	      }	nt1        |	|j                        }	|
j+                  |	       d}|s7|j                  d k(  r(t        |	tF              rtI        |	|jD                  !      }	n|r|s|st        |	|j                        rtK        |	d"      rtK        |	d#      rtK        |	d$      stM        |	      }	tO        |	|jD                  |d	      }	|
j+                  |	       t        |j                  t              xs |jP                   }d|j                  v r.tK        |	d%      s"tS        d&tU        |j                         d'      |
jW                          |jP                  r7t        |j                  t              rJ |
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
    utf-8strictr   )r4   r6   r5   r   r   rr   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   z 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lookuprH   r3   lookup_errorr   r2   _maybe_memory_mapr   r6   r   r   r5   r   r   GzipFiler   BZ2File_BytesZipFilebufferappendnamelistlenr   rr   
setdefault_BytesTarFilegetnamesextractfiler#   r$   ZstdDecompressorZstdCompressorr4   r
   _BytesIOWrapperr   
_IOWrapperr   r8   rv   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o MM(&#F# %'F &&F
 #4FJ"GFJ%GF../"&&x0K $7s6{+&  ++--c26FKF"s&++'= KK3K & &#&  # '   #	
 ' E! [[[[ #F E! #'7F }}!!S(v&"MM224	y>Q&#]]//	@F"$'D[M%RSS$22;>  E!''<&#&&GFG6FG
 ' "&6 fm444fmm(((v&..0u:?!==44U1X>D+++!F$'G}%UVV$::?B  D  %]_VV[[9F F"-k:Dfkk!#%:T%:%:%N=M%NO	#%8T%8%8%L;K%LM	TYY[[ F 4K=ACS/!fc***v	FC	  ??s&++5F &&++.Fv Jv{{d*z&*/M __
 
z_VV[[%I 
+6:.6:.'F __	
 	v v00#6M&:M:M

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

 OOf77===v001   &&
 
r?   c                  6     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.
    c                     y rO   r>   rP   s    r@   write_to_bufferz_BufferedWriter.write_to_buffer  s    r?   c                   | j                   ry | j                         r7| j                  d       | j                  5  | j	                          d d d        n| j                  j                          t        |           y # 1 sw Y   xY w)Nr   )closedgetvalueseekr  r  rL   super)rM   	__class__s    r@   rL   z_BufferedWriter.close  si    ;;==?IIaL '$$&' ' KK' 's   A??BrU   )r9   r:   r;   r<   r   r  rL   __classcell__r  s   @r@   r  r    s&    
   r?   r  c                  T     e Zd Z	 	 	 	 d	 	 	 	 	 	 	 	 	 d fdZddZddZd	dZ xZS )
r  c                    t         |           || _        || _        t	        j
                  j                  d|| j                  |      |d|| _        y )N)r   r5   r   r>   )	r  __init__archive_namer   tarfileTarFiler   extend_moder  )rM   r   r5   r   r%  r   r  s         r@   r$  z_BytesTarFile.__init__  sZ     	(	 oo** 
!!$'
 	
r?   c                    |j                  dd      }|dk7  r|S | j                  -t        | j                        j                  }|dv r
| d|dd   }|S )Nr   r,   r   )r   r   r   :r   )r   r   r   suffix)rM   r5   r+  s      r@   r(  z_BytesTarFile.extend_mode  s_    ||C$3;K99 $))_++F//q-r?   c                "   | j                   yt        | j                         }|j                  dk(  r|j                  d      j                   S |j                  dv r*|j                  d      j                  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rM   r   s     r@   infer_filenamez_BytesTarFile.infer_filename  sz    
 99		???f$''+000__ BB''+77;@@@}}r?   c                    | j                   xs | j                         xs d}t        j                  |      }t	        | j                               |_        | j                  j                  ||        y )Nr   )r   )	r%  r/  r&  TarInfor  r  sizer  addfile)rM   r%  tarinfos      r@   r  z_BytesTarFile.write_to_buffer  sT    ((JD,?,?,AJU//|44==?+GT*r?   )Nr   NN)
r   
str | Noner5   zLiteral['r', 'a', 'w', 'x']r   z-ReadBuffer[bytes] | WriteBuffer[bytes] | Noner%  r5  rV   rW   )r5   r3   rV   r3   rV   r5  rU   )r9   r:   r;   r$  r(  r/  r  r   r!  s   @r@   r  r    sU      ,/AE#'

 *
 ?	

 !
 

*+r?   r  c                  B     e Zd Z	 d	 	 	 	 	 	 	 d fdZddZddZ xZS )r  c                    t         |           |j                  dd      }|| _        |j	                  dt
        j                         t        j                  ||fi || _        y )Nr   r,   r6   )	r  r$  r   r%  r  zipfileZIP_DEFLATEDZipFiler  )rM   r  r5   r%  r   r  s        r@   r$  z_BytesZipFile.__init__  sW     	||C$(-)=)=> oodD;F;r?   c                   t        | j                  j                  t        j                  t
        f      rUt        | j                  j                        }|j                  dk(  r|j                  d      j                  S |j                  S y)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)
rH   r  r   rh   r   r3   r   r+  r-  r   r.  s     r@   r/  z_BytesZipFile.infer_filename   se    
 dkk**R[[#,>?DKK001H&(++B/444== r?   c                    | j                   xs | j                         xs d}| j                  j                  || j	                                y )Nr   )r%  r/  r  writestrr  )rM   r%  s     r@   r  z_BytesZipFile.write_to_buffer  s:    ((JD,?,?,AJU\4==?;r?   rO   )r  z1FilePath | ReadBuffer[bytes] | WriteBuffer[bytes]r5   r3   r%  r5  rV   rW   r6  rU   )r9   r:   r;   r$  r/  r  r   r!  s   @r@   r  r    s=    
 $(	<?< < !	< 
<"
<r?   r  c                  4    e Zd ZddZddZd	dZd	dZd	dZy)
r  c                    || _         y rO   )r  )rM   r  s     r@   r$  z_IOWrapper.__init__  s	    r?   c                .    t        | j                  |      S rO   getattrr  )rM   r   s     r@   __getattr__z_IOWrapper.__getattr__      t{{D))r?   c                d    t        | j                  d      r| j                  j                         S y)Nr   T)r   r  r   rP   s    r@   r   z_IOWrapper.readable  &    4;;
+;;''))r?   c                d    t        | j                  d      r| j                  j                         S y)Nr   T)r   r  r   rP   s    r@   r   z_IOWrapper.seekable%  s&    4;;
+;;''))r?   c                d    t        | j                  d      r| j                  j                         S y)Nr   T)r   r  r   rP   s    r@   r   z_IOWrapper.writable*  rG  r?   N)r  r   rV   rW   )r   r3   )rV   r7   )r9   r:   r;   r$  rD  r   r   r   r>   r?   r@   r  r    s    *
r?   r  c                  (    e Zd ZdddZddZdd	dZy)
r  c                .    || _         || _        d| _        y )Nr?   )r  r4   overflow)rM   r  r4   s      r@   r$  z_BytesIOWrapper.__init__4  s     
 r?   c                .    t        | j                  |      S rO   rB  )rM   attrs     r@   rD  z_BytesIOWrapper.__getattr__=  rE  r?   c                   | j                   J | j                   j                  |      j                  | j                        }| j                  |z   }||dk  s|t        |      k\  r	d| _        |S |d | }||d  | _        |S )Nr   r?   )r  r   encoder4   rL  r  )rM   n
bytestringcombined_bytestring	to_returns        r@   r   z_BytesIOWrapper.read@  s    {{&&&[[%%a(//>
"mmj89Ac*=&>!>DM&&+BQ/I/3DMr?   N)r   )r  zStringIO | TextIOBaser4   r3   rV   rW   )rN  r3   ))rQ  z
int | NonerV   r   )r9   r:   r;   r$  rD  r   r>   r?   r@   r  r  1  s    *r?   r  c                   g }|t        | d      xs t        | t              z  }|s| ||fS t        | t              rt        | d      } |j	                  |        	 t        t        j                  | j                         dt        j                              }t        |      D ]  } | j                           	 |||gfS # t        |      D ]  } | j                           w xY w)zTry to memory map file/buffer.filenor   r   )access)r   rH   r3   r   r  r  r   rW  ACCESS_READreversedrL   )rC   r   r  wrappeds       r@   r   r   N  s     !#G'&(+Fz&#/FFJz7** &#fd#v II4+;+;
 w' 	FLLN	 J	))	 w' 	FLLN	s   =B= ="Cc                    d}t        |       } t        | t              s|S 	 t        j                  j                  |       }|S # t        t        f$ r Y |S w xY w)zTest whether file exists.F)r|   rH   r3   rh   ri   existsrv   rr   )r2   r]  s     r@   file_existsr^  m  s`    F'(:;(#. 23 M z" Ms   A AAc                    d|v sd|v rd|v S t         j                  t         j                  t         j                  f}t	        t        |       |      ryt        | t                     xs dt        | d|      v S )z+Whether the handle is opened in binary moder   r   Fr5   )	r   StreamWriterStreamReaderStreamReaderWriter
issubclassr   rH   _get_binary_io_classesrC  )rC   r5   text_classess      r@   r   r   {  s     d{cTkd{
 	!!	L $v,-f467 3'C < r?   c                     t         t        f} t        dd      }|9|j                         j	                  d      5 }| t        |      fz  } ddd       | S | S # 1 sw Y   | S xY w)z!IO classes that that expect bytesr   ignore)r   Nr?   )r   r   r$   r
  stream_readerr   )binary_classesr   r   s      r@   rd  rd    sp     )7	'BN &k(CD""$2237 	.6tF|o-N	. >	. s   AA!)r`   objectrV   r7   )r2   r3   rV   r3   )r2   r-   rV   r-   )r2   str | BaseBufferTrV   rk  )rw   rj  rV   rW   ).)r2   r   r{   r7   rV   r3   )r2   r-   r{   r7   rV   r-   )F)r2   zFilePath | BaseBufferTr{   r7   rV   rk  )r`   FilePath | BaseBufferrV   r7   )r   Nr   N)r2   rl  r4   r3   r6   r   r5   r3   r   r!   rV   r0   )ri   r3   rV   r3   )r6   r   rV   z"tuple[str | None, CompressionDict])r2   rl  r6   r5  rV   r5  )ri   z
Path | strrV   rW   )r   rl  r5   r3   r4   r5  r6   r   r   r7   r   zLiteral[False]r   r5  r   r!   rV   zIOHandles[bytes])r   rl  r5   r3   r4   r5  r6   r   r   r7   r   zLiteral[True]r   r5  r   r!   rV   zIOHandles[str])r   rl  r5   r3   r4   r5  r6   r   r   r7   r   r7   r   r5  r   r!   rV   z!IOHandles[str] | IOHandles[bytes])rC   r1   r   r7   rV   z/tuple[str | BaseBuffer, bool, list[BaseBuffer]])r2   rl  rV   r7   )rC   rl  r5   r3   rV   r7   )rV   ztuple[type, ...])er<   
__future__r   abcr   r   r   r   rX   	functoolsr   ior   r   r   r	   r
   r   r   rh   pathlibr   rer&  typingr   r   r   r   r   r   r   r   r   r   urllib.parser   r   r\   r   r   r   r   r9  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+   setr^   discardcompiler   r-   	dataclassr0   rB   ra   rd   rx   r|   r   r   r   r   r   valuesr   r   r   r   r   r  r  r  r  r  r   r^  r   	lru_cacherd  r>   r?   r@   <module>r     sc    "        	  	         ( > ' 4  1-+-;<   B BJJ?@ m:6 	 	 	 ) ) )X0$ 
 
 
 
&C: 
 
 
?B#8< 
 $,.,, ,D3	  !23$%:;>RR &*&*o-oo $o 	o
 $o o	od0& 
  7>>@A  0# 0' 0F &;<?SST5-5<F55 U5pV 

 &)&)&
 	
 $    $  
 

 &) &)&
 	
 $    $  
 

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