Skip to content

Commit 3b6a380

Browse files
committed
💚 fix styling problem
1 parent 84ec619 commit 3b6a380

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pyexcel_io/book.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,13 @@ def _convert_content_to_stream(file_content, file_type):
233233
stream = manager.get_io(file_type)
234234
if not PY2:
235235
target_content_type = manager.get_io_type(file_type)
236-
if target_content_type == 'bytes' and not isinstance(file_content, bytes):
236+
needs_encode = (target_content_type == 'bytes' and
237+
not isinstance(file_content, bytes))
238+
needs_decode = (target_content_type == 'string' and
239+
isinstance(file_content, bytes))
240+
if needs_encode:
237241
file_content = file_content.encode('utf-8')
238-
elif target_content_type == 'string' and isinstance(file_content, bytes):
242+
elif needs_decode:
239243
file_content = file_content.decode('utf-8')
240244
stream.write(file_content)
241245
stream.seek(0)

tests/test_book.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from nose.tools import raises
2-
from pyexcel_io.book import RWInterface, BookReader, BookWriter, _convert_content_to_stream
2+
from pyexcel_io.book import RWInterface, BookReader, BookWriter
3+
from pyexcel_io.book import _convert_content_to_stream
34
from pyexcel_io._compact import PY2, StringIO, BytesIO
45
from nose import SkipTest
56

0 commit comments

Comments
 (0)