
    Mht                    ~   d Z ddlmZ ddlZddlZddlZddlZddlZddl	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 ddlmZ dd	lm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 ddl$m%Z% ddl&m'Z'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0m1Z1  ej2        d          Z3 G d de%          Z4 G d de4          Z5dS )z#A base class for contents managers.    )annotationsNfnmatch)ensure_asyncrun_sync)EventLogger)ValidationErrorsign)validate)new_notebook)	HTTPErrorRequestHandler)
AnyBoolDictInstanceList
TraitErrorTypeUnicodedefaultr   )LoggingConfigurable)DEFAULT_EVENTS_SCHEMA_PATHJUPYTER_SERVER_EVENTS_URI)_i18n)import_item   )FilesHandler   )AsyncCheckpointsCheckpointsz\-Copy\d*\.c                  t   e Zd ZU dZedz   Z ee                              d          Z	 e
d          d             Zd Z edd          Z ed	d ed
                    Z ed          d             Z eddd          Z eej                  Z e
d          d             Z e e            g ddd          Z e ed          dd          Z eddd          Z eddd          Z edddd          Z ed          d             Z  edddd          Z! ed           d!             Z"d" Z#d# Z$ e            Z%d$e&d%<    e            Z'd$e&d&<   d' Z(d( Z)d) Z*d* Z+ e,e-d          Z. ee-d          Z/ e0d          Z1 e
d+          d,             Z2 e
d-          d.             Z3 e,e4e5ddd/0          Z6 e0dd1          Z7d2 Z8d3 Z9d4 Z:dNd5Z;d6 Z<dOd7Z=d8 Z>d9 Z?d: Z@d; ZAd< ZBd= ZCd> ZDdPd?ZEdQd@ZFdPdAZGdRdBZHdSdCZIdPdDZJdE ZKdF ZLdNdGZMdNdHZNdI ZOdJ ZPdK ZQdL ZRdM ZSdS )TContentsManagera  Base class for serving files and directories.

    This serves any text or binary file,
    as well as directories,
    with special handling for JSON notebook documents.

    Most APIs take a path argument,
    which is always an API-style unicode path,
    and always refers to a directory.

    - unicode, not url-escaped
    - '/'-separated
    - leading and trailing '/' will be stripped
    - if unspecified, path defaults to '',
      indicating the root path.

    z/contents_service/v1Tconfigevent_loggerc                    | j         r!t          | j         d          r| j         j        S t                      }t          dz  dz  }|                    |           |S )Nr&   contents_servicezv1.yaml)parenthasattrr&   r   r   register_event_schema)selfloggerschema_paths      h/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jupyter_server/services/contents/manager.py_default_event_loggerz%ContentsManager._default_event_loggerC   s^    ; 	74;?? 	;++ !]]F47IIIUK((555M    c                H    | j                             | j        |           dS )zNEmit event using the core event schema from Jupyter Server's Contents Manager.)	schema_iddataN)r&   emitevent_schema_id)r,   r4   s     r/   r5   zContentsManager.emitN   s'    )=DIIIIIr1   / zlPreferred starting directory to use for notebooks. This is an API path (`/` separated, relative to root dir))r%   helppreferred_dirc                6   |d                              d          }	 dd l}|                    | j                  r t	          | j                  |          }n|                     |          }n'# t
          $ r}t          |j                  |d }~ww xY w|st          t          d          |z            | j	        r[	 || j	        j
        k    r9t          j        j        | j        g|                    d          R  | j	        _
        n# t          $ r Y nw xY w|S )Nvaluer7   r   z!Preferred directory not found: %r)stripinspectiscoroutinefunction
dir_existsr   r   r   log_messager   r)   r:   ospathjoinroot_dirsplit)r,   proposalr<   r>   r@   es         r/   _validate_preferred_dirz'ContentsManager._validate_preferred_dir\   s5   !'',,	3NNN**4?;; 46Xdo66u==

!__U33
 	3 	3 	3Q]++2	3 	QU#FGG%OPPP; 	DK55502T]0^U[[Y\M]M]0^0^0^DK-   s+   AA/ /
