Ë
    	êñiÛ,  ã                  ó  — d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZmZmZmZmZ d dlmZmZ d d	lmZmZmZmZ d d
lmZ erd dlmZ d dlmZ d dl m!Z! 	 	 	 	 d d„Z"d!d„Z#	 	 d"	 	 	 	 	 d#d„Z$e	 d$ddddœ	 	 	 	 	 	 	 	 	 	 	 d%d„«       Z%e	 d$ddddœ	 	 	 	 	 	 	 	 	 	 	 d&d„«       Z%e	 d$ddddœ	 	 	 	 	 	 	 	 	 	 	 d'd„«       Z%	 d(ddddœ	 	 	 	 	 	 	 	 	 	 	 d'd„Z%ddœ	 	 	 	 	 	 	 	 	 d)d„Z&d*d„Z'd(d+d„Z(d,d„Z)d,d„Z*	 	 	 	 d-d„Z+y).é    )ÚannotationsN)ÚSequence)Úcontextmanager)ÚBytesIOÚStringIO)ÚPath)ÚIOÚTYPE_CHECKINGÚAnyÚcastÚoverload)Ú_FSSPEC_AVAILABLEÚfsspec)Úis_int_sequenceÚis_path_or_str_sequenceÚis_str_sequenceÚnormalize_filepath)ÚNoDataError)ÚIterator)ÚAbstractContextManager)ÚStorageOptionsDictc                óö   — | €yd}d}t        | t        «      r| g}||fS t        | t        «      r| g}||fS t        | «      rt	        | «       | }||fS t        | «      rt	        | «       | }||fS d}t        |«      ‚)a0  
    Parse the `columns` argument of an I/O function.

    Disambiguates between column names and column indices input.

    Returns
    -------
    tuple
        A tuple containing the columns as a projection and a list of column names.
        Only one will be specified, the other will be `None`.
    N)NNzQthe `columns` argument should contain a list of all integers or all string values)Ú
isinstanceÚstrÚintr   Ú_ensure_columns_are_uniquer   Ú	TypeError)ÚcolumnsÚ
projectionÚcolumn_namesÚmsgs       úR/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/polars/io/_utils.pyÚparse_columns_argr#      s®   € ð €Øà'+€JØ)-€Lä�'œ3ÔØ�yˆð �|Ð#Ð#ô 
�GœSÔ	!Ø�Yˆ
ð �|Ð#Ð#ô 
˜Ô	!Ü" 7Ô+Øˆð �|Ð#Ð#ô 
˜Ô	!Ü" 7Ô+Øˆ
ð
 �|Ð#Ð#ð bˆÜ˜‹nÐó    c                ód   — t        | «      t        t        | «      «      k7  rd| ›�}t        |«      ‚y )Nz2`columns` arg should only have unique values, got )ÚlenÚsetÚ
ValueError)r   r!   s     r"   r   r   @   s2   € Ü
ˆ7ƒ|”sœ3˜w›<Ó(Ò(ØBÀ7À+ÐNˆÜ˜‹oÐð )r$   c                ó   — | €y| |fS )z©
    Parse the `row_index_name` and `row_index_offset` arguments of an I/O function.

    The Rust functions take a single tuple rather than two separate arguments.
    N© )Úrow_index_nameÚrow_index_offsets     r"   Úparse_row_index_argsr-   F   s   € ð ÐØàÐ 0Ð1Ð1r$   .)Úuse_pyarrowÚraise_if_emptyÚstorage_optionsc                ó   — y ©Nr*   ©ÚfileÚencodingr.   r/   r0   s        r"   Úprepare_file_argr6   U   ó   € ð %(r$   c                ó   — y r2   r*   r3   s        r"   r6   r6   `   r7   r$   c                ó   — y r2   r*   r3   s        r"   r6   r6   k   s	   € ð ADr$   FTc          	     óü  ‡— |r|j                  «       ni }|rt        sd}t        |«      ‚t        dd„«       }|r|dv nd}|r|nd}|j	                  d«      r|dd	 d
