Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jsoncsv/dumptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# 2015.10.09

import six
import csv
import unicodecsv as csv
import json
import xlwt

Expand Down
7 changes: 1 addition & 6 deletions jsoncsv/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# coding=utf-8

import io
import click
import sys

from jsoncsv import jsontool
from jsoncsv import dumptool
from jsoncsv import PY3
from jsoncsv.dumptool import dump_excel
from jsoncsv.jsontool import convert_json
from jsoncsv.utils import separator_type
Expand Down Expand Up @@ -88,11 +86,8 @@ def jsoncsv(output, input, expand, restore, safe, separator):
type=click.File('wb'),
default=sys.stdout)
def mkexcel(output, input, sort_, row, type_):
if type_ == "xls" and output == sys.stdout:
if output == sys.stdout:
output = click.get_binary_stream('stdout')
if type_ == "csv" and output != sys.stdout:
if PY3:
output = io.TextIOWrapper(output)

klass = dumptool.DumpCSV
if type_ == "xls":
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
xlwt>=1.1.2
click>=6.7
click>=6.7
unicodecsv>=0.14.1
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='jsoncsv',
version='2.2.0a',
version='2.2.0b1',
url='https://github.com/alingse/jsoncsv',
description='A command tool easily convert json file to csv or xlsx.',
long_description=readme,
Expand All @@ -30,6 +30,7 @@
'Programming Language :: Python :: 3.6',
],
install_requires=[
'unicodecsv',
'xlwt',
'click',
],
Expand Down
6 changes: 3 additions & 3 deletions tests/test_mkexcel.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TestDumpTool(unittest.TestCase):
# FIXME (使用虚拟文件)
def test_dumpexcel_csv(self):
fin = open('./fixture/files/expand.1.json', 'r')
fout = open('./fixture/files/tmp.output.1.csv', 'w')
fout = open('./fixture/files/tmp.output.1.csv', 'wb')

dump_excel(fin, fout, DumpCSV)
fin.close()
Expand All @@ -30,7 +30,7 @@ def test_dumpexcel_csv(self):

def test_dumpexcel_csv_with_sort(self):
fin = open('./fixture/files/expand.1.json', 'r')
fout = open('./fixture/files/tmp.output.1.sort.csv', 'w')
fout = open('./fixture/files/tmp.output.1.sort.csv', 'wb')

dump_excel(fin, fout, DumpCSV, sort_type=True)
fin.close()
Expand All @@ -55,7 +55,7 @@ def test_dumpcexcel_xls(self):

def test_dump_csv_with_non_ascii(self):
fin = open('./fixture/files/expand.2.json', 'r')
fout = open('./fixture/files/tmp.output.2.csv', 'w')
fout = open('./fixture/files/tmp.output.2.csv', 'wb')

dump_excel(fin, fout, DumpCSV)

Expand Down