PK J(Kz z nbopen/__init__.py"""Open a notebook from the command line in the best available server"""
__version__ = '0.4.3'
from .nbopen import main
PK "nI}
2 nbopen/__main__.pyfrom .nbopen import main
main()
PK nIqw
# nbopen/application-x-ipynb+json.xml
IPython notebook
PK nIi97 nbopen/install_win.py"""Install GUI integration on Windows"""
import sys
try:
import winreg
except ImportError:
import _winreg as winreg
SZ = winreg.REG_SZ
with winreg.CreateKey(winreg.HKEY_CURRENT_USER, "Software\Classes\.ipynb") as k:
winreg.SetValue(k, "", SZ, "Jupyter.nbopen")
winreg.SetValueEx(k, "Content Type", 0, SZ, "application/x-ipynb+json")
winreg.SetValueEx(k, "PerceivedType", 0, SZ, "document")
with winreg.CreateKey(k, "OpenWithProgIds") as openwith:
winreg.SetValueEx(openwith, "Jupyter.nbopen", 0, winreg.REG_NONE, b'')
executable = sys.executable
if executable.endswith("python.exe"):
executable = executable[:-10] + 'pythonw.exe'
launch_cmd = '"{}" -m nbopen "%1"'.format(executable)
with winreg.CreateKey(winreg.HKEY_CURRENT_USER, "Software\Classes\Jupyter.nbopen") as k:
winreg.SetValue(k, "", SZ, "IPython notebook")
with winreg.CreateKey(k, "shell\open\command") as launchk:
winreg.SetValue(launchk, "", SZ, launch_cmd)
try:
from win32com.shell import shell, shellcon
shell.SHChangeNotify(shellcon.SHCNE_ASSOCCHANGED, shellcon.SHCNF_IDLIST, None, None)
except ImportError:
print("You may need to restart for association with .ipynb files to work")
print(" (pywin32 is needed to notify Windows of the change)")
PK nI[W W nbopen/install_xdg.py"""Install GUI integration on XDG platforms (primarily Linux)"""
import os
from pathlib import Path
import shutil
from subprocess import run
_PKGDIR = Path(__file__).resolve().parent
if not os.environ.get('XDG_DATA_HOME'):
os.environ['XDG_DATA_HOME'] = os.path.expanduser('~/.local/share')
print("Installing data files to:", os.environ['XDG_DATA_HOME'])
#export XDG_UTILS_DEBUG_LEVEL=1 #DEBUG
print('Installing mimetype data...')
run(['xdg-mime', 'install', str(_PKGDIR / 'application-x-ipynb+json.xml')],
check=True)
print('Installing icons...')
for s in [16, 24, 32, 48, 64, 128, 256, 512]:
src = _PKGDIR / "icons/ipynb_icon_{s}x{s}.png".format(s=s)
run(['xdg-icon-resource', 'install', '--noupdate', '--size', str(s),
'--context', 'mimetypes', str(src), 'application-x-ipynb+json'],
check=True)
run(['xdg-icon-resource', 'forceupdate'], check=True)
print('Installing desktop file...')
apps_dir = os.path.join(os.environ['XDG_DATA_HOME'], "applications/")
shutil.copy2(str(_PKGDIR / 'nbopen.desktop'), apps_dir)
run(['update-desktop-database', apps_dir], check=True)
PK nIL nbopen/nbopen.desktop[Desktop Entry]
Type=Application
Version=1.0
Name=IPython Notebook
# This is for opening files, not launching the notebook from a menu
NoDisplay=true
Exec=nbopen %f
Terminal=false
MimeType=application/x-ipynb+json;
PK J(K