o
    ir2                     @   s  d Z ddlmZmZ ddlZddlZddlZddlmZ ddl	Z	ddl	m
Z
mZmZ ddlmZ ddlmZmZmZmZ ddlm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! ddl"m#Z# ddl$m%Z% ddl&m'Z' dZ(i Z)i Z*dddiiedfe)d< dddiidfe)d< dddiiedfe)d< e*+d d!d"d#d$d%d&d'd( G d)d de%eee'Z,e,j- Z.Z/dS )*z(A tornado based Jupyter notebook server.    )absolute_importprint_functionN)RedirectHandler)DEFAULT_STATIC_FILES_PATHDEFAULT_TEMPLATE_PATH_LISTnbclassic_path)__version__)UnicodeListBooldefault)jupyter_path)FileFindHandler)url_path_join)ExtensionAppExtensionAppJinjaMixin)_i18n)load_handlers   )TerminalHandler)NotebookConfigShimMixin)NotebookAppTraitsz
jupyter nbclassic                       # start the notebook
jupyter nbclassic --certfile=mycert.pem # use SSL/TLS certificate
jupyter nbclassic password              # enter a password to protect the server
	ServerAppopen_browserFz3Don't open the notebook in a browser after startup.z
no-browserNotebookAppenable_mathjaxa4  Disable MathJax

    MathJax is the javascript library Jupyter uses to render math/LaTeX. It is
    very large, so you may want to disable it if you have a slow internet
    connection, or for offline use of the notebook.

    When disabled, equations etc. will appear as their untransformed TeX source.
    z
no-mathjax
allow_rootTz,Allow the notebook to be run from root user.z
allow-rootzServerApp.ipzServerApp.portzServerApp.port_retrieszServerApp.keyfilezServerApp.certfilezServerApp.client_cazServerApp.notebook_dirzServerApp.browser)ipportzport-retrieskeyfilecertfilez	client-caznotebook-dirbrowserc                       s   e Zd ZdZeZedZeZe	Z	dZ
i Zede  jddZedddjddZed	dd
dZee eddZeddd Zee deddZedd Zedd Zedd Z fddZ fddZdd Zdd Z  Z S )r   	nbclassiczThe Jupyter HTML Notebook.

    This launches a Tornado based HTML Notebook Server that serves up an HTML5/Javascript Notebook client.z/treez%s/treeT)configa  Whether to open in a browser after starting.
        The specific browser used is platform dependent and
        determined by the python standard library `webbrowser`
        module, unless it is overridden using the --browser
        (ServerApp.browser) configuration option.
        )helpjupyter_notebook_configzSpecify a config file to load.)r#   r$   z!Path to search for custom.js, cssstatic_custom_pathc                 C   s   dd | j tfD S )Nc                 S   s   g | ]	}t j|d qS )custom)ospathjoin).0d r-   P/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/nbclassic/notebookapp.py
<listcomp>   s    z;NotebookApp._default_static_custom_path.<locals>.<listcomp>)
config_dirr   selfr-   r-   r.   _default_static_custom_path   s
   z'NotebookApp._default_static_custom_pathz6extra paths to look for Javascript notebook extensionsc                 C   s   | j td }|S )z3The path to look for Javascript notebook extensionsnbextensions)extra_nbextensions_pathr   )r2   r)   r-   r-   r.   nbextensions_path   s   zNotebookApp.nbextensions_pathc                 C   s   | j tg S )zRename trait in jupyter_server.)extra_static_pathsr   r1   r-   r-   r.   static_paths   s   zNotebookApp.static_pathsc                 C   s
   | j t S )z Rename trait for Jupyter Server.)extra_template_pathsr   r1   r-   r-   r.   template_paths   s   