B9BB?A	D	 	
DDFzAllow access to hidden filesnotaryc                ,    t          j        |           S )N)r)   )r
   NotebookNotaryr,   s    r/   _notary_defaultzContentsManager._notary_defaultv   s    "$////r1   )__pycache__z*.pycz*.pyoz	.DS_Storez*~zC
        Glob patterns to hide in file and directory listings.
    Untitledz4The base name used when creating untitled notebooks.untitledz0The base name used when creating untitled files.zUntitled Folderz6The base name used when creating untitled directories.Nau  Python callable or importstring thereof

        To be called on a contents model prior to save.

        This can be used to process the structure,
        such as removing notebook outputs or other side effects that
        should not be saved.

        It will be called as (all arguments passed by keyword)::

            hook(path=path, model=model, contents_manager=self)

        - model: the model to be saved. Includes file contents.
          Modifying this dict will affect the file that is stored.
        - path: the API path of the save destination
        - contents_manager: this ContentsManager instance
        )r%   
allow_noner9   pre_save_hookc                (   |d         }t          |t                    rt          | j                  }t	          |          sd}t          |          t	          | j                  r,t          j        d| j        j         d|j         dd           |S )Nr<   zpre_save_hook must be callablez#Overriding existing pre_save_hook () with a new one ().   
stacklevel)	
isinstancestrr   rS   callabler   warningswarn__name__r,   rG   r<   msgs       r/   _validate_pre_save_hookz'ContentsManager._validate_pre_save_hook   s    !eS!! 	4 233E 	"2CS//!D&'' 	Mwd6H6Qwwejeswww    r1   a   Python callable or importstring thereof

        to be called on the path of a file just saved.

        This can be used to process the file on disk,
        such as converting the notebook to a script or HTML via nbconvert.

        It will be called as (all arguments passed by keyword)::

            hook(os_path=os_path, model=model, contents_manager=instance)

        - path: the filesystem path to the file just written
        - model: the model representing the file
        - contents_manager: this ContentsManager instance
        post_save_hookc                   |d         }t          |t                    rt          |          }t          |          sd}t	          |          t          | j                  r,t          j        d| j        j         d|j         dd           |S )Nr<   zpost_save_hook must be callablez$Overriding existing post_save_hook (rU   rV   rW   rX   )	rZ   r[   r   r\   r   rc   r]   r^   r_   r`   s       r/   _validate_post_save_hookz(ContentsManager._validate_post_save_hook   s    !eS!! 	'&&E 	"3CS//!D'(( 	Myt7J7Syyglguyyy    r1   c                   t          j        dt          d           | j        rg	 | j                            d|            | j        d
||| d| d	S # t          $ r  t          $ r! | j                            d|d           Y d	S w xY wd	S )z0Run the pre-save hook if defined, and log errorsz@run_pre_save_hook is deprecated, use run_pre_save_hooks instead.rW   rX   Running pre-save hook on %smodelrC   contents_managerzPre-save hook failed on %sTexc_infoN )	r]   r^   DeprecationWarningrS   logdebugr   	Exceptionerror)r,   ri   rC   kwargss       r/   run_pre_save_hookz!ContentsManager.run_pre_save_hook   s    N	
 	
 	
 	

  	R
R<dCCC""[TD[[TZ[[[[[     R R R ;TDQQQQQQR	R 	Rs   ,A 1BBc                4   t          j        dt          d           | j        rt	 | j                            d|           |                     |||            dS # t          $ r1 | j                            d|d           d	}t          d
|          dw xY wdS )z1Run the post-save hook if defined, and log errorszBrun_post_save_hook is deprecated, use run_post_save_hooks instead.rW   rX   Running post-save hook on %sos_pathri   rj   zPost-save hook failed o-n %sTrk   z3fUnexpected error while running post hook save: {e}  N)	r]   r^   rn   rc   ro   rp   rq   rr   r   )r,   ri   rx   ra   s       r/   run_post_save_hookz"ContentsManager.run_post_save_hook   s    P	
 	
 	
 	

  	44=wGGG##G5SW#XXXXX 4 4 4=wQUVVVKS))t34		4 	4s   3A ;BzList[t.Any]_pre_save_hooks_post_save_hooksc                    t          |t                    rt          |          }t          |          sd}t	          |          | j                            |           dS )zRegister a pre save hook.hook must be callableN)rZ   r[   r   r\   RuntimeErrorr{   appendr,   hookra   s      r/   register_pre_save_hookz&ContentsManager.register_pre_save_hook
  s_    dC   	%t$$D~~ 	$)Cs#####D)))))r1   c                    t          |t                    rt          |          }t          |          sd}t	          |          | j                            |           dS )zRegister a post save hook.r~   N)rZ   r[   r   r\   r   r|   r   r   s      r/   register_post_save_hookz'ContentsManager.register_post_save_hook  s_    dC   	%t$$D~~ 	$)Cs###$$T*****r1   c                   | j         | j         gng }|| j        z  }|D ]g}	 | j                            d|            |d||| d| +# t          $ r  t
          $ r& | j                            d|j        |d           Y dw xY wdS )z-Run the pre-save hooks if any, and log errorsNrg   rh   zPre-save hook %s failed on %sTrk   rm   )rS   r{   ro   rp   r   rq   rr   r_   )r,   ri   rC   rs   pre_save_hooksrS   s         r/   run_pre_save_hooksz"ContentsManager.run_pre_save_hooks  s    151C1O$,--UW$..+ 	 	M<dCCCVEtVVvVVVV        3!*!	      	 	s   'A		7BBc                ,   | j         | j         gng }|| j        z  }|D ]u}	 | j                            d|            ||||            -# t          $ r<}| j                            d|j        |d           t          dd|z            |d}~ww xY wdS )	z.Run the post-save hooks if any, and log errorsNrv   rw   zPost-save %s hook failed on %sTrk   ry   z1Unexpected error while running post hook save: %s)rc   r|   ro   rp   rq   rr   r_   r   )r,   ri   rx   post_save_hooksrc   rH   s         r/   run_post_save_hooksz#ContentsManager.run_post_save_hooks2  s    373F3R4.//XZ400- 	e 	eN
e=wGGGwedSSSSS e e e4"+!	      %X[\%\]]cdde		e 	es   )A
B7BBcheckpointsc                &     | j         di | j        S Nrm   checkpoints_classcheckpoints_kwargsrM   s    r/   _default_checkpointsz$ContentsManager._default_checkpointsG      %t%@@(?@@@r1   r   c                    | | j         dS N)r)   ro   ro   rM   s    r/   _default_checkpoints_kwargsz+ContentsManager._default_checkpoints_kwargsK       8
 
 	
r1   av  handler class to use when serving raw file requests.

        Default is a fallback that talks to the ContentsManager API,
        which may be inefficient, especially for large files.

        Local files-based ContentsManagers can use a StaticFileHandler subclass,
        which will be much more efficient.

        Access to these files should be Authenticated.
        )klassrR   r%   r9   zExtra parameters to pass to files_handler_class.

        For example, StaticFileHandlers generally expect a `path` argument
        specifying the root directory from which to serve files.
        c                \    g }| j         r"|                    d| j         | j        f           |S )z[Return additional handlers

        Default: self.files_handler_class on /files/.*
        z/files/(.*))files_handler_classr   files_handler_params)r,   handlerss     r/   get_extra_handlersz"ContentsManager.get_extra_handlersl  s9    
 # 	cOO^T-EtG`abbbr1   c                    t           a:  Does a directory exist at the given path?

        Like os.path.isdir

        Override this method in subclasses.

        Parameters
        ----------
        path : str
            The path to check

        Returns
        -------
        exists : bool
            Whether the path does indeed exist.
        NotImplementedErrorr,   rC   s     r/   r@   zContentsManager.dir_existsy  
    " "!r1   c                    t           a,  Is path a hidden directory or file?

        Parameters
        ----------
        path : str
            The path to check. This is an API path (`/` separated,
            relative to root dir).

        Returns
        -------
        hidden : bool
            Whether the path is hidden.

        r   r   s     r/   	is_hiddenzContentsManager.is_hidden  s
     "!r1   c                    t           a>  Does a file exist at the given path?

        Like os.path.isfile

        Override this method in subclasses.

        Parameters
        ----------
        path : str
            The API path of a file to check for.

        Returns
        -------
        exists : bool
            Whether the file exists.
        r   r   s     r/   file_existszContentsManager.file_exists  r   r1   c                V    |                      |          p|                     |          S )-  Does a file or directory exist at the given path?

        Like os.path.exists

        Parameters
        ----------
        path : str
            The API path of a file or directory to check for.

        Returns
        -------
        exists : bool
            Whether the target exists.
        )r   r@   r   s     r/   existszContentsManager.exists  s)     %%>)>)>>r1   c                    t           zGet a file or directory model.

        Parameters
        ----------
        require_hash : bool
            Whether the file hash must be returned or not.

        *Changed in version 2.11*: The *require_hash* parameter was added.
        r   r,   rC   contenttypeformatrequire_hashs         r/   getzContentsManager.get  s
     "!r1   c                    t           z
        Save a file or directory model to path.

        Should return the saved model with no content.  Save implementations
        should call self.run_pre_save_hook(model=model, path=path) prior to
        writing any data.
        r   r,   ri   rC   s      r/   savezContentsManager.save  s
     "!r1   c                    t           z%Delete the file or directory at path.r   r   s     r/   delete_filezContentsManager.delete_file      !!r1   c                    t           zRename a file or directory.r   r,   old_pathnew_paths      r/   rename_filezContentsManager.rename_file  r   r1   c                    |                     d          }|st          dd          |                     |           | j                            |           |                     d|d           dS )7Delete a file/directory and any associated checkpoints.r7     Can't delete rootdeleteactionrC   r4   Nr=   r   r   r   delete_all_checkpointsr5   r   s     r/   r   zContentsManager.delete  sw    zz# 	6C!4555//555		(D99	:::::r1   c                    |                      ||           | j                            ||           |                     d||d           dS )<Rename a file and any checkpoints associated with that file.renamer   rC   source_pathr   Nr   r   rename_all_checkpointsr5   r   s      r/   r   zContentsManager.rename  sU    8,,,//(CCC		(HXVV	WWWWWr1   c                    |                     d          }|                    d|                               d          }||k    r|                     ||           |                     |d          }|S )Update the file's path

        For use in PATCH requests, to enable renaming a file without
        re-uploading its contents. Only used for renaming at the moment.
        r7   rC   Fr   r=   r   r   r,   ri   rC   r   s       r/   updatezContentsManager.update  sm     zz#99VT**00558KKh'''511r1   c                    dS )z'The information string for the manager.zServing contentsrm   rM   s    r/   info_stringzContentsManager.info_string  s    !!r1   c                    dS )aM  Return the API path for the kernel

        KernelManagers can turn this value into a filesystem path,
        or ignore it altogether.

        The default value here will start kernels in the directory of the
        notebook server. FileContentsManager overrides this to use the
        directory containing the notebook.
        r8   rm   )r,   rC   ri   s      r/   get_kernel_pathzContentsManager.get_kernel_path  s	     rr1   c                2   |                     d          }|                    d          \  }}}|dk    r|                    d          \  }}}||z   }t          j                    D ]0}|r| | nd}	| |	 | }
