
    7Th                         S SK r S SKrS SKrS SKrS SKr " S S\R
                  5      r " S S\R                  R                  5      r	g)    Nc                   h   ^  \ rS rSrSrSrSU 4S jjrSS jrSS jrS r	SS jr
S	 rSS
 jrSrU =r$ )JupyterFileSystem
   z?View of the files as seen by a Jupyter server (notebook or lab))jupyterjlabc                   > SU;   a3  Uc   [         R                  " SU5      S   nUR	                  SS5      S   nUR                  S5      S-   U l        [        R                  " 5       U l	        U(       a  S	U 3U R                  R                  S
'   [        TU ]0  " S0 UD6  g! [         a  n[        S5      UeSnAff = f)z

Parameters
----------
url : str
    Base URL of the server, like "http://127.0.0.1:8888". May include
    token in the string, which is given by the process when starting up
tok : str
    If the token is obtained separately, can be given here
kwargs
?Nztoken=([a-z0-9]+)r   zCould not determine token   /z/api/contentsztoken Authorization )refindall
IndexError
ValueErrorsplitrstripurlrequestsSessionsessionheaderssuper__init__)selfr   tokkwargse	__class__s        V/var/www/auris/envauris/lib/python3.13/site-packages/fsspec/implementations/jupyter.pyr   JupyterFileSystem.__init__   s     #:{I**%8#>qAC ))C#A&C::c?_4'')6<SENDLL  1"6" " I$%@AqHIs   B" "
B=,B88B=c                    U R                  U5      nU R                  R                  U R                   SU 35      nUR                  S:X  a  [        U5      $ UR                  5         UR                  5       nUS   S:X  a  US   nOU/nU H8  nUR                  S5      US'   UR                  S5        US   S:X  d  M3  S	US'   M:     U(       a  U$ U Vs/ s H  ofS   PM	     sn$ s  snf )
Nr     type	directorycontentpathnamenotebookfile)	_strip_protocolr   getr   status_codeFileNotFoundErrorraise_for_statusjsonpop)r   r'   detailr   routos          r    lsJupyterFileSystem.ls)   s    ##D)LLz4&12==C$T**	ffhv;+%i.C%CAfAfIEE)yJ&"&		 
 J#&'3a&	3'''s   C%c                 b   U R                  U5      nU R                  R                  U R                   SU 35      nUR                  S:X  a  [        U5      $ UR                  5         UR                  5       nUS   S:X  a  US   R                  5       nO[        R                  " US   5      nXrU $ )Nr   r#   formattextr&   )r+   r   r,   r   r-   r.   r/   r0   encodebase64	b64decode)r   r'   startendr   r3   r4   bs           r    cat_fileJupyterFileSystem.cat_file>   s    ##D)LLz4&12==C$T**	ffhx=F"I%%'A  Y0As|    c                    U R                  U5      nUR                  SS5      S   U[        U5      [        R                  " U5      R                  5       SSS.nU R                  R                  U R                   SU 3US9  g )Nr   r
   r<   r*   )r(   r'   sizer&   r9   r$   r0   )	r+   rsplitlenr<   	b64encodedecoder   putr   )r   r'   value_r0   s        r    	pipe_fileJupyterFileSystem.pipe_fileL   s{    ##D)KKQ'+J''.557
 	DHH:Qtf-D9rC   c                    U R                  U5      nU(       a+  SU;   a%  U R                  UR                  SS5      S   S5        UR                  SS5      S   US S SS.nU R                  R	                  U R
                   SU 3US9  g )	Nr   r
   r   TrE   r%   )r(   r'   rF   r&   r$   rG   )r+   mkdirrH   r   rL   r   )r   r'   create_parentsr   r0   s        r    rR   JupyterFileSystem.mkdirX   s    ##D)cTkJJt{{3*1-t4KKQ'+
 	DHH:Qtf-D9rC   c                 z    U R                  U5      nU R                  R                  U R                   SU 35        g )Nr   )r+   r   deleter   )r   r'   s     r    _rmJupyterFileSystem._rme   s3    ##D)txxj$01rC   c                     U R                  U5      nUS:X  a'  U R                  U5      n[        R                  " U5      $ [	        XSS9$ )Nrbwb)mode)r+   rA   ioBytesIOSimpleFileWriter)r   r'   r\   r   datas        r    _openJupyterFileSystem._openi   sC    ##D)4<==&D::d###DT::rC   )r   r   )N)T)NN)rZ   )__name__
__module____qualname____firstlineno____doc__protocolr   r6   rA   rO   rR   rW   ra   __static_attributes____classcell__)r   s   @r    r   r   
   s3    I"H#4(*
::2; ;rC   r   c                       \ rS rSrSS jrSrg)r_   r   c                     USL a  gU R                   R                  S5        U R                   R                  5       nU R                  R	                  U R
                  U5        g)zGNever uploads a chunk until file is done

Not suitable for large files
Fr   N)bufferseekreadfsrO   r'   )r   finalr`   s      r    _upload_chunkSimpleFileWriter._upload_chunks   sJ    
 E>{{!$))T*rC   r   N)F)rc   rd   re   rf   rs   ri   r   rC   r    r_   r_   r   s    	+rC   r_   )
r<   r]   r   r   fsspecAbstractFileSystemr   specAbstractBufferedFiler_   r   rC   r    <module>ry      s?     	 	  e;11 e;P
+v{{77 
+rC   