base.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """
  2. Contains writer base class.
  3. """
  4. # Copyright (c) Jupyter Development Team.
  5. # Distributed under the terms of the Modified BSD License.
  6. from __future__ import annotations
  7. from traitlets import List, Unicode
  8. from nbconvert.utils.base import NbConvertBase
  9. class WriterBase(NbConvertBase):
  10. """Consumes output from nbconvert export...() methods and writes to a
  11. useful location."""
  12. files = List(
  13. Unicode(),
  14. help="""
  15. List of the files that the notebook references. Files will be
  16. included with written output.""",
  17. ).tag(config=True)
  18. def __init__(self, config=None, **kw):
  19. """
  20. Constructor
  21. """
  22. super().__init__(config=config, **kw)
  23. def write(self, output, resources, **kw):
  24. """
  25. Consume and write Jinja output.
  26. Parameters
  27. ----------
  28. output : string
  29. Conversion results. This string contains the file contents of the
  30. converted file.
  31. resources : dict
  32. Resources created and filled by the nbconvert conversion process.
  33. Includes output from preprocessors, such as the extract figure
  34. preprocessor.
  35. """
  36. raise NotImplementedError()