
    7ThY                       % S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	J
r
  S SKJr  S SKJr  S SKJrJrJrJrJrJrJrJr  S SKJr  \(       a  S SKrS SKJr  S S	KJr  S
r\" S5      r  S'     S(S jjr! S'     S)S jjr"0 r#S\$S'   S*S jr%S+S jr&S,S jr'  S-           S.S jjr(S/S jr)S0S jr*        S1S jr+S2S jr,  S3         S4S jjr-S5S jr.S6S jr/S7S jr0S8S jr1S9S jr2    S:         S;S jjr3S<S jr4      S=S  jr5\Rl                  S>S! j5       r7   S?             S@S" jjr8SAS# jr9\Rl                  SBSCS$ jj5       r:S% r;S& r<g)D    )annotationsN)partial)md5)version)IOTYPE_CHECKINGAnyCallableIterableIteratorSequenceTypeVar)urlsplit)	TypeGuard)AbstractFileSystemi  P Tc                   [         R                  " SU 5      (       d  [         R                  " SU 5      c  SU S.$ [        U 5      nUR                  =(       d    SnUR                  (       a(  SR                  UR                  UR                  /5      nOUR                  nUS:X  a7  [         R                  " SU5      nU(       a  UR                  5       u  pdU SU 3nUS;   a  X0S.$ X4S.nUR                  (       a  UR                  R                  S	S
5      S   R                  SS
5      S   US'   US;   a  US   US   -   US'   OUS   US'   UR                  (       a  UR                  US'   UR                  (       a  UR                  US'   UR                  (       a  UR                  US'   UR                  (       a  UR                  US'   UR                  (       a  UR                  US'   U(       a  [        Xq5        U$ )aO  Infer storage options from URL path and merge it with existing storage
options.

Parameters
----------
urlpath: str or unicode
    Either local absolute file path or URL (hdfs://namenode:8020/file.csv)
inherit_storage_options: dict (optional)
    Its contents will get merged with the inferred information from the
    given path

Returns
-------
Storage options dict.

Examples
--------
>>> infer_storage_options('/mnt/datasets/test.csv')  # doctest: +SKIP
{"protocol": "file", "path", "/mnt/datasets/test.csv"}
>>> infer_storage_options(
...     'hdfs://username:pwd@node:123/mnt/datasets/test.csv?q=1',
...     inherit_storage_options={'extra': 'value'},
... )  # doctest: +SKIP
{"protocol": "hdfs", "username": "username", "password": "pwd",
"host": "node", "port": 123, "path": "/mnt/datasets/test.csv",
"url_query": "q=1", "extra": "value"}
z^[a-zA-Z]:[\\/]z^[a-zA-Z0-9]+://file)protocolpath#z^/([a-zA-Z])[:|]([\\/].*)$:)httphttps@   r   host)s3s3agcsgsr   portusernamepassword	url_queryurl_fragment)rematchr   schemefragmentjoinr   groupsnetlocrsplitr#   r$   r%   queryupdate_storage_options)urlpathinherit_storage_optionsparsed_pathr   r   windows_pathdriveoptionss           D/var/www/auris/envauris/lib/python3.13/site-packages/fsspec/utils.pyinfer_storage_optionsr9   &   s   @ 	#W--88'19"G447#K!!+VHxx));+?+?@A6 xx =tD&--/KEWAdV$D$$$66+3BG &,,33C;B?FFsANqQ11%fo?GFO%foGFO)..GFO"-"6"6GJ"-"6"6GJ*00"-"6"6w@N    c                    U(       d  0 n[        U 5      [        U5      -  nU(       a;  U H5  nU R                  U5      UR                  U5      :w  d  M)  [        SU 35      e   U R                  U5        g )Nz9Collision between inferred and specified storage option:
)setgetKeyErrorupdate)r7   	inherited
collisions	collisions       r8   r1   r1   {   so     	WI.J#I{{9%y)AA  ){,  $ NN9r:   zdict[str, str]compressionsc                    [         R                  R                  U 5      S   R                  S5      R	                  5       nU[
        ;   a	  [
        U   $ g)a	  Infer compression, if available, from filename.

Infer a named compression type, if registered and available, from filename
extension. This includes builtin (gz, bz2, zip) compressions, as well as
optional compressions. See fsspec.compression.register_compression.
r   .N)osr   splitextstriplowerrC   )filename	extensions     r8   infer_compressionrL      sG       *2.44S9??AIL I&&r:   c                   ^ U S-  n [        [        R                  " [        R                  " U 5      5      5      mSU4S jjnU$ )aU  Returns a function that receives a single integer
and returns it as a string padded by enough zero characters
to align with maximum possible integer

>>> name_f = build_name_function(57)

>>> name_f(7)
'07'
>>> name_f(31)
'31'
>>> build_name_function(1000)(42)
'0042'
>>> build_name_function(999)(42)
'042'
>>> build_name_function(0)(0)
'0'
g:0yE>c                8   > [        U 5      R                  T5      $ N)strzfill)i
pad_lengths    r8   name_function*build_name_function.<locals>.name_function   s    1v||J''r:   )rR   intreturnrP   )rV   mathceillog10)max_intrT   rS   s     @r8   build_name_functionr\      s7    & tOGTYYtzz'234J( r:   c                   U R                  5       S:X  a  gSn U R                  U5      nU(       d  gU(       a  X4-   OUn X;   aL  UR                  U5      nU R                  U R                  5       [	        U5      U-
  -
  [	        U5      -   5        g[	        U5      U:  a  g U[	        U5      * S nM  ! [
        [        4 a     N#f = f)a\  Seek current file to file start, file end, or byte after delimiter seq.

Seeks file to next chunk delimiter, where chunks are defined on file start,
a delimiting sequence, and file end. Use file.tell() to see location afterwards.
Note that file start is a valid split, so must be at offset > 0 to seek for
delimiter.

Parameters
----------
file: a file
delimiter: bytes
    a delimiter like ``b'\n'`` or message sentinel, matching file .read() type
blocksize: int
    Number of bytes to read from the file at once.


Returns
-------
Returns True if a delimiter was found, False if at file start or end.

r   FNT)tellreadindexseeklenOSError
ValueError)r   	delimiter	blocksizelastcurrentfullrR   s          r8   seek_delimiterrj      s    . yy{a D
))I&!%t~7		 JJy)		$))+TQ7#i.HIW	) *
 S^O%&!  $ 		s    AB3 B3 3CCc                   U(       a  U R                  U5        [        XS5      nUc  U R                  5       $ U R                  5       nX&U-
  -  nU R                  Xb-   5        [        XS5      nU R                  5       nU(       a  U(       a  U[	        U5      -  nU(       a  U(       a  U[	        U5      -  nUnX-
  nU R                  U5        Uc   eU R                  U5      n	U	$ )a  Read a block of bytes from a file

Parameters
----------
f: File
    Open file
offset: int
    Byte offset to start read
length: int
    Number of bytes to read, read through end of file if None
delimiter: bytes (optional)
    Ensure reading starts and stops at delimiter bytestring
split_before: bool (optional)
    Start/stop read *before* delimiter bytestring.


If using the ``delimiter=`` keyword argument we ensure that the read
starts and stops at delimiter boundaries that follow the locations
``offset`` and ``offset + length``.  If ``offset`` is zero then we
start at zero, regardless of delimiter.  The bytestring returned WILL
include the terminating delimiter string.

Examples
--------

>>> from io import BytesIO  # doctest: +SKIP
>>> f = BytesIO(b'Alice, 100\nBob, 200\nCharlie, 300')  # doctest: +SKIP
>>> read_block(f, 0, 13)  # doctest: +SKIP
b'Alice, 100\nBo'

>>> read_block(f, 0, 13, delimiter=b'\n')  # doctest: +SKIP
b'Alice, 100\nBob, 200\n'

>>> read_block(f, 10, 10, delimiter=b'\n')  # doctest: +SKIP
b'Bob, 200\nCharlie, 300'
i   )ra   rj   r_   r^   rb   )
foffsetlengthre   split_beforefound_start_delimstartfound_end_delimendbs
             r8   
read_blockru      s    V 	v*1?>668O&. 	u~(u=ffh S^#E|3y>!CFF6N 	vAHr:   c                     U(       a  X4-  n  [        [        U 5      R                  5       5      nUR	                  5       $ ! [         a3    [        [        U 5      R                  5       SS9n UR	                  5       $ f = f)zDeterministic token

(modified from dask.base)

>>> tokenize([1, 2, '3'])
'9d71491b50023b06fc76928e6eddb952'

>>> tokenize('Hello') == tokenize('Hello')
True
F)usedforsecurity)r   rP   encoderd   	hexdigest)argskwargshs      r8   tokenizer}   4  sq     	;D	  "# ;;=  ;D	  "E:;;=;s   "A   +A=<A=c                    [        U [        5      (       a  U $ [        U S5      (       a  U R                  5       $ [        U S5      (       a  U R                  $ U $ )a  Attempt to convert a path-like object to a string.

Parameters
----------
filepath: object to be converted

Returns
-------
filepath_str: maybe a string version of the object

Notes
-----
Objects supporting the fspath protocol are coerced according to its
__fspath__ method.

For backwards compatibility with older Python version, pathlib.Path
objects are specially coerced.

Any other object is passed through unchanged, which includes bytes,
strings, buffers, or anything else that's not even path-like.

__fspath__r   )
isinstancerP   hasattrr   r   )filepaths    r8   stringify_pathr   I  sN    , (C  	<	(	(""$$	6	"	"}}r:   c                6    U " U0 UD6nUR                  5         U$ rO   )_determine_worker)clsrz   r{   insts       r8   make_instancer   i  s$     DKr:   c                  ^^ U  Vs/ s H  oR                  S5      PM     snm[        S T 5       5      nSn[        U5       H"  m[        UU4S jT 5       5      nU(       a  M"    O   TU-  mSR	                  TS   ST 5      $ s  snf )z;For a list of paths, find the shortest prefix common to all/c              3  8   #    U  H  n[        U5      v   M     g 7frO   )rb   ).0ps     r8   	<genexpr> common_prefix.<locals>.<genexpr>t  s     %u!s1vvu   r   c              3  >   >#    U  H  oT   TS    T   :H  v   M     g7f)r   N )r   r   rR   partss     r8   r   r   w  s      5u!A$%(1+%us   N)splitminrangeallr,   )pathsr   lmaxrs   rR   r   s       @@r8   common_prefixr   q  s    #()5aWWS\5)E%u%%D
C4[5u55s  HA88E!HRaL!! *s   Bc           	     8   [        U[        5      (       a  UR                  S5      nU(       a6  U  Vs/ s H'  nSR                  XR	                  S5      S   45      PM)     nnU$ [        U 5      nU(       a  UR                  SS5      S   nU(       d;  [        S U  5       5      (       a$  U  Vs/ s H  nSR                  X/5      PM     nnU$ U  Vs/ s H  oDR                  XQS5      PM     nn U$ [        U 5      [        U5      :X  d   eU$ s  snf s  snf s  snf )aE  In bulk file operations, construct a new file tree from a list of files

Parameters
----------
paths: list of str
    The input file tree
path2: str or list of str
    Root to construct the new list in. If this is already a list of str, we just
    assert it has the right number of elements.
exists: bool (optional)
    For a str destination, it is already exists (and is a dir), files should
    end up inside.
flatten: bool (optional)
    Whether to flatten the input directory tree structure so that the output files
    are in the same directory.

Returns
-------
list of str
r   r   r   r   c              3  L   #    U  H  oR                  S 5      (       + v   M     g7f)r   N)
startswithr   ss     r8   r   other_paths.<locals>.<genexpr>  s     CU,,s"333Us   "$)
r   rP   rstripr,   r   r   r/   r   replacerb   )r   path2existsflattenr   cps         r8   other_pathsr   ~  s   6 %S!BGH%QSXXuggcl2&678%EH L u%BYYsA&q)#CUCCC7<=u!5*-u=
 L ;@@%Q2a0%@ L 5zSZ'''L I >@s   .D-DDc                "    [        U [        5      $ rO   )r   BaseExceptionobjs    r8   is_exceptionr     s    c=))r:   c                .   ^  [        U 4S jS 5       5      $ )Nc              3  <   >#    U  H  n[        TU5      v   M     g 7frO   )r   )r   attrrl   s     r8   r   isfilelike.<locals>.<genexpr>  s     F,EDwq$,Es   )r_   closer^   )r   )rl   s   `r8   
isfileliker     s    F,EFFFr:   c                n    [        U 5      n [        R                  " SU SS9n[        U5      S:  a  US   $ g)Nz(\:\:|\://)r   )maxsplitr   r   )r   r(   r   rb   )urlr   s     r8   get_protocolr     s5    

CHH^S15E
5zA~Qxr:   c                t    SSK Jn   [        U" [        U 5      5      SS5      $ ! [        [
        4 a     gf = f)z*Can the given URL be used with open_local?r   )get_filesystem_class
local_fileF)fsspecr   getattrr   rd   ImportError)r   r   s     r8   can_be_localr     s;    ++L,>?uUU$ s   $ 77c                    U [         R                  ;   a0  [         R                  U    n[        US5      (       a  UR                  $  [	        U 5      $ !    O= f SSKnUR                  U 5      nUR                  $ ! [        [        4 a     gf = f)zFor given package name, try to find the version without importing it

Import and package.__version__ is still the backup here, so an import
*might* happen.

Returns either the version string, or None if the package
or the version was not readily  found.
__version__r   N)	sysmodulesr   r   r   	importlibimport_moduler   AttributeError)namemodr   s      r8   "get_package_version_without_importr     s     s{{kk$3&&??"t}%%d+( s   
A A A: :BBc                d   U c  Uc  [        S5      eU =(       d    [        R                  " U5      n [        R                  " 5       n[        R                  " S5      nUR                  U5        U(       a  U R                  R                  5         U R                  U5        U R                  U5        U $ )Nz+Provide either logger object or logger namezD%(asctime)s - %(name)s - %(levelname)s - %(funcName)s -- %(message)s)
rd   logging	getLoggerStreamHandler	FormattersetFormatterhandlersclear
addHandlersetLevel)loggerlogger_namelevelr   handle	formatters         r8   setup_loggingr     s     ~+-FGG5w((5F""$F!!NI 	"
f
OOEMr:   c                $    UR                  U 5      $ rO   )unstrip_protocol)r   fss     r8   _unstrip_protocolr     s    t$$r:   c                .   ^ ^^ SU 4S jjmSUU4S jjnU$ )ziMirror attributes and methods from the given
origin_name attribute of the instance to the
decorated classc                2   > [        UT5      n[        X 5      $ rO   )r   )methodselforiginorigin_names      r8   origin_getter"mirror_from.<locals>.origin_getter   s    {+v&&r:   c                \   > T H$  n[        TU5      n[        X[        U5      5        M&     U $ rO   )r   setattrproperty)r   r   wrapped_methodmethodsr   s      r8   wrappermirror_from.<locals>.wrapper  s/    F$]F;NC.!9:  
r:   )r   rP   r   r	   rW   r	   )r   type[T]rW   r   r   )r   r   r   r   s   `` @r8   mirror_fromr     s    '  Nr:   c              #     #    U v   g 7frO   r   r   s    r8   nullcontextr     s
     
Is   c           
     j   [        U [        5      (       d  [        e[        U[        5      (       d  U/[        U 5      -  n[        U[        5      (       d  U/[        U 5      -  n[        U5      [        U 5      :w  d  [        U5      [        U 5      :w  a  [        e[        U5      S::  a  XU4$ U Vs/ s H  of=(       d    SPM     nnU(       a%  S [        [        [        XU5      5      6  5       u  pnU (       a  U SS nUSS nUSS n	[        S[        U 5      5       H  n
X
   X
S-
     :X  a  U	S   c  M  X
   X
S-
     :w  d  X   U	S   -
  U:  d  UbI  X*   US   -
  U:  a;  UR                  X
   5        UR                  X   5        U	R                  X*   5        M  X*   U	S'   M     XxU	4$ XU4$ s  snf )ae  Merge adjacent byte-offset ranges when the inter-range
gap is <= `max_gap`, and when the merged byte range does not
exceed `max_block` (if specified). By default, this function
will re-order the input paths and byte ranges to ensure sorted
order. If the user can guarantee that the inputs are already
sorted, passing `sort=False` will skip the re-ordering.
r   r   c              3  8   #    U  H  n[        U5      v   M     g 7frO   )list)r   vs     r8   r   &merge_offset_ranges.<locals>.<genexpr>2  s!      
 GGr   Nr   )	r   r   	TypeErrorrb   rd   zipsortedr   append)r   startsendsmax_gap	max_blocksortr   	new_paths
new_startsnew_endsrR   s              r8   merge_offset_rangesr     s     eT""fd##CJ&dD!!vE
"
6{c%j CIU$; 6{ad""$%ff1ffF%
t,
t  "1I	BQZ
8q#e*%Ax5Q<'HRL,@Ea%L(Y"-8)twB/G9.T   *!!&),(  $w! &" h.. $M &s   1F0c                    U R                  5       n U R                  SS5      U R                  U5        $ ! U R                  U5        f = f)z+Find length of any open read-mode file-liker      )r^   ra   )filelikeposs     r8   	file_sizer  X  s9    
--/C}}Q"ccs	   5 Ac              #    #    [         R                  " [        R                  R	                  U 5      [        R                  R                  U 5      S-   S9u  p# [        X!5       nUv   SSS5        [        R                  " X05        g! , (       d  f       N%= f! [         aL    [        R                  " [        5         [        R                  " U5        SSS5        e ! , (       d  f       e = ff = f7f)z
A context manager that opens a temporary file next to `path` and, on exit,
replaces `path` with the temporary file, thereby updating `path`
atomically.
-)dirprefixN)tempfilemkstemprF   r   dirnamebasenameopenr   r   
contextlibsuppressFileNotFoundErrorunlink)r   modefdfnfps        r8   atomic_writer  a  s      GGOOD!"''*:*:4*@3*FFB"^rH  	

2 ^   !23IIbM 4 43sN   AC1B #B(B 0C1
BB $C.<C	C.
C*	&C..C1c                   / nUR                   nS[        U 5      peXV:  Ga  X   nUS-   nUS:X  a  U(       a  US   ULa  U" U5        GOUS:X  a
  U" U5        GOUS:X  Ga  UnX:  a  X   S:X  a  US-   nX:  a  X   S:X  a  US-   nX:  a  X   S:w  a  US-   nX:  a
  X   S:w  a  M  X:  a
  U" S	5        GOXU n	S
U	;  a  U	R                  SS5      n	O/ n
X   S:X  a  US-   OUS-   n U R                  S
X5      nUS:  a  OU
R                  XU 5        US-   nUS-   nM8  XU nU(       a  U
R                  U5        OU
S==   S
-  ss'   [	        [        U
5      S-
  SS5       H1  nXS-
     S   X   S   :  d  M  XS-
     S S X   SS  -   XS-
  '   X	 M3     S
R                  S U
 5       5      n	[        R                  " SSU	5      n	US-   nU	(       d	  U" S5        OXU	S:X  a	  U" S5        OIU	S   S:X  a	  SU	SS  -   n	OU	S   S;   a  SU	-   n	U" SU	 S35        OU" [        R                  " U5      5        XV:  a  GM  XV:X  d   eU$ )Nr   r   *r   ?[!]z\[r  \\\r     c              3  d   #    U  H&  oR                  S S5      R                  SS5      v   M(     g7f)r  r  r  z\-N)r   r   s     r8   r   _translate.<locals>.<genexpr>  s,      %LRq		$.66sEBBFs   .0z([&~|])z\\\1z(?!)rE   ^)r#  r  )	r   rb   r   findr   r,   r(   subescape)patSTARQUESTION_MARKresaddrR   ncjstuffchunkskchunks                r8   
_translater3  v  s   C
**Cc#hq
%FE8CG4/D	#X#XAu3Eu3E%CFcME %CFcMvE
ae#!MM$6EF!$3AAEAHHS!/q5!cAh/EE   !HEe,r
c)
"3v;?Ar:!a%=,vy|;,2q5M#2,>12,NFq5M &	 ;  HH %LR% E z7E:EKc\HQx3 #eABiqZ/ $u!E7!%		!A %B 6M6Jr:   c                P   [         R                  R                  (       a6  [         R                  R                  [         R                  R                  -   nO[         R                  R                  nSR	                  [        [        R                  U5      5      n[        U5      S:  a  SU S3OUnSU S3nU S3nU U 3nSU S3nS	n/ n	[        R                  " X05      n
[        U
5      S-
  n[        U
5       H  u  pUS
:X  a  U	R                  X:  a  UOU5        M%  US:X  a  U	R                  X:  a  UOU5        ME  SU;   a  [        S5      eU(       a  U	R                  [        X S
3U5      5        X:  d  M  U	R                  U5        M     SR	                  U	5      nSU S3$ )zBTranslate a pathname with shell wildcards to a regular expression. r   r  r  z[^+z(?:.+z)?z.*r  z**z:Invalid pattern: '**' can only be an entire path componentz(?s:z)\Z)rF   r   altsepsepr,   mapr(   r&  rb   r   	enumerater   rd   extendr3  )r'  sepsescaped_sepsany_sepnot_sepone_last_segmentone_segmentany_segmentsany_last_segmentsresultsr   last_part_idxidxpartr*  s                  r8   glob_translaterH    sy   
 
ww~~ww{{RWW^^+ww{{773ryy$/0L%(Y],q!G<."G!!}%&wi0K7)2&LGHHW"EJNMu%	3;NN#*=;CST4<NN3+><DUVT\L  NN:diqM7CDNN7# & '''
C3%sr:   rO   )r2   rP   r3   dict[str, Any] | NonerW   dict[str, Any])r7   rJ  r@   rI  rW   None)rJ   rP   rW   
str | None)r[   floatrW   zCallable[[int], str])r   	IO[bytes]re   bytesrf   rV   rW   bool)NF)rl   rN  rm   rV   rn   
int | Nonere   zbytes | Nonero   rP  rW   rO  )rz   r	   r{   r	   rW   rP   )r   z%str | os.PathLike[str] | pathlib.PathrW   rP   )r   zCallable[..., T]rz   zSequence[Any]r{   rJ  rW   r   )r   Iterable[str]rW   rP   )FF)
r   	list[str]r   zstr | list[str]r   rP  r   rP  rW   rS  )r   r	   rW   rP  )rl   r	   rW   zTypeGuard[IO[bytes]])r   rP   rW   rP   )r   rP   rW   rP  )r   rP   rW   rL  )NNDEBUGT)
r   zlogging.Logger | Noner   rL  r   rP   r   rP  rW   zlogging.Logger)r   rP   r   r   rW   rP   )r   rP   r   rR  rW   zCallable[[type[T]], type[T]])r   r   rW   zIterator[T])r   NT)r   rS  r   list[int] | intr   rU  r   rV   r   rQ  r   rP  rW   z&tuple[list[str], list[int], list[int]])r  rN  rW   rV   )wb)r   rP   r  rP   )=
__future__r   r  r   rX   rF   r(   r   r
  	functoolsr   hashlibr   importlib.metadatar   typingr   r   r	   r
   r   r   r   r   urllib.parser   pathlibtyping_extensionsr   fsspec.specr   DEFAULT_BLOCK_SIZEr   r9   r1   rC   __annotations__rL   r\   rj   ru   r}   r   r   r   r   r   r   r   r   r   r   r   r   contextmanagerr   r   r  r  r3  rH  r   r:   r8   <module>rc     s   "    	 	 
    &	 	 	 "+.  CL DHRR+@RRl AE(=	"  "n !
:.'j #GGG G 	G
 G GT*@	!.8F
"  	*** * 	*
 *Z*G6 %)"	!  	
 *%,!(    CCC C 	C
 C C ,CL  (GT#r:   