|                     | d|
           s n1|
S )  Increment a filename until it is unique.

        Parameters
        ----------
        filename : unicode
            The name of a file, including extension
        path : unicode
            The API path of the target's directory
        insert : unicode
            The characters to insert after the base filename

        Returns
        -------
        name : unicode
            A filename that is unique, based on the input filename.
        r7   .ipynbr8   )r=   
rpartition	partition	itertoolscountr   )r,   filenamerC   insertbasenamedotextsuffixiinsert_inames              r/   increment_filenamez"ContentsManager.increment_filename  s    $ zz#%0055#s'>>!)!3!3C!8!8Hc3s"" 	 	A)*2&~!~~~H22&22D;;$////00 r1   c           	     B   	 |-|                     d          }t          |t                    r|nt          |d                    nX# t          $ rK}d                    t          |          t          j        |j        dd                     |d<   Y d}~nd}~ww xY w|S )	z&Add failed-validation message to modelNr	   r   z"Notebook validation failed: {}:
{}r   c                    dS )Nz	<UNKNOWN>rm   )objs    r/   <lambda>z9ContentsManager.validate_notebook_model.<locals>.<lambda>?  s    [ r1   )indentr   message)	r   rZ   r	   validate_nbr   r[   jsondumpsinstance)r,   ri   validation_errorrH   s       r/   validate_notebook_modelz'ContentsManager.validate_notebook_model.  s    	  +$(():;;a11 G E),--- 	 	 	DKKA
1:a9P9PQQQ   E)	
 s   AA 
