Ë
    ëmxi|:  ã                   ó  — d Z ddlmZm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 eZg Z	 ddlmZ 	 ddlmZ 	 ddlm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%Z% e%jL                  e"«       d„ Z'ddœd„Z(dddœd„Z)	 ddddœd„Z* G d„ de«      Z+y# e$ r ej+                  d«       Y Œzw xY w# e$ r ej+                  d«       Y Œ�w xY w# e$ r ej+                  d	«       Y Œ¤w xY w# e$ r ej+                  d«       Y Œ‘w xY w)zO
FileSystem abstraction to interact with various local and remote filesystems.
é    )Ú_is_path_likeÚ_stringify_path)ÚFileSelectorÚFileTypeÚFileInfoÚ
FileSystemÚLocalFileSystemÚSubTreeFileSystemÚ_MockFileSystemÚFileSystemHandlerÚPyFileSystemÚ_copy_filesÚ_copy_files_selector)ÚAzureFileSystemr   )ÚHadoopFileSystemr   )ÚGcsFileSystemr   )
ÚAwsDefaultS3RetryStrategyÚAwsStandardS3RetryStrategyÚS3FileSystemÚ
S3LogLevelÚS3RetryStrategyÚensure_s3_initializedÚfinalize_s3Úensure_s3_finalizedÚinitialize_s3Úresolve_s3_regionNr   c                 óN   — | t         v rt        d| › d�«      ‚t        d| › d�«      ‚)Nz8The pyarrow installation is not built with support for 'ú'z&module 'pyarrow.fs' has no attribute ')Ú_not_importedÚImportErrorÚAttributeError)Únames    úA/home/htdocs/ttos/venv/lib/python3.12/site-packages/pyarrow/fs.pyÚ__getattr__r$   I   sC   € ØŒ}ÑÜðØˆv�Qðó
ð 	
ô
 Ø
0°°°aÐ8óð ó    F©Úuse_mmapc          	      ó�  — t        | t        «      r| S t        | t        «      r«|rt        d«      ‚t        j                  | «      \  }}|j                  |«      }|rq|j                  |g«      d   }|j                  t        j                  k7  r3t        d|j                  j                  › d|j                  › d| › d�«      ‚t        ||«      }|S 	 dd l}t        | |j                  «      r8t        | «      j                  dk(  rt!        |¬«      S t#        t%        | «      «      S t)        d	t        | «      › d
�«      ‚# t&        $ r Y Œ#w xY w)NzXSpecifying to use memory mapping not supported for filesystem specified as an URI stringr   zWThe path component of the filesystem URI must point to a directory but it has a type: `z`. The path component is `z#` and the given filesystem URI is `ú`r	   r&   zUnrecognized filesystem: zP. `filesystem` argument must be a FileSystem instance or a valid file system URI)Ú
isinstancer   ÚstrÚ
ValueErrorÚfrom_uriÚnormalize_pathÚget_file_infoÚtyper   Ú	Directoryr"   Úpathr
   ÚfsspecÚAbstractFileSystemÚ__name__r	   r   ÚFSSpecHandlerr    Ú	TypeError)Ú
