From cea39a6193c6e8451afa607e70231485216f7d18 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Tue, 5 Sep 2017 13:30:16 +0100 Subject: [PATCH 1/3] utils/types: Add file_path type This can be used to allow extension parameters that are paths to use '~' to refer to the home directory. --- wlauto/utils/types.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wlauto/utils/types.py b/wlauto/utils/types.py index 725b22d8..c3fd571a 100644 --- a/wlauto/utils/types.py +++ b/wlauto/utils/types.py @@ -83,6 +83,9 @@ def numeric(value): return ivalue return fvalue +def file_path(value): + """Handles expansion of paths containing '~'""" + return os.path.expanduser(value) def list_of_strs(value): """ From 64426601febdafb715f91aef735dfbe1d777954c Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Tue, 5 Sep 2017 13:31:15 +0100 Subject: [PATCH 2/3] ipynb_exporter: Use file_path to allow '~' in path parameters --- wlauto/result_processors/ipynb_exporter/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wlauto/result_processors/ipynb_exporter/__init__.py b/wlauto/result_processors/ipynb_exporter/__init__.py index 6689b3e3..e03f4377 100644 --- a/wlauto/result_processors/ipynb_exporter/__init__.py +++ b/wlauto/result_processors/ipynb_exporter/__init__.py @@ -29,6 +29,7 @@ from wlauto import File, Parameter, ResultProcessor from wlauto.exceptions import ConfigError, ResultProcessorError import wlauto.utils.ipython as ipython from wlauto.utils.misc import open_file +from wlauto.utils.types import file_path DEFAULT_NOTEBOOK_TEMPLATE = 'template.ipynb' @@ -59,6 +60,7 @@ class IPythonNotebookExporter(ResultProcessor): parameters = [ Parameter('notebook_template', default=DEFAULT_NOTEBOOK_TEMPLATE, + kind=file_path, description='''Filename of the ipython notebook template. If no `notebook_template` is specified, the example template above is used.'''), @@ -72,7 +74,7 @@ class IPythonNotebookExporter(ResultProcessor): ending in ``.pdf``.'''), Parameter('show_notebook', kind=bool, description='Open a web browser with the resulting notebook.'), - Parameter('notebook_directory', + Parameter('notebook_directory', kind=file_path, description='''Path to the notebooks directory served by the ipython notebook server. You must set it if ``show_notebook`` is selected. The ipython notebook From 6266edad6f379446776a26af928868e92a86381d Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Tue, 5 Sep 2017 13:31:56 +0100 Subject: [PATCH 3/3] ipython: Add support for IPython 5 This does not seem to require any change beyond incrementing the recognised version number. --- wlauto/utils/ipython.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wlauto/utils/ipython.py b/wlauto/utils/ipython.py index c1439f40..3f13fe12 100644 --- a/wlauto/utils/ipython.py +++ b/wlauto/utils/ipython.py @@ -36,7 +36,7 @@ NBFORMAT_VERSION = 3 if IPython: - if LooseVersion('5.0.0') > LooseVersion(IPython.__version__) >= LooseVersion('4.0.0'): + if LooseVersion('6.0.0') > LooseVersion(IPython.__version__) >= LooseVersion('4.0.0'): import nbformat from jupyter_client.manager import KernelManager