@@ -23,11 +23,14 @@ def restore_bytes(nb):
23
23
if "png" in output :
24
24
output .png = output .png .encode ("ascii" , "replace" )
25
25
if "jpeg" in output :
26
- output .jpeg = output .jpeg .encode ("ascii" , "replace" )
26
+ output .jpeg = output .jpeg .encode (
27
+ "ascii" , "replace" )
27
28
except KeyError as e :
28
- raise validator .ValidationError (f"The notebook was invalid missing the key: { e .message } " )
29
+ raise validator .ValidationError (
30
+ f"The notebook was invalid missing the key: { e .message } " )
29
31
return nb
30
32
33
+
31
34
# output keys that are likely to have multiline values
32
35
_multiline_outputs = ['text' , 'html' , 'svg' , 'latex' , 'javascript' , 'json' ]
33
36
@@ -67,7 +70,7 @@ def rejoin_lines(nb):
67
70
item = output .get (key , None )
68
71
if isinstance (item , list ):
69
72
output [key ] = _join_lines (item )
70
- else : # text, heading cell
73
+ else : # text, heading cell
71
74
for key in ['source' , 'rendered' ]:
72
75
item = cell .get (key , None )
73
76
if isinstance (item , list ):
@@ -93,7 +96,7 @@ def split_lines(nb):
93
96
item = output .get (key , None )
94
97
if isinstance (item , str ):
95
98
output [key ] = item .splitlines (True )
96
- else : # text, heading cell
99
+ else : # text, heading cell
97
100
for key in ['source' , 'rendered' ]:
98
101
item = cell .get (key , None )
99
102
if isinstance (item , str ):
@@ -103,6 +106,7 @@ def split_lines(nb):
103
106
# b64 encode/decode are never actually used, because all bytes objects in
104
107
# the notebook are already b64-encoded, and we don't need/want to double-encode
105
108
109
+
106
110
def base64_decode (nb ):
107
111
"""Restore all bytes objects in the notebook from base64-encoded strings.
108
112
@@ -179,8 +183,5 @@ def writes(self, nb, **kwargs):
179
183
180
184
def write (self , nb , fp , ** kwargs ):
181
185
"""Write a notebook to a file like object"""
182
- nbs = self .writes (nb ,** kwargs )
186
+ nbs = self .writes (nb , ** kwargs )
183
187
return fp .write (nbs )
184
-
185
-
186
-
0 commit comments