##// END OF EJS Templates
Removing old xml notebook format.
Brian Granger -
Show More
@@ -48,17 +48,6 b' def parse_json(s, **kwargs):'
48 48 return nbformat, d
49 49
50 50
51 def parse_xml(s, **kwargs):
52 """Parse a string into a (nbformat, etree) tuple."""
53 root = ET.fromstring(s)
54 nbformat_e = root.find('nbformat')
55 if nbformat_e is not None:
56 nbformat = int(nbformat_e.text)
57 else:
58 raise NBFormatError('No nbformat version found')
59 return nbformat, root
60
61
62 51 def parse_py(s, **kwargs):
63 52 """Parse a string into a (nbformat, string) tuple."""
64 53 pattern = r'# <nbformat>(?P<nbformat>\d+)</nbformat>'
@@ -87,16 +76,6 b' def writes_json(nb, **kwargs):'
87 76 return v2.writes_json(nb, **kwargs)
88 77
89 78
90 def reads_xml(s, **kwargs):
91 """Read an XML notebook from a string and return the NotebookNode object."""
92 nbformat, root = parse_xml(s, **kwargs)
93 if nbformat == 2:
94 nb = v2.to_notebook_xml(root, **kwargs)
95 else:
96 raise NBFormatError('Unsupported XML nbformat version: %i' % nbformat)
97 return nb
98
99
100 79 def reads_py(s, **kwargs):
101 80 """Read a .py notebook from a string and return the NotebookNode object."""
102 81 nbformat, s = parse_py(s, **kwargs)
@@ -133,9 +112,7 b' def reads(s, format, **kwargs):'
133 112 The notebook that was read.
134 113 """
135 114 format = unicode(format)
136 if format == u'xml':
137 return reads_xml(s, **kwargs)
138 elif format == u'json' or format == u'ipynb':
115 if format == u'json' or format == u'ipynb':
139 116 return reads_json(s, **kwargs)
140 117 elif format == u'py':
141 118 return reads_py(s, **kwargs)
@@ -161,9 +138,7 b' def writes(nb, format, **kwargs):'
161 138 The notebook string.
162 139 """
163 140 format = unicode(format)
164 if format == u'xml':
165 raise NotImplementedError('Write to XML files is not implemented.')
166 elif format == u'json' or format == u'ipynb':
141 if format == u'json' or format == u'ipynb':
167 142 return writes_json(nb, **kwargs)
168 143 elif format == u'py':
169 144 return writes_py(nb, **kwargs)
@@ -26,10 +26,6 b' from .nbjson import reads as reads_json, writes as writes_json'
26 26 from .nbjson import reads as read_json, writes as write_json
27 27 from .nbjson import to_notebook as to_notebook_json
28 28
29 from .nbxml import reads as reads_xml
30 from .nbxml import reads as read_xml
31 from .nbxml import to_notebook as to_notebook_xml
32
33 29 from .nbpy import reads as reads_py, writes as writes_py
34 30 from .nbpy import reads as read_py, writes as write_py
35 31 from .nbpy import to_notebook as to_notebook_py
General Comments 0
You need to be logged in to leave comments. Login now