##// END OF EJS Templates
support binary files in FilesWriter
MinRK -
Show More
@@ -1,17 +1,7 b''
1 """
1 """Contains writer for writing nbconvert output to filesystem."""
2 Contains writer for writing nbconvert output to filesystem.
3 """
4 #-----------------------------------------------------------------------------
5 #Copyright (c) 2013, the IPython Development Team.
6 #
7 #Distributed under the terms of the Modified BSD License.
8 #
9 #The full license is in the file COPYING.txt, distributed with this software.
10 #-----------------------------------------------------------------------------
11
2
12 #-----------------------------------------------------------------------------
3 # Copyright (c) IPython Development Team.
13 # Imports
4 # Distributed under the terms of the Modified BSD License.
14 #-----------------------------------------------------------------------------
15
5
16 import io
6 import io
17 import os
7 import os
@@ -19,6 +9,7 b' import glob'
19
9
20 from IPython.utils.traitlets import Unicode
10 from IPython.utils.traitlets import Unicode
21 from IPython.utils.path import link_or_copy
11 from IPython.utils.path import link_or_copy
12 from IPython.utils.py3compat import unicode_type
22
13
23 from .base import WriterBase
14 from .base import WriterBase
24
15
@@ -110,6 +101,11 b' class FilesWriter(WriterBase):'
110
101
111 # Write conversion results.
102 # Write conversion results.
112 self.log.info("Writing %i bytes to %s", len(output), dest)
103 self.log.info("Writing %i bytes to %s", len(output), dest)
104 if isinstance(output, unicode_type):
113 with io.open(dest, 'w', encoding='utf-8') as f:
105 with io.open(dest, 'w', encoding='utf-8') as f:
114 f.write(output)
106 f.write(output)
107 else:
108 with io.open(dest, 'wb') as f:
109 f.write(output)
110
115 return dest
111 return dest
General Comments 0
You need to be logged in to leave comments. Login now