BABBc                   |                     d          }|                     |          st          dd|z            i }|r||d<   |dk    r|                    dd           n|                    dd           d}|d         d	k    r
| j        }d
}nC|d         dk    r
| j        }d}n-|d         dk    r| j        }nt          dd|d         z            |                     ||z   ||          }| d| }|                     ||          S )Create a new untitled file or directory in path

        path must be a directory

        File extension can be specified.

        Use `new` to create files with a fully specified path (including filename).
        r7     No such directory: %sr   .ipynbnotebookfiler8   	directory r   Unexpected model type: %rr   )	r=   r@   r   
setdefaultuntitled_directoryuntitled_notebookuntitled_filer   new)r,   rC   r   r   ri   r   rQ   r   s           r/   new_untitledzContentsManager.new_untitledC  sE    zz#t$$ 	AC!84!?@@@ 	! E&M(??VZ0000VV,,,=K''.HFF6]j((-HCC6]f$$)HHC!<uV}!LMMM&&x#~tF&KKxxt$$$r1   c                l   |                     d          }|i }|                    d          r|                    dd           n|                    dd           d|vr>|d         dk    r2|d         dk    rt                      |d<   d	|d
<   nd|d<   d|d<   d|d
<   |                     ||          }|S zCreate a new file or directory and return its model with no content.

        To create a new untitled entity in a directory, use `new_untitled`.
        r7   Nr  r   r  r  r   r  r   r   r8   textr=   endswithr  r   r   r   s      r/   r  zContentsManager.newi  s    
 zz#=E=="" 	-VZ0000VV,,, E!!eFm{&B&BV}
