diff options
| author | 2014-06-13 21:51:02 -0300 | |
|---|---|---|
| committer | 2014-06-13 21:51:02 -0300 | |
| commit | 58c4878526dec5510f23c812274686787d8724ba (patch) | |
| tree | 5f2374bc17adb10e15f7e5b4576595d9cc2ef17e /nikola/plugins/compile/ipynb/__init__.py | |
| parent | fa50632a9d87c3989566fed3e49c160a132e0d14 (diff) | |
Imported Upstream version 7.0.1upstream/7.0.1
Diffstat (limited to 'nikola/plugins/compile/ipynb/__init__.py')
| -rw-r--r-- | nikola/plugins/compile/ipynb/__init__.py | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/nikola/plugins/compile/ipynb/__init__.py b/nikola/plugins/compile/ipynb/__init__.py index 2b1fd28..f4d554c 100644 --- a/nikola/plugins/compile/ipynb/__init__.py +++ b/nikola/plugins/compile/ipynb/__init__.py @@ -41,16 +41,12 @@ except ImportError: from nikola.plugin_categories import PageCompiler from nikola.utils import makedirs, req_missing -try: - from collections import OrderedDict -except ImportError: - OrderedDict = dict # NOQA - class CompileIPynb(PageCompiler): """Compile IPynb into HTML.""" name = "ipynb" + supports_onefile = False def compile_html(self, source, dest, is_two_file=True): if flag is None: @@ -66,19 +62,15 @@ class CompileIPynb(PageCompiler): (body, resources) = exportHtml.from_notebook_node(nb_json) out_file.write(body) - def create_post(self, path, onefile=False, is_page=False, **kw): - metadata = OrderedDict() - metadata.update(self.default_metadata) - metadata.update(kw) - d_name = os.path.dirname(path) + def create_post(self, path, **kw): + # content and onefile are ignored by ipynb. + kw.pop('content', None) + onefile = kw.pop('onefile', False) + kw.pop('is_page', False) + makedirs(os.path.dirname(path)) - meta_path = os.path.join(d_name, kw['slug'] + ".meta") - with codecs.open(meta_path, "wb+", "utf8") as fd: - fd.write('\n'.join((metadata['title'], metadata['slug'], - metadata['date'], metadata['tags'], - metadata['link'], - metadata['description'], metadata['type']))) - print("Your {0}'s metadata is at: {1}".format('page' if is_page else 'post', meta_path)) + if onefile: + raise Exception('The one-file format is not supported by this compiler.') with codecs.open(path, "wb+", "utf8") as fd: fd.write("""{ "metadata": { |
