a
    oÝEb®“  ã                   @  s&  d Z ddl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	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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,m-Z-m.Z.m/Z/m0Z0 dd
l1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z< e=e&e$ e% ƒZ>e> ?d¡ e @d¡ZAede*d�ZBejCG dd„ dƒƒZDejCG dd„ dee ƒƒZEdddœdd„ZFedddœdd „ƒZGedddœd!d „ƒZGd"d"dœd#d „ZGdd$d%œd&d'„ZHedxd)ddd*œd+d,„ƒZIedydddd*œd-d,„ƒZIdzd/dd"d*œd0d,„ZId1d2„ ZJd3ddœd4d5„ZKe6e<d6 d7 d8�d{d3dd;dd<dd=œd>d?„ƒZLddd@œdAdB„ZMdCdDdEdFdGdHœZNd;dIdJœdKdL„ZOe6e<d6 d7 d8�d3dMdMdNœdOdP„ƒZPdQd$d@œdRdS„ZQed(d(d(d(d(dTœd3ddMd;ddUdMd<dVdWœ	dXdY„ƒZRed(d(d(d(d(d(dZœd3ddMd;dd[dMd<d\dWœ	d]dY„ƒZRe6e<d6 d^ d8�ddd.d_dddZœd3ddMd;dddMd<d`dWœ	dadY„ƒZRG dbdc„ dce(jSeƒZTG ddde„ deejUƒZVG dfdg„ dgƒZWG dhdi„ diƒZXdjddddMddkdlœdmdn„ZYd3ddœdodp„ZZd3dddqœdrds„Z[ej\dtduœdvdw„ƒZ]dS )|zCommon IO api utilitiesé    )ÚannotationsN)Úabc)ÚBufferedIOBaseÚBytesIOÚ	RawIOBaseÚStringIOÚ
TextIOBaseÚTextIOWrapper)ÚPath)	ÚIOÚAnyÚAnyStrÚGenericÚLiteralÚMappingÚ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_file_like)Ú_shared_docsÚ z^[A-Za-z][A-Za-z0-9+\-+.]*://ÚBaseBufferT)Úboundc                   @  s>   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__r1   © r7   r7   úP/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/pandas/io/common.pyr)   D   s   
r)   c                   @  sz   e Zd ZU dZded< ded< ejed�Zded< d	Z	d
ed< d	Z
d
ed< ddœdd„Zddœdd„Zdddœ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_handlesFr0   Ú
is_wrappedÚis_mmapÚNone©Úreturnc              	   C  sx   | j r8t| jtƒsJ ‚| j ¡  | j ¡  | j | j¡ z| jD ]}| ¡  q@W n t	t
fyf   Y n0 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)r=   Ú
isinstancer:   r	   ÚflushÚdetachr<   ÚremoveÚcloseÚOSErrorÚ
ValueError)Úselfr:   r7   r7   r8   rF   g   s    


zIOHandles.closezIOHandles[AnyStr]c                 C  s   | S ©Nr7   ©rI   r7   r7   r8   Ú	__enter__{   s    zIOHandles.__enter__r   )ÚargsrA   c                 G  s   |   ¡  d S rJ   )rF   )rI   rM   r7   r7   r8   Ú__exit__~   s    zIOHandles.__exit__N)r2   r3   r4   r5   r6   ÚdataclassesÚfieldÚlistr<   r=   r>   rF   rL   rN   r7   r7   r7   r8   r9   Q   s   
r9   Úobjectr0   )ÚurlrA   c                 C  s   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)rB   r,   Ú	parse_urlÚschemeÚ_VALID_URLS©rS   r7   r7   r8   Úis_url‚   s    
rX   r,   )r+   rA   c                 C  s   d S rJ   r7   ©r+   r7   r7   r8   Ú_expand_user”   s    rZ   c                 C  s   d S rJ   r7   rY   r7   r7   r8   rZ   ™   s    zstr | BaseBufferTc                 C  s   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
    )rB   r,   ÚosÚpathÚ
