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