filesystemr'   Úfsr2   ÚprefixÚprefix_infor3   s          r#   Ú_ensure_filesystemr<   U   sd  € Ü�*œjÔ)ØÐÜ	�J¤Ô	$ñ Üð8óð ô ×&Ñ& zÓ2‰ˆˆDØ×"Ñ" 4Ó(ˆÙà×*Ñ*¨F¨8Ó4°QÑ7ˆKØ×Ñ¤8×#5Ñ#5Ò5Ü ð5Ø5@×5EÑ5E×5JÑ5JÐ4Kð L%Ø%0×%5Ñ%5Ð$6ð 7Ø%˜, að)óð ô # 6¨2Ó.ˆBØˆ	ð		?Ûô ˜* f×&?Ñ&?Ô@Ü˜
Ó#×,Ñ,Ð0AÒAä*°HÔ=Ð=Ü#¤M°*Ó$=Ó>Ð>äØ'¬¨ZÓ(8Ð'9ð :Bð Bó
ð 	
øô ò 	Ùð	ús   ÃD9 Ä9	EÅE)Ú
memory_mapc                óh  — t        | «      s|�t        d«      ‚|| fS |�Yt        ||¬«      }t        |t        «      rt        | «      } nt        | t        «      st        d«      ‚|j                  | «      } || fS t        | «      } t	        |¬«      }	 |j                  | «      }|j                  t        j                  k7  }|s	 t        j                  | «      \  }} || fS |j                  | «      } || fS # t        $ r d}d}Y ŒCw xY w# t        $ r#}t        |«      }d|v sd|v rn|‚Y d}~|| fS d}~ww xY w)zŒ
    Return filesystem/path from path which could be an URI or a plain
    filesystem path or a combination of fsspec protocol and URI.
    Nzg'filesystem' passed but the specified path is file-like, so there is nothing to open with 'filesystem'.r&   zPExpected string path; path-like objects are only allowed with a local filesystemFzempty schemezCannot parse URI)r   r,   r<   r*   r	   r   r+   r7   r.   r/   r0   r   ÚNotFoundr   r-   )r2   r8   r=   Ú	file_infoÚexists_locallyÚeÚmsgs          r#   Ú_resolve_filesystem_and_pathrD   ‚   s{  € ô
 ˜ÔØÐ!Üð?óð ð ˜4ÐÐàÐÜ'¨
¸ZÔHˆ
Ü�j¤/Ô2Ü" 4Ó(‰DÜ˜D¤#Ô&Üð*óð ð ×(Ñ(¨Ó.ˆØ˜4ÐÐä˜4Ó €Dô
 !¨*Ô5€Jð?Ø×,Ñ,¨TÓ2ˆ	ð
 $Ÿ.™.¬H×,=Ñ,=Ñ=ˆñ ð
	Ü)×2Ñ2°4Ó8ÑˆJ˜ð �tÐÐð ×(Ñ(¨Ó.ˆà�tÐÐøô/ ò Øˆ	ØŠðûô ò 	Ü�a“&ˆCØ Ñ$Ð(:¸cÑ(Að à�ó ð �tÐÐûð	ús*   ÂC2 ÃD Ã2DÄDÄ	D1ÄD,Ä,D1i   T)Ú
chunk_sizeÚuse_threadsc                óø   — t        | |«      \  }}t        ||«      \  }}	|j                  |«      }
|
j                  t        j                  k(  rt        |d¬«      }t        ||||	||«       yt        ||||	||«       y)a–  
    Copy files between FileSystems.

    This functions allows you to recursively copy directories of files from
    one file system to another, such as from S3 to your local machine.

    Parameters
    ----------
    source : string
        Source file path or URI to a single file or directory.
        If a directory, files will be copied recursively from this path.
    destination : string
        Destination file path or URI. If `source` is a file, `destination`
        is also interpreted as the destination file (not directory).
        Directories will be created as necessary.
    source_filesystem : FileSystem, optional
        Source filesystem, needs to be specified if `source` is not a URI,
        otherwise inferred.
    destination_filesystem : FileSystem, optional
        Destination filesystem, needs to be specified if `destination` is not
        a URI, otherwise inferred.
    chunk_size : int, default 1MB
        The maximum size of block to read before flushing to the
        destination file. A larger chunk_size will use more memory while
        copying but may help accommodate high latency FileSystems.
    use_threads : bool, default True
        Whether to use multiple threads to accelerate copying.

    Examples
    --------
    Inspect an S3 bucket's files:

    >>> s3, path = fs.FileSystem.from_uri(
    ...            "s3://registry.opendata.aws/roda/ndjson/")
    >>> selector = fs.FileSelector(path)
    >>> s3.get_file_info(selector)
    [<FileInfo for 'registry.opendata.aws/roda/ndjson/index.ndjson':...]

    Copy one file from S3 bucket to a local directory:

    >>> fs.copy_files("s3://registry.opendata.aws/roda/ndjson/index.ndjson",
    ...               f"file:///{local_path}/index_copy.ndjson")

    >>> fs.LocalFileSystem().get_file_info(str(local_path)+
    ...                                    '/index_copy.ndjson')
    <FileInfo for '.../index_copy.ndjson': type=FileType.File, size=...>

    Copy file using a FileSystem object:

    >>> fs.copy_files("registry.opendata.aws/roda/ndjson/index.ndjson",
    ...               f"file:///{local_path}/index_copy.ndjson",
    ...               source_filesystem=fs.S3FileSystem())
    T©Ú	recursiveN)rD   r/   r0   r   r1   r   r   r   )ÚsourceÚdestinationÚsource_filesystemÚdestination_filesystemrE   rF   Ú	source_fsÚsource_pathÚdestination_fsÚdestination_pathr@   Ú