zNotebookApp.template_pathsc                    sZ   t t|   tjtj}tj	dtj
|ddd}| jj|dd | jjjtd d S )Nnbuiznbclassic/i18nT)	localedirfallbackF)newstyle)r   )superr   _prepare_templatesr(   r)   dirnamer"   __file__gettexttranslationr*   
jinja2_envinstall_gettext_translationsglobalsupdater   )r2   base_dirr;   	__class__r-   r.   r@      s   zNotebookApp._prepare_templatesc                    s4   dd }t ||j_dd }t || j_t |S )Nc                 S   s   | j tjtjg S ))return extra paths + the default location)r7   jupyter_serverr   r"   r1   r-   r-   r.   static_file_path_jupyter_server   s   zSNotebookApp._link_jupyter_server_extension.<locals>.static_file_path_jupyter_serverc                 S   s   | j tjtjdtjg S )rL   notebook)r7   r(   r)   r*   r"   r   r1   r-   r-   r.   static_file_path_nbclassic   s   
zNNotebookApp._link_jupyter_server_extension.<locals>.static_file_path_nbclassic)propertyrK   static_file_pathr?   _link_jupyter_server_extension)r2   	serverapprN   rP   rJ   r-   r.   rS      s   z*NotebookApp._link_jupyter_server_extensionc                 C   s   | j r| jtd | jtdd  ttdt t| jdt	| j
jd| jdgi| j | j| j| jd}| jjd
i | d	S )z Add settings to the tornado app.z@The `ignore_minified_js` flag is deprecated and no longer works.zIAlternatively use `%s` when working on the notebook's Javascript and LESSznpm run build:watchzOThe `ignore_minified_js` flag is deprecated and will be removed in Notebook 6.0no_cache_pathsstaticr'   )r&   static_handler_argsignore_minified_jsmathjax_urlmathjax_configr6   Nr-   )rX   logwarningr   warningswarnDeprecationWarningdictr&   r   rT   base_urlnamerY   rZ   r6   settingsrH   )r2   rc   r-   r-   r.   initialize_settings   s>   zNotebookApp.initialize_settingsc                 C   s  g }| d| j dtd| jjd if tt dkr*| dtd| jjd if | jd D ]	}|t	| q/|t	d	 |t	d
 |t	d | j
| g }| jj}t}| ||dtd| jif | ||dt| jd dgdf | ||dt| jd dgdf t	d}t|d }| jjj}|jd|  }	|j| d }
g |_||	 || ||
 td dS )z:Load the (URL pattern, handler) tuples for each component./z/((?!.*\.ipynb($|\?)).*)urlz	files/{0}r   z
/nbclassicznbclassic/treeextra_servicesznbclassic.tree.handlersznbclassic.notebook.handlersznbclassic.edit.handlersz/terminals/(\w+)rb   z/nbextensions/(.*)r6   )r)   rU   z/custom/(.*)r&   zjupyter_server.base.handlers   Na  
  _   _          _      _
 | | | |_ __  __| |__ _| |_ ___
 | |_| | '_ \/ _` / _` |  _/ -_)
  \___/| .__/\__,_\__,_|\__\___|
       |_|
                                                                           
Read the migration plan to Notebook 7 to learn about the new features and the actions to take if you are using extensions.

https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html

Please note that updating to Notebook 7 might break some of your extensions.
)appendfile_url_prefixr   rT   ra   lenr   rc   extendr   handlersr   r   rb   r   web_appwildcard_routerrules	add_rulesprint)r2   rm   servicestatic_handlersra   ujoinbase_handlersnrouter
core_rulesfinal_rulesr-   r-   r.   initialize_handlers   s`   		






zNotebookApp.initialize_handlers)!__name__
__module____qualname__rb   r   versionr   descriptionaliasesflagsextension_urlsubcommandsr	   r   tagdefault_urlr   r   config_file_namer
   r&   r   r3   r5   rQ   r6   r8   r:   r@   rS   rd   r{   __classcell__r-   r-   rJ   r.   r   g   sT    



)0__doc__
__future__r   r   r(   rC   r]   tornado.webr   r"   r   r   r   nbclassic._versionr   	traitletsr	   r
   r   r   jupyter_core.pathsr   rM   jupyter_server.base.handlersr   jupyter_server.utilsr   $jupyter_server.extension.applicationr   r   jupyter_server.transutilsr   jupyter_server.serverappr   terminal.handlersr   notebook_shim.shimr   notebook_shim.traitsr   	_examplesr   r   rH   r   launch_instancemainlaunch_new_instancer-   r-   r-   r.   <module>   sd   




 v