debug.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """
  2. Contains debug writer.
  3. """
  4. from __future__ import print_function
  5. #-----------------------------------------------------------------------------
  6. #Copyright (c) 2013, the IPython Development Team.
  7. #
  8. #Distributed under the terms of the Modified BSD License.
  9. #
  10. #The full license is in the file COPYING.txt, distributed with this software.
  11. #-----------------------------------------------------------------------------
  12. #-----------------------------------------------------------------------------
  13. # Imports
  14. #-----------------------------------------------------------------------------
  15. from .base import WriterBase
  16. from pprint import pprint
  17. #-----------------------------------------------------------------------------
  18. # Classes
  19. #-----------------------------------------------------------------------------
  20. class DebugWriter(WriterBase):
  21. """Consumes output from nbconvert export...() methods and writes useful
  22. debugging information to the stdout. The information includes a list of
  23. resources that were extracted from the notebook(s) during export."""
  24. def write(self, output, resources, notebook_name='notebook', **kw):
  25. """
  26. Consume and write Jinja output.
  27. See base for more...
  28. """
  29. if isinstance(resources['outputs'], dict):
  30. print("outputs extracted from %s" % notebook_name)
  31. print('-' * 80)
  32. pprint(resources['outputs'], indent=2, width=70)
  33. else:
  34. print("no outputs extracted from %s" % notebook_name)
  35. print('=' * 80)