source_sels               r#   Ú
copy_filesrS   ¾   s“   € ôp :ØÐ!óÑ€Iˆ{ô (DØÐ+ó(Ñ$€NÐ$ð ×'Ñ'¨Ó4€IØ‡~�~œ×+Ñ+Ò+Ü! +¸Ô>ˆ
Ü˜Y¨
Ø+Ð-=Ø'¨õ	6ô 	�I˜{Ø"Ð$4Ø õ	-r%   c                   ó’   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Ze	d„ «       Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)r6   a  
    Handler for fsspec-based Python filesystems.

    https://filesystem-spec.readthedocs.io/en/latest/index.html

    Parameters
    ----------
    fs : FSSpec-compliant filesystem instance

    Examples
    --------
    >>> PyFileSystem(FSSpecHandler(fsspec_fs)) # doctest: +SKIP
    c                 ó   — || _         y ©N)r9   )Úselfr9   s     r#   Ú__init__zFSSpecHandler.__init__  s	   € Øˆ�r%   c                 ó`   — t        |t        «      r| j                  |j                  k(  S t        S rV   ©r*   r6   r9   ÚNotImplemented©rW   Úothers     r#   Ú__eq__zFSSpecHandler.__eq__  ó%   € Ü�eœ]Ô+Ø—7‘7˜eŸh™hÑ&Ð&ÜÐr%   c                 ó`   — t        |t        «      r| j                  |j                  k7  S t        S rV   rZ   r\   s     r#   Ú__ne__zFSSpecHandler.__ne__   r_   r%   c                 ób   — | j                   j                  }t        |t        «      r|d   }d|› �S )Nr   zfsspec+)r9   Úprotocolr*   Úlist)rW   rc   s     r#   Úget_type_namezFSSpecHandler.get_type_name%  s1   € Ø—7‘7×#Ñ#ˆÜ�h¤Ô%Ø ‘{ˆHØ˜˜
Ð#Ð#r%   c                 ó   — |S rV   © ©rW   r2   s     r#   r.   zFSSpecHandler.normalize_path+  s   € Øˆr%   c           	      óÒ   — |d   }|d   dk(  rt         j                  }n+|d   dk(  rt         j                  }d }nt         j                  }t	        | |||j                  dd «      ¬«      S )NÚsizer0   ÚfileÚ	directoryÚmtime)rj   rm   )r   ÚFiler1   ÚUnknownr   Úget)r2   Úinforj   Úftypes       r#   Ú_create_file_infozFSSpecHandler._create_file_info.  sc   € à�F‰|ˆØ�‰<˜6Ò!Ü—M‘M‰EØ�&‰\˜[Ò(Ü×&Ñ&ˆEà‰Dä×$Ñ$ˆEÜ˜˜e¨$°d·h±h¸wÈÓ6MÔNÐNr%   c                 ó  — g }|D ]?  }	 | j                   j                  |«      }|j                  | j                  ||«      «       ŒA |S # t        $ r, |j                  t        |t        j                  «      «       Y Œxw xY wrV   )r9   rq   Úappendrs   ÚFileNotFoundErrorr   r   r?   )rW   ÚpathsÚinfosr2   rq   s        r#   r/   zFSSpecHandler.get_file_info;  s~   € ØˆØò 	AˆDðAØ—w‘w—|‘| DÓ)�ð —‘˜T×3Ñ3°D¸$Ó?Õ@ð	Að ˆøô	 %ò @Ø—‘œX d¬H×,=Ñ,=Ó>Ö?ð@ús   ‰A	Á	2A>Á=A>c                 óX  — | j                   j                  |j                  «      s]| j                   j                  |j                  «      rt	        |j                  «      ‚|j
                  rg S t        |j                  «      ‚|j                  rd }nd}g }| j                   j                  |j                  |dd¬«      }|j                  «       D ]X  \  }}|j                  d«      }|j                  j                  d«      }||k7  sŒ8|j                  | j                  ||«      «       ŒZ |S )Né   T)ÚmaxdepthÚwithdirsÚdetailú/)r9   ÚisdirÚbase_dirÚexistsÚNotADirectoryErrorÚallow_not_foundrv   rI   ÚfindÚitemsÚstripru   rs   )	rW   Úselectorr{   rx   Úselected_filesr2   rq   Ú_pathr€   s	            r#   Úget_file_info_selectorz$FSSpecHandler.get_file_info_selectorF  s	  € Ø�w‰w�}‰}˜X×.Ñ.Ô/Ø�w‰w�~‰~˜h×/Ñ/Ô0Ü(¨×):Ñ):Ó;Ð;à×+Ò+Ø�Iä+¨H×,=Ñ,=Ó>Ð>à×ÒØ‰HàˆHàˆØŸ™Ÿ™Ø×Ñ¨¸4Èð &ó 
ˆð )×.Ñ.Ó0ò 	A‰JˆD�$Ø—J‘J˜s“OˆEØ×(Ñ(×.Ñ.¨sÓ3ˆHð ˜Ó Ø—‘˜T×3Ñ3°D¸$Ó?Õ@ð	Að ˆr%   c                 ó^   — 	 | j                   j                  ||¬«       y # t        $ r Y y w xY w)N)Úcreate_parents)r9   ÚmkdirÚFileExistsError)rW   r2   rI   s      r#   Ú
create_dirzFSSpecHandler.create_dirc  s-   € ð	Ø�G‰G�M‰M˜$¨yˆMÕ9øÜò 	Ùð	ús   ‚   	,«,c                 ó>   — | j                   j                  |d¬«       y ©NTrH   )r9   Úrmrh   s     r#   Ú
delete_dirzFSSpecHandler.delete_dirj  s   € Ø�‰�
‰
�4 4ˆ
Õ(r%   c                 óR  — 	 | j                   j                  |d¬«      }|D ]r  }| j                   j                  |«      r| j                   j	                  |d¬«       Œ<| j                   j                  |«      sŒX| j                   j	                  |«       Œt y # t        $ r |rY y ‚ w xY w)NF)r}   TrH   )r9   Úlistdirrv   r   r’   Úisfile)rW   r2   Úmissing_dir_okÚsubpathsÚsubpaths        r#   Ú_delete_dir_contentsz"FSSpecHandler._delete_dir_contentsm  sŒ   € ð	Ø—w‘w—‘ t°E�Ó:ˆHð
  ò 	$ˆGØ�w‰w�}‰}˜WÔ%Ø—‘—
