Show More
@@ -13,7 +13,9 b" notebook file. The extracted figures are returned in the 'resources' dictionary" | |||
|
13 | 13 | # Imports |
|
14 | 14 | #----------------------------------------------------------------------------- |
|
15 | 15 | |
|
16 | import base64 | |
|
16 | 17 | import sys |
|
18 | ||
|
17 | 19 | from IPython.utils.traitlets import Unicode |
|
18 | 20 | from .base import Transformer |
|
19 | 21 | from IPython.utils import py3compat |
@@ -65,15 +67,10 b' class ExtractFigureTransformer(Transformer):' | |||
|
65 | 67 | |
|
66 | 68 | #Binary files are base64-encoded, SVG is already XML |
|
67 | 69 | if out_type in ('png', 'jpg', 'jpeg', 'pdf'): |
|
68 | ||
|
69 | #Python3 base64 is in a separate library... | |
|
70 |
|
|
|
71 |
|
|
|
72 | #Base 64 decode the bytes | |
|
73 | import base64 | |
|
74 | data = base64.b64decode(data) | |
|
75 | else: | |
|
76 | data = data.decode('base64') | |
|
70 | # data is b64-encoded as text (str, unicode) | |
|
71 | # decodestring only accepts bytes | |
|
72 | data = py3compat.cast_bytes(data) | |
|
73 | data = base64.decodestring(data) | |
|
77 | 74 | elif sys.platform == 'win32': |
|
78 | 75 | data = data.replace('\n', '\r\n').encode("UTF-8") |
|
79 | 76 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now