ipypublish.postprocessors.base module

class ipypublish.postprocessors.base.IPyPostProcessor(*args, **kwargs)[source]

Bases: traitlets.config.configurable.Configurable

an abstract class for post-processors

property allowed_mimetypes

override in subclasses

return a list of allowed mime types if None, then all are allowed

Text based mime-types include: text/plain, text/latex, text/restructuredtext, text/html, text/x-python, application/json, text/markdown, text/asciidoc, text/yaml

check_exe_exists(name, error_msg)[source]

test if an executable exists

handle_error(msg, err_type, raise_msg=None, log_msg=None)[source]

handle error by logging it then raising

property logger
property logger_name

override in subclass

postprocess(stream, mimetype, filepath, resources=None)[source]

Post-process output.

Parameters
  • stream (str) – the main file contents

  • mimetype (str) – the mimetype of the file

  • filepath (None or str or pathlib.Path) – the path to the output file the path does not have to exist, but must be absolute

  • resources (None or dict) – a resources dict, output from exporter.from_notebook_node

Returns

property requires_path

override in subclasses

whether the prostprocessor requires the supplied filepath to have an existing parent directory

if True and filepath is None, will raise an IOError, otherwise, will try to make the directory if it doesn’t exist

run_postprocess(stream, mimetype, filepath, resources)[source]

should not be called directly override in sub-class

Parameters
  • stream (str) – the main file contents

  • filepath (None or pathlib.Path) – the path to the output file

  • resources (dict) – a resources dict, output from exporter.from_notebook_node

Returns

skip_mime

A boolean (True, False) trait.