|
3 | 3 | import click |
4 | 4 | import sys |
5 | 5 |
|
| 6 | +from jsoncsv import jsontool |
| 7 | +from jsoncsv import dumptool |
6 | 8 | from jsoncsv.dumptool import dump_excel |
7 | 9 | from jsoncsv.jsontool import convert_json |
8 | 10 | from jsoncsv.utils import separator_type |
@@ -44,11 +46,11 @@ def jsoncsv(output, input, expand, restore, safe, separator): |
44 | 46 | if expand and restore: |
45 | 47 | raise click.UsageError('can not choose both, default is `-e`') |
46 | 48 |
|
47 | | - type = "expand" # default |
| 49 | + func = jsontool.expand |
48 | 50 | if restore: |
49 | | - type = "restore" |
| 51 | + func = jsontool.restore |
50 | 52 |
|
51 | | - convert_json(input, output, type, separator, safe) |
| 53 | + convert_json(input, output, func, separator, safe) |
52 | 54 |
|
53 | 55 | input.close() |
54 | 56 | output.close() |
@@ -87,7 +89,11 @@ def mkexcel(output, input, sort_, row, type_): |
87 | 89 | if output == sys.stdout and type_ == "xls": |
88 | 90 | output = click.get_binary_stream('stdout') |
89 | 91 |
|
90 | | - dump_excel(input, output, type_, read_row=row, sort_type=sort_) |
| 92 | + klass = dumptool.DumpCSV |
| 93 | + if type_ == "xls": |
| 94 | + klass = dumptool.DumpXLS |
| 95 | + |
| 96 | + dump_excel(input, output, klass, read_row=row, sort_type=sort_) |
91 | 97 |
|
92 | 98 | input.close() |
93 | 99 | output.close() |
0 commit comments