**#/>>i "(h#%i  &f"(h		%&&r1   c                "   |                     d          }||                     d          }d|v r|                    dd          \  }}nd}|}|                     |          }|                    dd           |                    dd           |d         dk    rt	          d	d
          |du}|s|}|                     |          r;t                              d|          }|                     ||d          }	| d|	 }n[|rFd|v rA|                    dd          \  }
}	|                     |
          st	          dd|
z            nt	          dd|z            | 	                    ||          }| 
                    d||d           |S a  Copy an existing file and return its new model.

        If to_path not specified, it will be the parent directory of from_path.
        If to_path is a directory, filename will increment `from_path-Copy#.ext`.
        Considering multi-part extensions, the Copy# part will be placed before the first dot for all the extensions except `ipynb`.
        For easier manual searching in case of notebooks, the Copy# part will be placed before the last dot.

        from_path must be a full path to a file.
        r7   Nr   r8   rC   r   r   r  r   zCan't copy directoriesr   z-Copyr  r   z,No such parent directory: %s to copy file inr   copyr   r   )r=   rsplitr   popr   r@   copy_patsubr   r   r5   r,   	from_pathto_pathrC   from_dir	from_nameri   is_destination_specifiedr   to_nameto_dirs              r/   r  zContentsManager.copy  s    s##mmC((G$;;"&++c1"5"5HiiHI		&$		&$=K''C!9:::#*$#6 ' 	G??7## 
	D<<Y//D--dGG-LLG ,,7,,GG% 	Dg~~")..a"8"8v.. b#C)WZ`)`aaaC!87!BCCC		%))		&')TT	UUUr1   c                ^    | j                             |                                            dS )z+Log the information string for the manager.N)ro   infor   rM   s    r/   log_infozContentsManager.log_info  s(    d&&(()))))r1   c                    |                      |          }|d         }| j                            d|           | j                            |d           |                     ||           dS )Explicitly trust a notebook

        Parameters
        ----------
        path : str
            The path of a notebook
        r   Trusting notebook %sTNr   ro   warningrJ   