fn|df\  }}	| }
t        | t        «      r;|s"| j                  ||	¬«      j                  d«      } t        t        | «      d|¬«      S t        | t        «      rCt        t        | j                  «       j                  d«      «      d| j                  «       |¬«      S t        | t        «      ry|sTt        t        | j                  «       j                  ||	¬«      j                  d«      «      d| j                  «       |¬«      S  |t        | d| j                  «       |¬«      «      S t        | t        «      r^|sIt        t        | j                  «       j                  ||	¬«      j                  d«      «      d| ›d�|¬«      S  |t!        | |
¬«      «      S t        | t"        «      rÁt%        | «      rt'        | |«      S t        r¤ddlmŠ  ‰| «      d   dk(  rp|r |t!        | |
¬«      «      S t        | «      j-                  ||	¬«      5 }t        t        |j                  «       j                  d«      «      | ›|¬«      cddd«       S ||d<   |	|d<   t/        j,                  | fi |¤ŽS t        | t0        «      r€t3        | «      rut5        d„ | D «       «      rct        r]ddlmŠ |r5t5        ˆfd„| D «       «      r! || D �cg c]  }t!        ||
¬«      ‘Œ c}«      S ||d<   |	|d<   t/        j6                  | fi |¤ŽS t        | t"        «      rjt!        | |
¬«      } |s[t        | «      j-                  ||	¬«      5 }t        t        |j                  «       j                  d«      «      | ›|¬«      cddd«       S  || «      S # 1 sw Y   �Œ<xY wc c}w # 1 sw Y   Œ#xY w)uœ  
    Prepare file argument.

    Utility for read_[csv, parquet]. (not to be used by scan_[csv, parquet]).
    Returned value is always usable as a context.

    A `StringIO`, `BytesIO` file is returned as a `BytesIO`.
    A local path is returned as a string.
    An http URL is read into a buffer and returned as a `BytesIO`.

    When `encoding` is not `utf8` or `utf8-lossy`, the whole file is
    first read in Python and decoded using the specified encoding and
    returned as a `BytesIO` (for usage with `read_csv`). If encoding
    ends with "-lossy", characters that can't be decoded are replaced
    with `ï¿½`.

    A `bytes` file is returned as a `BytesIO` if `use_pyarrow=True`.

    When fsspec is installed, remote file(s) is (are) opened with
    `fsspec.open(file, **kwargs)` or `fsspec.open_files(file, **kwargs)`.
    If encoding is not `utf8` or `utf8-lossy`, decoding is handled by
    fsspec too.
    z3`fsspec` is required for `storage_options` argumentr4   c              3  ó    K  — 	 | –— y # w xY w­wr2   r*   ©r4   s    r"   Úmanaged_filez&prepare_file_arg.<locals>.managed_file›   s   è ø€ ð	ØŠJàøˆDüs   ‚„	 ˆ‰‹>   Úutf8ú
utf8-lossyTr>   z-lossyNiúÿÿÿÚreplaceÚstrict)ÚerrorsÚbytes)Úcontextr/   r   )rD   Úread_positionr/   r   )ÚbrD   rE   r/   zPath (ú)©Úcheck_not_directoryr   )Úinfer_storage_optionsÚprotocol)r5   rB   r5   rB   c              3  ó<   K  — | ]  }t        |t        «      –— Œ y ­wr2   )r   r   )Ú.0Úfs     r"   ú	<genexpr>z#prepare_file_arg.<locals>.<genexpr>þ   s   è ø€ Ò4VÈA´ZÀÄ3×5GÑ4Vùs   ‚c              3  ó:   •K  — | ]  } ‰|«      d    dk(  –— Œ y­w)rK   r4   Nr*   )rM   rN   rJ   s     €r"   rO   z#prepare_file_arg.<locals>.<genexpr>  s!   øè ø€ ÒTÈ!Ñ,¨QÓ/°
Ñ;¸vÕEÑTùs   ƒ)r4   r   ÚreturnzIterator[Any])Úcopyr   ÚImportErrorr   Úendswithr   rC   ÚdecodeÚencodeÚ_check_emptyr   r   ÚreadÚtellr   Ú
read_bytesr   r   Úlooks_like_urlÚprocess_file_urlÚfsspec.utilsrJ   Úopenr   ÚlistÚboolÚallÚ
open_files)r4   r5   r.   r/   r0   r!   r=   Úhas_utf8_utf8_lossy_encodingÚencoding_strÚencoding_errorsÚcheck_not_dirrN   rJ   s               @r"   r6   r6   v   s÷  ø€ ñ> 1@�o×*Ñ*Ô,ÀR€OÙÕ0ØCˆÜ˜#ÓÐô òó ðñ /7ˆÐ*Ñ*¸Dð !ñ  (‘8¨V€Lð × Ñ  Ô*ð 
�c�rÐ	˜IÑ&à˜HÐ%ñ "€L�/ð $�O€Mä�$œÔÙ+Ø—;‘;˜|°O�;ÓD×KÑKÈFÓSˆDÜÜ�D‹M 7¸>ô
ð 	
ô �$œÔ!ÜÜ�D—I‘I“K×&Ñ& vÓ.Ó/ØØŸ)™)›+Ø)ô	
ð 	
ô �$œÔ Ù+ÜÜØ—I‘I“Kß‘V˜L°�VÓAß‘V˜F“^óð
 "Ø"Ÿi™i›kØ-ô	ð 	ñ ÜØØ!Ø"Ÿi™i›kØ-ô	ó