expanduserrY   r7   r7   r8   rZ   ž   s    
r?   )ÚheaderrA   c                 C  s   t | tƒrtdƒ‚d S )Nz–Passing 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)rB   r0   Ú	TypeError)r^   r7   r7   r8   Úvalidate_header_arg±   s    
ÿr`   .r   )r+   Úconvert_file_likerA   c                 C  s   d S rJ   r7   ©r+   ra   r7   r7   r8   Ústringify_pathº   s    rc   c                 C  s   d S rJ   r7   rb   r7   r7   r8   rc   ¿   s    FzFilePath | BaseBufferTc                 C  s2   |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'   rB   r[   ÚPathLikeÚ
__fspath__rZ   rb   r7   r7   r8   rc   Æ   s
    
c                  O  s   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)rM   ÚkwargsÚurllibr7   r7   r8   rh   è   s    rh   zFilePath | BaseBufferc                 C  s$   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://)rB   r,   r0   Ú_RFC_3986_PATTERNÚmatchÚ
startswithrW   r7   r7   r8   Úis_fsspec_urlò   s
    
ÿ
ýrn   Úcompression_optionsr+   )ro   úutf-8Úrr   r   )r+   r-   r/   r.   Ústorage_optionsrA   c              	   C  sÚ  t | ƒ} t|ƒ\}}t| |ƒ}|rJt| dƒrJd|vrJtjdttƒ d� d}t||d�}d|v r„|dv r„|d	v r„t |› d
|› �t	¡ |}d|vr d|vr |d7 }t
| tƒ�r<t| ƒ�r<|p¼i }ddl}|jj| |d�}t|ƒ�:}	|	j dd¡}
|
dkrþddi}t|	 ¡ ƒ}W d  ƒ n1 �s 0    Y  t|||d|d�S t| ƒ�rbt
| tƒ�sVJ ‚|  d¡�rn|  dd¡} |  d¡�r†|  dd¡} tdƒ}g }z&tdƒ ddlm}m} ||tg}W n t�yÌ   Y n0 z$|j| fd|i|�pæi ¤Ž ¡ }W n\ t |ƒ�yN   |du �rddi}nt|ƒ}d|d< |j| fd|i|�p@i ¤Ž ¡ }Y n0 t|||d|d�S |�rpt!dƒ‚t
| tt"t#j#fƒ�rštt$| ƒ||d|d�S t| dƒ�sÈt| dƒ�sÈdt%| ƒ› �}t!|ƒ‚t| ||d|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 : dict, optional
        Extra options that make sense for a particular storage connection, e.g.
        host, port, username, password, etc., if using a URL that will
        be parsed by ``fsspec``, e.g., starting "s3://", "gcs://". An error
        will be raised if providing this argument with a local path or
        a file-like buffer. See the fsspec and backend storage implementation
        docs for the set of allowed keys and values

        .. 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Úgziprv   T)r+   r-   r/   r1   r.   zs3a://zs3://zs3n://ÚfsspecZbotocore)ÚClientErrorÚNoCredentialsErrorr.   Zanonz?storage_options passed with file object or non-fsspec file pathFÚreadz)Invalid file path or buffer object type: )&rc   Úget_compression_methodÚinfer_compressionÚhasattrÚwarningsÚwarnÚRuntimeWarningr#   ÚdictÚUnicodeWarningrB   r,   rX   rf   rg   ÚRequestrh   r{   Úgetr   r€   r)   rn   rm   Úreplacer!   Zbotocore.exceptionsr~   r   ÚPermissionErrorÚImportErrorÚopenÚtuplerH   ÚbytesÚmmaprZ   Útype)r+   r-   r/   r.   rr   Úcompression_methodZfsspec_moderj   Zreq_infoÚreqÚcontent_encodingÚreaderr}   Zerr_types_to_retry_with_anonr~   r   Zfile_objÚmsgr7   r7   r8   Ú_get_filepath_or_bufferþ   sÞ    %
ýÿþýþ
,û
ÿ
ýÿÿÿ

ÿÿÿûÿûÿÿûr˜   )r\   rA   c                 C  s   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:)rf   r™   r   )r\   r™   r7   r7   r8   Úfile_path_to_url¶  s    rš   z.gzz.bz2ú.zipz.xzz.zst)r|   rx   Úzipry   Úzstdz"tuple[str | None, CompressionDict])r/   rA   c              
   C  sb   t | tƒrRt| ƒ}z| d¡}W qZ tyN } ztdƒ|‚W Y d}~qZd}~0 0 n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
    rv   z.If mapping, compression must have key 'method'N)rB   r   r‡   ÚpopÚKeyErrorrH   )r/   Úcompression_argsr“   Úerrr7   r7   r8   r�   Ñ  s    
"r�   ú
str | None)r+   r/   rA   c                 C  s’   |du rdS |dkrZt | dd�} t| tƒs.dS t ¡ D ]\}}|  ¡  |¡r6|  S q6dS |tv rf|S ddgttƒ }d|› d|› �}t|ƒ‚dS )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.
    NZinferT)ra   úUnrecognized compression type: z
Valid compression types are )	rc   rB   r,   Ú_compression_to_extensionÚitemsÚlowerÚendswithÚsortedrH   )r+   r/   Ú	extensionZvalidr—   r7   r7   r8   r‚   ô  s(    

ÿÿÿr‚   z
Path | strc                 C  s&   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_dirrG   )r\   r«   r7   r7   r8   Úcheck_parent_directory/  s    

r­   )r-   r/   Ú
memory_mapÚerrorsrr   zLiteral[False]zIOHandles[bytes])	Úpath_or_bufr.   r-   r/   r®   Úis_textr¯   rr   rA   c                C  s   d S rJ   r7   ©r°   r.   r-   r/   r®   r±   r¯   rr   r7   r7   r8   Ú
get_handle>  s    r³   )r-   r/   r®   r±   r¯   rr   zLiteral[True]zIOHandles[str]c                C  s   d S rJ   r7   r²   r7   r7   r8   r³   M  s    r°   Tz!IOHandles[str] | IOHandles[bytes]c                C  sâ  |pd}t | |ƒr"d|vr"|d7 }t |¡ t|tƒr@t |¡ t| ||||d�}|j}	t|	||j	|j
||jd tvƒ\}	}}
t|	tƒ}t|jƒ}| d¡}d|vr´|r´tt|	ƒƒ |�r¢|dkrÔ|j
 dd¡|_
n |dkrôd|j
vrô| j
d7  _
|d	k�rJ|�r.t|	tƒ�sJ ‚tjf |	|j
d
œ|¤Ž}	ntjf |	|j
dœ|¤Ž}	�n<|dk�rptj|	fd|j
i|¤Ž}	�n|dk�røt|	|j
fi |¤Ž}	|	j
dk�r†|
 |	¡ |	 ¡ }t|ƒdk�rÊ|	 | ¡ ¡}	n,t|ƒdk�rètd| › �ƒ‚ntd|› �ƒ‚nŽ|dk�rtƒ |	|j
ƒ}	nt|dk�rttdƒ}d|j
v �rFd|jf i |¤Ži}nd|jf i |¤Ži}|j|	fd|j
i|¤Ž}	nd|› �}t|ƒ‚t|	tƒ�r–J ‚|
 |	¡ nNt|	tƒ�rð|j	�rÚd|j
v�rÚt|	|j
|j	|dd�}	nt|	|j
ƒ}	|
 |	¡ d}|�s"|j
dk�r"t|	tƒ�r"t |	|j	d�}	nP|�rr|�s<t |	|j
ƒ�rrt!t"|	ƒ|j	|dd�}	|
 |	¡ t|jtƒ�pn|j# }d|j
v �r t$|	dƒ�s t%dt&|jƒ› d�ƒ‚|
 '¡  |j#�rÎt|jtƒ�rÂJ ‚|
 |j¡ t(|	|
|||jd�S ) aw  
    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.
    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
    rp   rt   )r-   r/   r.   rr   rv   rq   r�   rz   r&   r|   )Úfilenamer.   )Úfileobjr.   rx   r.   rœ   é   r   zZero files found in ZIP file z9Multiple files found in ZIP file. Only one file per ZIP: ry   Ú	zstandardZdctxZcctxr£   ©r-   r¯   ÚnewlineFÚrb)r-   r€   z1Expected file path name or file-like object, got z type)r:   r<   r=   r>   r/   ))Ú_is_binary_modeÚcodecsÚlookuprB   r,   Úlookup_errorr˜   r+   Ú_maybe_memory_mapr-   r.   r/   r¤   r‡   rž   r­   r‹   r|   ÚGzipFilerx   ÚBZ2FileÚ_BytesZipFileÚappendÚnamelistÚlenrŽ   rH   r    r!   ÚZstdDecompressorZZstdCompressorr   Ú_BytesIOWrapperr	   Ú
_IOWrapperr1   rƒ   r_   r’   Úreverser9   )r°   r.   r-   r/   r®   r±   r¯   rr   Zioargsr:   ÚhandlesZis_pathr    Z	zip_namesr�   Z	open_argsr—   r=   r7   r7   r8   r³   \  s   6


ûú
	



þýüû
	
ÿþý

ÿÿ
ÿÿ

ÿþý
û	
þù	
ÿÿÿöc                      sf   e Zd ZdZdddddœ‡ fdd„Zd	d
„ Zdd„ Zddœ‡ fdd„Z‡ fdd„Ze	dd„ ƒZ
‡  ZS )rÂ   a  
    Wrapper for standard library class ZipFile and allow the returned file-like
    handle to accept byte strings via `write` method.

    BytesIO provides attributes of file-like object and ZipFile.writestr writes
    bytes strings into a member of the archive.
    Nz1FilePath | ReadBuffer[bytes] | WriteBuffer[bytes]r,   r¢   )Úfiler.   Úarchive_namec                   sF   |  dd¡}|| _d | _dtji}| |¡ tƒ j||fi |¤Ž d S )Nrt   r&   r/   )r‹   rÌ   Úmultiple_write_bufferÚzipfileÚZIP_DEFLATEDÚupdateÚsuperÚ__init__)rI   rË   r.   rÌ   ri   Z
kwargs_zip©Ú	__class__r7   r8   rÒ   h  s    

z_BytesZipFile.__init__c                 C  s<   t | jtjtfƒr8t| jƒ}|jdkr2| 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)	rB   r´   r[   rd   r,   r
   ÚsuffixÚwith_suffixÚname)rI   r´   r7   r7   r8   Úinfer_filename|  s    

z_BytesZipFile.infer_filenamec                 C  s2   | j d u r"t|tƒrtƒ ntƒ | _ | j  |¡ d S rJ   )rÍ   rB   r�   r   r   rs   )rI   Údatar7   r7   r8   rs   ˆ  s    
ÿz_BytesZipFile.writer?   r@   c                   sf   | j d u s| j jrd S | jp&|  ¡ p&d}| j �$ tƒ  || j  ¡ ¡ W d   ƒ n1 sX0    Y  d S )Nrœ   )rÍ   ÚclosedrÌ   rØ   rÑ   ÚwritestrÚgetvalue)rI   rÌ   rÓ   r7   r8   rC   �  s
    z_BytesZipFile.flushc                   s   |   ¡  tƒ  ¡  d S rJ   )rC   rÑ   rF   rK   rÓ   r7   r8   rF   š  s    z_BytesZipFile.closec                 C  s
   | j d u S rJ   )ÚfprK   r7   r7   r8   rÚ   ž  s    z_BytesZipFile.closed)N)r2   r3   r4   r5   rÒ   rØ   rs   rC   rF   ÚpropertyrÚ   Ú__classcell__r7   r7   rÓ   r8   rÂ   ^  s    ü
rÂ   c                   @  sb   e Zd ZdZddddddœd	d
„Zddœdd„Zd dœdd„Zddddœdd„Zddœdd„ZdS )Ú_MMapWrappera  
    Wrapper for the Python's mmap class so that it can be properly read in
    by Python's csv.reader class.

    Parameters
    ----------
    f : file object
        File object to be mapped onto memory. Must support the 'fileno'
        method or have an equivalent attribute

    rp   ÚstrictTr   r,   r0   )Úfr-   r¯   Údecodec                 C  sn   || _ || _t |¡|d�| _|| _i | _dD ]"}t||ƒs>q.t||ƒƒ | j|< q.t	j	| 
¡ dt	jd�| _	d S )N©r¯   )ÚseekableÚreadabler   )Úaccess)r-   r¯   r¼   ÚgetincrementaldecoderÚdecoderrã   Ú
attributesrƒ   Úgetattrr‘   ÚfilenoÚACCESS_READ)rI   râ   r-   r¯   rã   Ú	attributer7   r7   r8   rÒ   °  s    
z_MMapWrapper.__init__©r×   c                   s$   ˆ ˆj v r‡ ‡fdd„S tˆjˆ ƒS )Nc                     s
   ˆj ˆ  S rJ   )rê   r7   ©r×   rI   r7   r8   Ú<lambda>Å  ó    z*_MMapWrapper.__getattr__.<locals>.<lambda>)rê   rë   r‘   ©rI   r×   r7   rð   r8   Ú__getattr__Ã  s    
z_MMapWrapper.__getattr__r@   c                 C  s   | S rJ   r7   rK   r7   r7   r8   Ú__iter__È  s    z_MMapWrapper.__iter__éÿÿÿÿÚintzstr | bytes)ÚsizerA   c                 C  sD   | j  |¡}| jr@| jdkr@|dkp.t|ƒ|k }| jj||d�S |S )Nrp   rö   )Úfinal)r‘   r€   rã   r-   rÅ   ré   )rI   rø   Úcontentrù   r7   r7   r8   r€   Ë  s
    z_MMapWrapper.readc                 C  s,   | j  ¡ }| j |¡}|dkr"t‚| d¡S )Nr&   Ú
)r‘   Úreadlineré   rã   ÚStopIterationÚlstrip)rI   Znewbytesr¹   r7   r7   r8   Ú__next__Õ  s
    
z_MMapWrapper.__next__N)rp   rá   T)rö   )	r2   r3   r4   r5   rÒ   rô   rõ   r€   rÿ   r7   r7   r7   r8   rà   £  s      û
rà   c                   @  sR   e Zd Zddœdd„Zddœdd„Zd	d
œdd„Zd	d
œdd„Zd	d
œdd„ZdS )rÈ   r   ©Úbufferc                 C  s
   || _ d S rJ   r   )rI   r  r7   r7   r8   rÒ   í  s    z_IOWrapper.__init__r,   rï   c                 C  s   t | j|ƒS rJ   ©rë   r  ró   r7   r7   r8   rô   ð  s    z_IOWrapper.__getattr__r0   r@   c                 C  s   t | jdƒr| j ¡ S dS )Nræ   T)rƒ   r  ræ   rK   r7   r7   r8   ræ   ó  s    
z_IOWrapper.readablec                 C  s   t | jdƒr| j ¡ S dS )Nrå   T)rƒ   r  rå   rK   r7   r7   r8   rå   ù  s    
z_IOWrapper.seekablec                 C  s   t | jdƒr| j ¡ S dS )NÚwritableT)rƒ   r  r  rK   r7   r7   r8   r  þ  s    
z_IOWrapper.writableN)r2   r3   r4   rÒ   rô   ræ   rå   r  r7   r7   r7   r8   rÈ   æ  s
   rÈ   c                   @  s>   e Zd Zddddœdd„Zddœdd	„Zddddœdd„ZdS )rÇ   rp   zStringIO | TextIOBaser,   )r  r-   c                 C  s   || _ || _d| _d S )Nrò   )r  r-   Úoverflow)rI   r  r-   r7   r7   r8   rÒ     s    z_BytesIOWrapper.__init__)Úattrc                 C  s   t | j|ƒS rJ   r  )rI   r  r7   r7   r8   rô     s    z_BytesIOWrapper.__getattr__rö   z
int | Noner�   )ÚnrA   c                 C  st   | j d usJ ‚| j  |¡ | j¡}| j| }|d u sH|dk sH|t|ƒkrRd| _|S |d |… }||d … | _|S d S )Nr   rò   )r  r€   Úencoder-   r  rÅ   )rI   r  Z
bytestringZcombined_bytestringZ	to_returnr7   r7   r8   r€     s    
z_BytesIOWrapper.readN)rp   )rö   )r2   r3   r4   rÒ   rô   r€   r7   r7   r7   r8   rÇ     s   	rÇ   r*   z/tuple[str | BaseBuffer, bool, list[BaseBuffer]])r:   r®   r-   r.   r¯   rã   rA   c              	   C  sÄ   g }|t | dƒpt| tƒM }|s*| ||fS t| tƒrh|rTd|vrTt| |||dd�} n
t| |ƒ} | | ¡ z.ttt| |||ƒƒ}W t|ƒD ]} |  	¡  qˆnt|ƒD ]} |  	¡  q 0 | |¡ |||fS )zTry to memory map file/buffer.rì   rt   r&   r¸   )
rƒ   rB   r,   rŽ   rÃ   r   r   rà   ÚreversedrF   )r:   r®   r-   r.   r¯   rã   rÊ   Úwrappedr7   r7   r8   r¿   "  s(    	



þþ
r¿   c              	   C  sF   d}t | ƒ} t| tƒs|S ztj | ¡}W n ttfy@   Y n0 |S )zTest whether file exists.F)rc   rB   r,   r[   r\   Úexistsr_   rH   )r+   r
  r7   r7   r8   Úfile_existsJ  s    
r  )r:   r.   rA   c                 C  sV   d|v sd|v rd|v S t jt jt jf}tt| ƒ|ƒr:dS t| tƒ ƒpTdt| d|ƒv S )z+Whether the handle is opened in binary moderz   rt   Fr.   )	r¼   ÚStreamWriterÚStreamReaderÚStreamReaderWriterÚ
issubclassr’   rB   Ú_get_binary_io_classesrë   )r:   r.   Ztext_classesr7   r7   r8   r»   X  s    üÿr»   ztuple[type, ...]r@   c                  C  s\   t tf} tddd�}|durX| ¡  d¡�}| t|ƒf7 } W d  ƒ n1 sN0    Y  | S )z!IO classes that that expect bytesr·   Úignorerä   Nrò   )r   r   r!   rÆ   Ústream_readerr’   )Zbinary_classesr�   r–   r7   r7   r8   r  m  s    ,r  ).).)F)rp   Nrq   N)^r5   Ú
__future__r   rx   r¼   Úcollectionsr   rO   Ú	functoolsr|   Úior   r   r   r   r   r	   r‘   r[   Úpathlibr
   ÚreÚtypingr   r   r   r   r   r   r   r   r   Úurllib.parser   r   rT   r   r   r   r„   rÎ   Zpandas._typingr   r   r   r   r   r   r   Zpandas.compatr    Zpandas.compat._optionalr!   Zpandas.util._decoratorsr"   Zpandas.util._exceptionsr#   Zpandas.core.dtypes.commonr$   Zpandas.core.shared_docsr%   ÚsetrV   ÚdiscardÚcompilerk   r'   Ú	dataclassr)   r9   rX   rZ   r`   rc   rh   rn   r˜   rš   r¤   r�   r‚   r­   r³   ÚZipFilerÂ   ÚIteratorrà   rÈ   rÇ   r¿   r  r»   Ú	lru_cacher  r7   r7   r7   r8   Ú<module>   sÆ    ,$	

0	 ÿ þ"
    û 8û	#:÷$÷$÷$  EC(