mark_cellscheck_and_signr,   rC   ri   nbs       r/   trust_notebookzContentsManager.trust_notebook  sj     9/666r4(((B%%%%%r1   c                    | j                             |          r| j                             |           dS | j                            d|           dS )zCheck for trusted cells, and sign the notebook.

        Called as a part of saving notebooks.

        Parameters
        ----------
        nb : dict
            The notebook dict
        path : str
            The notebook's path (for logging)
        Notebook %s is not trustedN)rJ   check_cellsr
   ro   r)  )r,   r-  rC   s      r/   r+  zContentsManager.check_and_sign  sX     ;""2&& 	AKR     H94@@@@@r1   c                    | j                             |          }|s| j                            d|           | j                             ||           dS )a!  Mark cells as trusted if the notebook signature matches.

        Called as a part of loading notebooks.

        Parameters
        ----------
        nb : dict
            The notebook object (in current nbformat)
        path : str
            The notebook's path (for logging)
        r0  N)rJ   check_signaturero   r)  r*  )r,   r-  rC   trusteds       r/   mark_trusted_cellsz"ContentsManager.mark_trusted_cells  sY     +--b11 	AH94@@@r7+++++r1   c                F    t          fd| j        D                        S )z:Should this file/directory name be displayed in a listing?c              3  8   K   | ]}t          |          V  d S Nr   ).0globr   s     r/   	<genexpr>z.ContentsManager.should_list.<locals>.<genexpr>  s-      GGtwtT**GGGGGGr1   )any