ð 	
ô �$œÔÙ+ÜÜØ—O‘OÓ%ß‘V˜L°�VÓAß‘V˜F“^óð
 !  ¨Ð*Ø-ôð ñ Ô.¨tÈÔWÓXÐXä�$œÔô ˜$ÔÜ# D¨,Ó7Ð7ÝÝ:ñ % TÓ*¨:Ñ6¸&Ò@á/Ù'Ü*¨4À]ÔSóð ô ˜$“Z—_‘_Ø)°/ð %ó ð àÜ'Ü §¡£§¡°Ó 7Ó8Ø#' (Ø'5ô÷ñ ð +3ˆO˜JÑ'Ø(7ˆO˜HÑ%Ü—;‘;˜tÑ7 Ñ7Ð7ä�$œÔ¤$ t¤*´Ñ4VÐQUÔ4VÔ1VÝÝ:á+ÜÓTÈtÔTÔTÙ'ð &*öà !ô /¨qÀmÖTòóð ð +3ˆO˜JÑ'Ø(7ˆO˜HÑ%Ü×$Ñ$ TÑ=¨_Ñ=Ð=ä�$œÔÜ! $¸MÔJˆÙ+Ü�d“—‘¨,¸�ÓOð ÐSTÜ#Ü˜AŸF™F›HŸO™O¨FÓ3Ó4Ø#˜hØ#1ô÷ñ ñ ˜ÓÐ÷Mñ üò&÷ð ús   É/5O Ì#O-Î5O2Ï O*Ï2O;)rE   c               ó„   — |r=| j                  «       j                  dk(  r |dv r|rd|› d�nd}d|› |› �}t        |«      ‚| S )Nr   )r   r   z (buffer position = z; try seek(0) before reading?)Ú zempty data from )Ú	getbufferÚnbytesr   )rF   rD   r/   rE   Úhintr!   s         r"   rW   rW     s`   € ñ ˜!Ÿ+™+›-×.Ñ.°!Ò3ð Ð1Ñ1±mð # = /Ð1OÑPàð 	ð
 !  	¨$¨Ð0ˆÜ˜#ÓÐØ€Hr$   c                óP   — t        j                  d| t         j                  «      d uS )Nz^(ht|f)tps?://)ÚreÚmatchÚ
