Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/nbformat/v1/rwbase.py: 50%
12 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-01 06:54 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-01 06:54 +0000
1"""Base classes and function for readers and writers.
3Authors:
5* Brian Granger
6"""
8# -----------------------------------------------------------------------------
9# Copyright (C) 2008-2011 The IPython Development Team
10#
11# Distributed under the terms of the BSD License. The full license is in
12# the file LICENSE, distributed as part of this software.
13# -----------------------------------------------------------------------------
15# -----------------------------------------------------------------------------
16# Imports
17# -----------------------------------------------------------------------------
19# -----------------------------------------------------------------------------
20# Code
21# -----------------------------------------------------------------------------
24class NotebookReader:
25 """The base notebook reader."""
27 def reads(self, s, **kwargs):
28 """Read a notebook from a string."""
29 msg = "loads must be implemented in a subclass"
30 raise NotImplementedError(msg)
32 def read(self, fp, **kwargs):
33 """Read a notebook from a file like object"""
34 return self.reads(fp.read(), **kwargs)
37class NotebookWriter:
38 """The base notebook writer."""
40 def writes(self, nb, **kwargs):
41 """Write a notebook to a string."""
42 msg = "loads must be implemented in a subclass"
43 raise NotImplementedError(msg)
45 def write(self, nb, fp, **kwargs):
46 """Write a notebook to a file like object"""
47 return fp.write(self.writes(nb, **kwargs))