hide_globs)r,   r   s    `r/   should_listzContentsManager.should_list  s+    GGGGtGGGGGGGr1   c                8    | j                             | |          S )Create a checkpoint.r   create_checkpointr   s     r/   rB  z!ContentsManager.create_checkpoint  s    11$===r1   c                >    | j                             | ||           dS z'
        Restore a checkpoint.
        Nr   restore_checkpointr,   checkpoint_idrC   s      r/   rF  z"ContentsManager.restore_checkpoint  s%     	++D-FFFFFr1   c                6    | j                             |          S r8  r   list_checkpointsr   s     r/   rK  z ContentsManager.list_checkpoints  s    00666r1   c                8    | j                             ||          S r8  r   delete_checkpointrG  s      r/   rN  z!ContentsManager.delete_checkpoint  s    11-FFFr1   r8   TNNFr8  r8   r8   r8   r8   r8   Nr8   )Tr_   
__module____qualname____doc__r   r6   r   r   tagr&   r   r0   r5   r   rE   r   r:   r   rI   r   allow_hiddenr
   rL   rJ   rN   r   r=  r
  r  r	  r   rS   rb   rc   re   rt   rz   r{   __annotations__r|   r   r   r   r   r   r!   r   r   r   r   r   r   r   r   r   r   r   r@   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r$  r.  r+  r5  r>  rB  rF  rK  rN  rm   r1   r/   r#   r#   -   s         $ 02HHO8K((,,D,99LW^  J J J ws4(((HG
Uz
 
  M Xo  * 4d1OPPPLXd)**FWX0 0 0 			
 	
 	
   J  jC   G4&X  M !E   C	  M. Xo   S	  N* X   R R R(4 4 4  $(466O))))$(DFF***** * *+ + +  ,e e e" [666(;t444KT***W]A A A W!""
 
 #"
 $	  "  4    " " "&" " """ " " "&? ? ?"
" 
" 
" 
"" " "" " "" " "; ; ;X X X  " " "
 
 
 
   @   *$% $% $% $%L   6, , , ,\* * *& & &A A A A", , , ,"H H H
> > >G G G7 7 7G G G G Gr1   r#   c                  2   e Zd ZdZ eed          Z eed          Z e	d          Z
 ed          d             Z ed          d             Zd Zd	 ZddZd Zd dZd Zd Zd Zd Zd Zd Zd!dZd"dZd#dZd$dZd Zd Zd Zd Z d Z!dS )%AsyncContentsManagerz<Base class for serving files and directories asynchronously.Tr$   r   c                &     | j         di | j        S r   r   rM   s    r/   r   z)AsyncContentsManager._default_checkpoints  r   r1   r   c                    | | j         dS r   r   rM   s    r/   r   z0AsyncContentsManager._default_checkpoints_kwargs  r   r1   c                   K   t           r   r   r   s     r/   r@   zAsyncContentsManager.dir_exists        " "!r1   c                   K   t           r   r   r   s     r/   r   zAsyncContentsManager.is_hidden$  s       "!r1   r8   c                   K   t           r   r   r   s     r/   r   z AsyncContentsManager.file_exists5  r_  r1   c                   K   t          |                     |                     d{V p't          |                     |                     d{V S )r   N)r   r   r@   r   s     r/   r   zAsyncContentsManager.existsH  sx       "$"2"24"8"899999999 
<OOD!!D
 D
 >
 >
 >
 >
 >
 >
 	
r1   NFc                   K   t           r   r   r   s         r/   r   zAsyncContentsManager.get[  s       "!r1   c                   K   t           r   r   r   s      r/   r   zAsyncContentsManager.saveg  s       "!r1   c                   K   t           r   r   r   s     r/   r   z AsyncContentsManager.delete_fileq        !!r1   c                   K   t           r   r   r   s      r/   r   z AsyncContentsManager.rename_fileu  rf  r1   c                   K   |                     d          }|st          dd          |                     |           d{V  | j                            |           d{V  |                     d|d           dS )r   r7   r   r   Nr   r   r   r   r   s     r/   r   zAsyncContentsManager.delete|  s      zz# 	6C!4555t$$$$$$$$$55d;;;;;;;;;		(D99	:::::r1   c                   K   |                      ||           d{V  | j                            ||           d{V  |                     d||d           dS )r   Nr   r   r   r   r   s      r/   r   zAsyncContentsManager.rename  s}      x22222222255hIIIIIIIII		(HXVV	WWWWWr1   c                  K   |                     d          }|                    d|                               d          }||k    r|                     ||           d{V  |                     |d           d{V }|S )r   r7   rC   NFr   r   r   s       r/   r   zAsyncContentsManager.update  s       zz#99VT**00558++dH---------hhxh77777777r1   c                `  K   |                     d          }|                    d          \  }}}|dk    r|                    d          \  }}}||z   }t          j                    D ]E}|r| | nd}	| |	 | }
t          |                     | d|
                      d{V }|s nF|
