Skip to content

Commit e8969cb

Browse files
committed
0.1.0 uses pyexcel-io 0.1.0
1 parent 8c4e3b7 commit e8969cb

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
include README.rst
2+
include VERSION

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0-dev

pyexcel_text/__init__.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,14 @@ def __init__(self, filename, **keywords):
160160
TextWriter.__init__(self, filename, **keywords)
161161

162162
def write(self, sheet_dicts):
163-
import json
164-
self.f.write(json.dumps(sheet_dicts))
163+
if self.keywords.get('single_sheet_in_book', False):
164+
keys = list(sheet_dicts.keys())
165+
sheet = self.create_sheet(keys[0])
166+
sheet.write_array(sheet_dicts[keys[0]])
167+
sheet.close()
168+
else:
169+
import json
170+
self.f.write(json.dumps(sheet_dicts))
165171

166172
def create_sheet(self, name):
167173
return JsonSheetWriter(self.f, name)

setup.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
with open("README.rst", 'r') as readme:
1616
README_txt = readme.read()
1717

18+
with open("VERSION", "r") as version:
19+
version_txt = version.read().rstrip()
20+
1821
setup(
1922
name='pyexcel-text',
2023
author="C. W.",
21-
version='0.0.3',
24+
version=version_txt,
2225
author_email="[email protected]",
2326
url="https://github.com/chfw/pyexcel-text",
2427
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),

tests/test_io.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
22
import sys
3+
import json
4+
35
from textwrap import dedent
46
import pyexcel as pe
57
from pyexcel.ext import text
@@ -98,6 +100,7 @@ def test_dict(self):
98100
5 6
99101
7 8
100102
= =""").strip('\n')
103+
print written_content
101104
assert written_content.strip('\n') == content
102105

103106
def tearDown(self):
@@ -115,25 +118,20 @@ def test_new_normal_usage(self):
115118
[7, 8, 999]
116119
]
117120
pe.save_as(array=content, dest_file_name=self.testfile)
118-
f = open(self.testfile, "r")
119-
written_content = f.read()
120-
f.close()
121-
content = dedent("""
122-
[[1, 2, 3], [4, 588, 6], [7, 8, 999]]""").strip('\n')
123-
assert written_content == content
121+
with open(self.testfile, "r") as f:
122+
written_content = json.load(f)
123+
print written_content
124+
assert written_content == content
124125

125126
def test_dict(self):
126127
adict = {
127128
'sheet 1': [[1,2],[3,4]],
128129
'sheet 2': [[5,6],[7,8]]
129130
}
130131
pe.save_book_as(bookdict=adict, dest_file_name=self.testfile)
131-
f = open(self.testfile, "r")
132-
written_content = f.read()
133-
f.close()
134-
content = dedent("""
135-
{"sheet 1": [[1, 2], [3, 4]], "sheet 2": [[5, 6], [7, 8]]}""").strip('\n')
136-
assert written_content == content
132+
with open(self.testfile, "r") as f:
133+
written_content = json.load(f)
134+
assert written_content == adict
137135

138136
def tearDown(self):
139137
if os.path.exists(self.testfile):

0 commit comments

Comments
 (0)