From 66c3bbfa94d8a41e58adf154be25e6d86fee8e30 Mon Sep 17 00:00:00 2001 From: "martial.simon" Date: Sun, 13 Apr 2025 19:54:19 +0200 Subject: init: initial commit --- PVCM/cama/.jupyter/custom/custom.css | 74 ++++++++++++++++++++++++++++++++++++ PVCM/cama/.jupyter/custom/custom.js | 44 +++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 PVCM/cama/.jupyter/custom/custom.css create mode 100644 PVCM/cama/.jupyter/custom/custom.js (limited to 'PVCM/cama/.jupyter/custom') diff --git a/PVCM/cama/.jupyter/custom/custom.css b/PVCM/cama/.jupyter/custom/custom.css new file mode 100644 index 0000000..6034bbd --- /dev/null +++ b/PVCM/cama/.jupyter/custom/custom.css @@ -0,0 +1,74 @@ + + diff --git a/PVCM/cama/.jupyter/custom/custom.js b/PVCM/cama/.jupyter/custom/custom.js new file mode 100644 index 0000000..4b280ad --- /dev/null +++ b/PVCM/cama/.jupyter/custom/custom.js @@ -0,0 +1,44 @@ +import json +import os +import re +import ipykernel +import requests +from notebook.notebookapp import list_running_servers +from urllib.parse import urljoin +from IPython.display import display, Markdown + +def get_notebook_path(): + """ + Return the full path of the jupyter notebook. + """ + session = requests.Session() + session.trust_env = False + kernel_id = re.search('kernel-(.*).json', + ipykernel.connect.get_connection_file()).group(1) + servers = list_running_servers() + if + for ss in servers: + response = session.get(f"{ss['url']}api/sessions", + params={'token': ss['token']}) + for nn in json.loads(response.text): + if nn['kernel']['id'] == kernel_id: + try: + return os.envion['HOME_URL'] + 'notebooks/' + nn['notebook']['path'] + except: + return ss['url'] + 'notebooks/' + nn['notebook']['path'] + +def PreviousNext(url1, url2): + section = get_notebook_path() + section = section.replace('notebooks','tree') + section = section[:section.rfind('/')] + toc = "http://python3.mooc.lrde.epita.fr/notebooks/Table%20des%20mati%C3%A8res.ipynb" + text = 200 * "  " + text += "
" + text += f'{url1[url1.rfind("/")+1:-6]}' +# text += f'  ← →  ' + text += f'  ← →  ' + text += f'{url2[url2.rfind("/")+1:-6]}' + text += '

' + text += ' ' + return text + -- cgit v1.2.3