S )r   r7   r   r   r8   N)r=   r   r   r   r   r   r   )r,   r   rC   r   r   r   r   r   r   r   r   r   s               r/   r   z'AsyncContentsManager.increment_filename  s      $ zz#%0055#s'>>!)!3!3C!8!8Hc3s"" 	 	A)*2&~!~~~H22&22D ,T[[D9I9I49I9I-J-J K KKKKKKKK r1   c                `  K   |                     d          }t          |                     |                     d{V }|st          dd|z            i }|r||d<   |dk    r|                    dd           n|                    dd           d	}|d         d
k    r
| j        }d}nC|d         dk    r
| j        }d}n-|d         dk    r| j        }nt          dd|d         z            |                     ||z   ||           d{V }| d| }| 	                    ||           d{V S )r   r7   Nr   r   r   r  r  r  r8   r  r  r   r  r  )
r=   r   r@   r   r  r	  r
  r  r   r  )	r,   rC   r   r   r@   ri   r   rQ   r   s	            r/   r  z!AsyncContentsManager.new_untitled  s      zz#'(=(=>>>>>>>>
 	AC!84!?@@@ 	! E&M(??VZ0000VV,,,=K''.HFF6]j((-HCC6]f$$)HHC!<uV}!LMMM,,X^T&,QQQQQQQQXXeT*********r1   c                |  K   |                     d          }|i }|                    d          r|                    dd           n|                    dd           d|vr>|d         dk    r2|d         dk    rt                      |d<   d	|d
<   nd|d<   d|d<   d|d
<   |                     ||           d{V }|S r  r  r   s      r/   r  zAsyncContentsManager.new  s      
 zz#=E=="" 	-VZ0000VV,,, E!!eFm{&B&BV}
**#/>>i "(h#%i  &f"(hiit,,,,,,,,r1   c                  K   |                     d          }||                     d          }d|v r|                    dd          \  }}nd}|}|                     |           d{V }|                    dd           |                    dd           |d         dk    rt	          d	d
          |du}|s|}t          |                     |                     d{V rAt                              d|          }| 	                    ||d           d{V }	| d|	 }nn|rYd|v rT|                    dd          \  }
}	t          |                     |
                     d{V st	          dd|
z            nt	          dd|z            | 
                    ||           d{V }|                     d||d           |S r  )r=   r  r   r  r   r   r@   r  r  r   r   r5   r  s              r/   r  zAsyncContentsManager.copy  s/      s##mmC((G$;;"&++c1"5"5HiiHIhhtnn$$$$$$		&$		&$=K''C!9:::#*$#6 ' 	Gdoog6677777777 
	D<<Y//D 33D''3RRRRRRRRG ,,7,,GG% 	Dg~~")..a"8"8)$//&*A*ABBBBBBBB b#C)WZ`)`aaaC!87!BCCCiiw////////		&')TT	UUUr1   c                   K   |                      |           d{V }|d         }| j                            d|           | j                            |d           |                     ||           dS )r&  Nr   r'  Tr(  r,  s       r/   r.  z#AsyncContentsManager.trust_notebook*  s       hhtnn$$$$$$9/666r4(((B%%%%%r1   c                H   K   | j                             | |           d{V S )r@  NrA  r   s     r/   rB  z&AsyncContentsManager.create_checkpoint9  s1      %77dCCCCCCCCCr1   c                N   K   | j                             | ||           d{V  dS rD  rE  rG  s      r/   rF  z'AsyncContentsManager.restore_checkpoint=  s;       11$tLLLLLLLLLLLr1   c                F   K   | j                             |           d{V S )z List the checkpoints for a path.NrJ  r   s     r/   rK  z%AsyncContentsManager.list_checkpointsC  s/      %66t<<<<<<<<<r1   c                H   K   | j                             ||           d{V S )z%Delete a checkpoint for a path by id.NrM  rG  s      r/   rN  z&AsyncContentsManager.delete_checkpointG  s1      %77tLLLLLLLLLr1   rO  rP  rQ  rR  rS  r8  )"r_   rT  rU  rV  r   r    r   r   r   r   r   r   r   r   r@   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r.  rB  rF  rK  rN  rm   r1   r/   r[  r[    s       FF-d;;;(+D999KT***W]A A A W!""
 
 #"
" " "&" " """ " " "&
 
 
&
" 
" 
" 
"" " "" " "" " "; ; ;X X X     B%+ %+ %+ %+N   6, , , ,\& & &D D DM M M= = =M M M M Mr1   r[  )6rV  
__future__r   r   r   rB   retypingtr]   r   jupyter_core.utilsr   r   jupyter_eventsr   nbformatr	   r
   r   r   nbformat.v4r   tornado.webr   r   	traitletsr   r   r   r   r   r   r   r   r   traitlets.config.configurabler   jupyter_serverr   r   jupyter_server.transutilsr   jupyter_server.utilsr   files.handlersr   r   r    r!   compiler  r#   r[  rm   r1   r/   <module>r     sr   ) ) # " " " " "      				 				            5 5 5 5 5 5 5 5 & & & & & & * * * * * * * * , , , , , , $ $ $ $ $ $ 1 1 1 1 1 1 1 1                        > = = = = = P P P P P P P P + + + + + + , , , , , , * * * * * * 6 6 6 6 6 6 6 62:n%%LG LG LG LG LG) LG LG LG^MM MM MM MM MM? MM MM MM MM MMr1   