‘
˜7¨d�
Õ3Ø—‘—‘ Õ(Ø—‘—
‘
˜7Õ#ñ		$øô	 !ò 	ÙÙØð	ús   ‚B ÂB&Â$B&c                 ój   — |j                  d«      dk(  rt        d|d«      ‚| j                  ||«       y )Nr~   Ú z$delete_dir_contents called on path 'r   )r†   r,   rš   )rW   r2   r—   s      r#   Údelete_dir_contentsz!FSSpecHandler.delete_dir_contentsz  s8   € Ø�:‰:�c‹?˜bÒ ÜØ6¸¸cóCð Cà×!Ñ! $¨Õ7r%   c                 ó(   — | j                  dd«       y )Nr~   F)rš   )rW   s    r#   Údelete_root_dir_contentsz&FSSpecHandler.delete_root_dir_contents€  s   € Ø×!Ñ! # uÕ-r%   c                 ó†   — | j                   j                  |«      st        |«      ‚| j                   j                  |«       y rV   )r9   r�   rv   r’   rh   s     r#   Údelete_filezFSSpecHandler.delete_fileƒ  s/   € ð �w‰w�~‰~˜dÔ#Ü# DÓ)Ð)Ø�‰�
‰
�4Õr%   c                 ó@   — | j                   j                  ||d¬«       y r‘   )r9   Úmv©rW   ÚsrcÚdests      r#   ÚmovezFSSpecHandler.moveŠ  s   € Ø�‰�
‰
�3˜¨ˆ
Õ-r%   c                 ó<   — | j                   j                  ||«       y rV   )r9   Úcopyr¤   s      r#   Ú	copy_filezFSSpecHandler.copy_file�  s   € ð 	�‰�‰�S˜$Õr%   c                 ó¤   — ddl m} | j                  j                  |«      st	        |«      ‚ || j                  j                  |d¬«      d¬«      S ©Nr   ©Ú
PythonFileÚrb©ÚmodeÚr©Úpyarrowr®   r9   r–   rv   Úopen©rW   r2   r®   s      r#   Úopen_input_streamzFSSpecHandler.open_input_stream”  ó>   € Ý&à�w‰w�~‰~˜dÔ#Ü# DÓ)Ð)á˜$Ÿ'™'Ÿ,™, t°$˜,Ó7¸cÔBÐBr%   c                 ó¤   — ddl m} | j                  j                  |«      st	        |«      ‚ || j                  j                  |d¬«      d¬«      S r¬   r³   r¶   s      r#   Úopen_input_filezFSSpecHandler.open_input_fileœ  r¸   r%   c                 óX   — ddl m}  || j                  j                  |d¬«      d¬«      S )Nr   r­   Úwbr°   Úw©r´   r®   r9   rµ   ©rW   r2   Úmetadatar®   s       r#   Úopen_output_streamz FSSpecHandler.open_output_stream¤  ó#   € Ý&á˜$Ÿ'™'Ÿ,™, t°$˜,Ó7¸cÔBÐBr%   c                 óX   — ddl m}  || j                  j                  |d¬«      d¬«      S )Nr   r­   Úabr°   r½   r¾   r¿   s       r#   Úopen_append_streamz FSSpecHandler.open_append_stream©  rÂ   r%   N)r5   Ú
__module__Ú__qualname__Ú__doc__rX   r^   ra   re   r.   Ústaticmethodrs   r/   rŠ   r�   r“   rš   r�   rŸ   r¡   r§   rª   r·   rº   rÁ   rÅ   rg   r%   r#   r6   r6   	  s€   „ ñòòò
ò
$òð ñ
Oó ð
Oò	òò:ò)ò$ò8ò.òò.ò òCòCòCó
Cr%   r6   rV   )NN),rÈ   Úpyarrow.utilr   r   Úpyarrow._fsr   r   r   r   r	   r
   r   r   r   r   r   Ú	FileStatsr   Úpyarrow._azurefsr   r    ru   Úpyarrow._hdfsr   Úpyarrow._gcsfsr   Úpyarrow._s3fsr   r   r   r   r   r   r   r   r   r   ÚatexitÚregisterr$   r<   rD   rS   r6   rg   r%   r#   ú<module>rÓ      s4  ðñ$÷ 8÷÷ ÷ ñ ð €	à€ð,Ý0ð-Ý.ð*Ý,ð)÷L÷ L÷ Ló Ø€F‡O�OÐ'Ô(ò	ð 05ô *
ðZ9Àeô 9ðz ?CðH-à&°DôH-ôVcCÐ%õ cCøð{ ò ,Ø×ÑÐ*Ö+ð,ûð
 ò -Ø×ÑÐ+Ö,ð-ûð
 ò *Ø×Ñ˜Ö)ð*ûð ò )Ø×Ñ˜Ö(ð)úsD   ªB ±B. ¸C
 ¿C& ÂB+Â*B+Â.CÃCÃ
C#Ã"C#Ã&C?Ã>C?