Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warning when importing jupyter_server.transutils._ #47

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions nbclassic/notebook/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
url_escape,
ensure_async
)
from jupyter_server.transutils import _
from jupyter_server.transutils import _i18n


def get_frontend_exporters():
Expand Down Expand Up @@ -52,7 +52,7 @@ def get_frontend_exporters():

# Ensure export_from_notebook is explicitly defined & not inherited
if ux_name is not None and ux_name != super_uxname:
display = _('{} ({})'.format(ux_name,
display = _i18n('{} ({})'.format(ux_name,
exporter_instance.file_extension))
frontend_exporters.append(ExporterInfo(name, display))

Expand Down Expand Up @@ -117,4 +117,3 @@ def get(self, path):
default_handlers = [
(r"/notebooks%s" % path_regex, NotebookHandler),
]

18 changes: 9 additions & 9 deletions nbclassic/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
)

from jupyter_server.log import log_request
from jupyter_server.transutils import _
from jupyter_server.transutils import _i18n
from jupyter_server.serverapp import (
ServerApp,
random_ports,
Expand Down Expand Up @@ -71,7 +71,7 @@
aliases = {}
flags['no-browser']=(
{'ServerApp' : {'open_browser' : False}},
_("Don't open the notebook in a browser after startup.")
_i18n("Don't open the notebook in a browser after startup.")
)
flags['no-mathjax']=(
{'NotebookApp' : {'enable_mathjax' : False}},
Expand All @@ -87,7 +87,7 @@

flags['allow-root']=(
{'ServerApp' : {'allow_root' : True}},
_("Allow the notebook to be run from root user.")
_i18n("Allow the notebook to be run from root user.")
)

aliases.update({
Expand Down Expand Up @@ -120,7 +120,7 @@ class NotebookApp(

name = 'notebook'
version = __version__
description = _("""The Jupyter HTML Notebook.
description = _i18n("""The Jupyter HTML Notebook.

This launches a Tornado based HTML Notebook Server that serves up an HTML5/Javascript Notebook client.""")

Expand All @@ -144,7 +144,7 @@ class NotebookApp(
).tag(config=True)

static_custom_path = List(Unicode(),
help=_("""Path to search for custom.js, css""")
help=_i18n("""Path to search for custom.js, css""")
)

@default('static_custom_path')
Expand All @@ -156,7 +156,7 @@ def _default_static_custom_path(self):
]

extra_nbextensions_path = List(Unicode(), config=True,
help=_("""extra paths to look for Javascript notebook extensions""")
help=_i18n("""extra paths to look for Javascript notebook extensions""")
)

@property
Expand Down Expand Up @@ -194,9 +194,9 @@ def _prepare_templates(self):
def initialize_settings(self):
"""Add settings to the tornado app."""
if self.ignore_minified_js:
self.log.warning(_("""The `ignore_minified_js` flag is deprecated and no longer works."""))
self.log.warning(_("""Alternatively use `%s` when working on the notebook's Javascript and LESS""") % 'npm run build:watch')
warnings.warn(_("The `ignore_minified_js` flag is deprecated and will be removed in Notebook 6.0"), DeprecationWarning)
self.log.warning(_i18n("""The `ignore_minified_js` flag is deprecated and no longer works."""))
self.log.warning(_i18n("""Alternatively use `%s` when working on the notebook's Javascript and LESS""") % 'npm run build:watch')
warnings.warn(_i18n("The `ignore_minified_js` flag is deprecated and will be removed in Notebook 6.0"), DeprecationWarning)

settings = dict(
static_custom_path=self.static_custom_path,
Expand Down
24 changes: 12 additions & 12 deletions nbclassic/traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@
__version__,
)
from jupyter_core.paths import jupyter_path
from jupyter_server.transutils import _
from jupyter_server.transutils import _i18n
from jupyter_server.utils import url_path_join


class NotebookAppTraits(HasTraits):

ignore_minified_js = Bool(False,
config=True,
help=_('Deprecated: Use minified JS file or not, mainly use during dev to avoid JS recompilation'),
help=_i18n('Deprecated: Use minified JS file or not, mainly use during dev to avoid JS recompilation'),
)


jinja_environment_options = Dict(config=True,
help=_("Supply extra arguments that will be passed to Jinja environment."))
help=_i18n("Supply extra arguments that will be passed to Jinja environment."))

jinja_template_vars = Dict(
config=True,
help=_("Extra variables to supply to jinja templates when rendering."),
help=_i18n("Extra variables to supply to jinja templates when rendering."),
)

enable_mathjax = Bool(True, config=True,
Expand Down Expand Up @@ -59,7 +59,7 @@ def static_file_path(self):
return self.extra_static_paths + [DEFAULT_STATIC_FILES_PATH]

static_custom_path = List(Unicode(),
help=_("""Path to search for custom.js, css""")
help=_i18n("""Path to search for custom.js, css""")
)

@default('static_custom_path')
Expand All @@ -71,7 +71,7 @@ def _default_static_custom_path(self):
]

extra_template_paths = List(Unicode(), config=True,
help=_("""Extra paths to search for serving jinja templates.
help=_i18n("""Extra paths to search for serving jinja templates.

Can be used to override templates from notebook.templates.""")
)
Expand All @@ -82,7 +82,7 @@ def template_file_path(self):
return self.extra_template_paths + DEFAULT_TEMPLATE_PATH_LIST

extra_nbextensions_path = List(Unicode(), config=True,
help=_("""extra paths to look for Javascript notebook extensions""")
help=_i18n("""extra paths to look for Javascript notebook extensions""")
)

@property
Expand Down Expand Up @@ -124,24 +124,24 @@ def _update_mathjax_url(self, change):
# enable_mathjax=False overrides mathjax_url
self.mathjax_url = u''
else:
self.log.info(_("Using MathJax: %s"), new)
self.log.info(_i18n("Using MathJax: %s"), new)

mathjax_config = Unicode("TeX-AMS-MML_HTMLorMML-full,Safe", config=True,
help=_("""The MathJax.js configuration file that is to be used.""")
help=_i18n("""The MathJax.js configuration file that is to be used.""")
)

@observe('mathjax_config')
def _update_mathjax_config(self, change):
self.log.info(_("Using MathJax configuration file: %s"), change['new'])
self.log.info(_i18n("Using MathJax configuration file: %s"), change['new'])

quit_button = Bool(True, config=True,
help="""If True, display a button in the dashboard to quit
(shutdown the notebook server)."""
)

nbserver_extensions = Dict({}, config=True,
help=(_("Dict of Python modules to load as notebook server extensions."
help=(_i18n("Dict of Python modules to load as notebook server extensions."
"Entry values can be used to enable and disable the loading of"
"the extensions. The extensions will be loaded in alphabetical "
"order."))
)
)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
python_requires='>=3.6',
include_package_data=True,
install_requires = [
'jupyter_server~=1.4',
'jupyter_server~=1.5',
'notebook<7',
],
entry_points = {
Expand Down