IGNORECASE)Úpaths    r"   r[   r[   )  s   € Ü�8‰8Ð% t¬R¯]©]Ó;À4ÐGÐGr$   c                ó  — ddl m}  || «      5 }|r|dv r"t        |j                  «       «      cd d d «       S t        |j                  «       j	                  |«      j                  d«      «      cd d d «       S # 1 sw Y   y xY w)Nr   )Úurlopen>   r>   r?   r>   )Úurllib.requestrr   r   rX   rU   rV   )rp   r5   rr   rN   s       r"   r\   r\   -  sp   € Ý&á	�‹ð E˜!Ù˜8Ð'=Ñ=Ü˜1Ÿ6™6›8Ó$÷Eñ Eô ˜1Ÿ6™6›8Ÿ?™?¨8Ó4×;Ñ;¸FÓCÓD÷	E÷ Eò Eús   �A8¸6A8Á8Bc                ó,   ‡ — t        ˆ fd„dD «       «      S )Nc              3  ó&   •K  — | ]  }|‰v –— Œ
 y ­wr2   r*   )rM   Úcharr4   s     €r"   rO   z"is_glob_pattern.<locals>.<genexpr>8  s   øè ø€ Ò8 ˆt�tŒ|Ñ8ùs   ƒ)Ú*ú?ú[)Úanyr<   s   `r"   Úis_glob_patternr{   7  s   ø€ ÜÓ8¨Ô8Ó8Ð8r$   c                ód   — 	 t        t        j                  | d¬«      «       y# t        $ r Y yw xY w)NT)Ú	recursiveF)ÚnextÚglobÚiglobÚStopIterationr<   s    r"   Úis_local_filer‚   ;  s3   € ðÜŒT�Z‰Z˜¨Ô-Ô.ð øô ò Ùðús   ‚ # £	/®/c                ó  — t        | t        t        f«      rt        | d¬«      } n&t	        | «      r| D � cg c]  } t        | d¬«      ‘Œ c} } t        | t
        «      rt        | t        t        f«      r| g}t        d|«      S | S c c} w )NFrH   z9list[bytes] | list[str] | list[IO[bytes]] | list[IO[str]])r   r   r   r   r   r   rC   r   )ÚsourceÚouts     r"   Úget_sourcesr†   D  s|   € ô �&œ3¤˜+Ô&Ü# FÀÔF‰Ü	  Ô	(àPVö
ØFLÔ˜v¸5ÖAò
ˆô �fœhÔ'¬:°f¼sÄE¸lÔ+KØ8>°xˆäÐOÐQTÓUÐUà€Mùò
s   ´B)r   z0Sequence[str] | Sequence[int] | str | int | NonerQ   z1tuple[Sequence[int] | None, Sequence[str] | None])r   zSequence[str] | Sequence[int]rQ   ÚNone)Nr   )r+   ú
str | Noner,   r   rQ   ztuple[str, int] | None).)r4   z*str | Path | list[str] | IO[bytes] | bytesr5   rˆ   r.   r`   r/   r`   r0   úStorageOptionsDict | NonerQ   úContextManager[str | BytesIO])r4   z(str | Path | IO[str] | IO[bytes] | bytesr5   rˆ   r.   r`   r/   r`   r0   r‰   rQ   rŠ   )r4   z4str | Path | list[str] | IO[str] | IO[bytes] | bytesr5   rˆ   r.   r`   r/   r`   r0   r‰   rQ   z9ContextManager[str | list[str] | BytesIO | list[BytesIO]]r2   )
rF   r   rD   r   r/   r`   rE   z
int | NonerQ   r   )rp   r   rQ   r`   )rp   r   r5   rˆ   rQ   r   )r4   r   rQ   r`   )r„   zqstr | Path | IO[bytes] | IO[str] | bytes | list[str] | list[Path] | list[IO[bytes]] | list[IO[str]] | list[bytes]rQ   zFlist[str] | list[Path] | list[IO[str]] | list[IO[bytes]] | list[bytes]),Ú
__future__r   r   rm   Úcollections.abcr   Ú
contextlibr   Úior   r   Úpathlibr   Útypingr	   r
   r   r   r   Úpolars._dependenciesr   r   Úpolars._utils.variousr   r   r   r   Úpolars.exceptionsr   r   r   ÚContextManagerÚpolars._typingr   r#   r   r-   r6   rW   r[   r\   r{   r‚   r†   r*   r$   r"   ú<module>r–      sk  ðÝ "ã Û 	Ý $Ý %ß  Ý ß 9Õ 9ç :÷ó õ *áÝ(ÝCå1ð"$Ø=ð"$à6ó"$óJð "&Øð2Øð2àð2ð ó2ð 
ð ð(ð ØØ14ñ(Ø
4ð(àð(ð ð	(ð
 ð(ð /ð(ð #ò(ó 
ð(ð 
ð ð(ð ØØ14ñ(Ø
2ð(àð(ð ð	(ð
 ð(ð /ð(ð #ò(ó 
ð(ð 
ð ðDð ØØ14ñDØ
>ðDàðDð ð	Dð
 ðDð /ðDð ?òDó 
ðDð  ðbð ØØ15ñbØ
>ðbàðbð ð	bð
 ðbð /ðbð ?óbðL TXñØðØðØ15ðØFPðàóóHôEó9óðð	ðð Lôr$   