Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getnikola/nikola
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 320a9c80b622
Choose a base ref
...
head repository: getnikola/nikola
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9e6a94b0e3bb
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Mar 4, 2017

  1. lint

    ralsina committed Mar 4, 2017
    Copy the full SHA
    f4b7aa0 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    3de19ba View commit details
  3. paperwork

    ralsina committed Mar 4, 2017
    Copy the full SHA
    9e6a94b View commit details
Showing with 31 additions and 27 deletions.
  1. +1 −0 AUTHORS.txt
  2. +1 −0 CHANGES.txt
  3. +29 −1 nikola/plugins/compile/ipynb.py
  4. +0 −26 nikola/utils.py
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -104,6 +104,7 @@
* `Sean Pue <https://github.com/seanpue>`_
* `Simon van der Veldt <https://github.com/simonvanderveldt>`_
* `Stefan Näwe <https://github.com/snaewe>`_
* `Stephan Fitzpatrick <https://github.com/knowsuchagency>`_
* `Sukil Etxenike <https://github.com/sukiletxe>`_
* `Thibauld Nion <https://github.com/tibonihoo>`_
* `Thomas Burette <https://github.com/tburette>`_
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ New in master
Features
--------

* Add Jupyter config as dependency for jupyter posts (by @knowsuchagency)
* Add ``RSS_COPYRIGHT``, ``RSS_COPYRIGHT_PLAIN``, and
``RSS_COPYRIGHT_FORMATS`` options in conf.py which can be disabled
by specifying ``copyright_=False`` to ``generic_rss_renderer``, or
30 changes: 29 additions & 1 deletion nikola/plugins/compile/ipynb.py
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@

from __future__ import unicode_literals, print_function
import io
import json
import os
import sys

@@ -61,7 +62,7 @@
ipy_modern = None

from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing, get_logger, STDERR_HANDLER, get_default_jupyter_config
from nikola.utils import makedirs, req_missing, get_logger, STDERR_HANDLER


class CompileIPynb(PageCompiler):
@@ -191,3 +192,30 @@ def create_post(self, path, **kw):
nbformat.write(nb, fd, 4)
else:
nbformat.write(nb, fd, 'ipynb')


def get_default_jupyter_config():
"""
Search default jupyter configuration location paths
and return dictionary from configuration json files.
"""
config = {}
try:
from jupyter_core.paths import jupyter_config_path
except ImportError:
# jupyter not installed, must be using IPython
return config

for parent in jupyter_config_path():
try:
for file in os.listdir(parent):
if 'nbconvert' in file and file.endswith('.json'):
abs_path = os.path.join(parent, file)
with open(abs_path) as config_file:
config.update(json.load(config_file))
except FileNotFoundError:
# some paths jupyter uses to find configurations
# may not exist
pass

return config
26 changes: 0 additions & 26 deletions nikola/utils.py
Original file line number Diff line number Diff line change
@@ -2040,29 +2040,3 @@ def html_unescape(s):
"""Convert all named and numeric character references in the string s to the corresponding unicode characters."""
h = HTMLParser()
return h.unescape(s)

def get_default_jupyter_config():
"""
Search default jupyter configuration location paths
and return dictionary from configuration json files.
"""
config = {}
try:
from jupyter_core.paths import jupyter_config_path
except ImportError:
# jupyter not installed, must be using IPython
return config

for parent in jupyter_config_path():
try:
for file in os.listdir(parent):
if 'nbconvert' in file and file.endswith('.json'):
abs_path = os.path.join(parent, file)
with open(abs_path) as config_file:
config.update(json.load(config_file))
except FileNotFoundError:
# some paths jupyter uses to find configurations
# may not exist
pass

return config