summaryrefslogtreecommitdiff
path: root/tablib/cli.py
diff options
context:
space:
mode:
authorKenneth Reitz <me@kennethreitz.com>2010-09-28 08:33:57 -0400
committerKenneth Reitz <me@kennethreitz.com>2010-09-28 08:33:57 -0400
commitf58d4b67dc22570fe69338ddf841b76569872ad8 (patch)
treeab03e7f0289bf1c3ad9e7a53f940473d22fe3e8c /tablib/cli.py
parenta310ab7a09e2444d146877d27e0bba6872866b8b (diff)
downloadtablib-f58d4b67dc22570fe69338ddf841b76569872ad8.tar.gz
Changes.
Diffstat (limited to 'tablib/cli.py')
-rw-r--r--tablib/cli.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/tablib/cli.py b/tablib/cli.py
index f182049..6d773c9 100644
--- a/tablib/cli.py
+++ b/tablib/cli.py
@@ -39,23 +39,19 @@ def start(in_file=None, out_file=None, **opts):
if stdin:
data = tablib.import_set(stdin)
- print data.json
- # test = tablib.Dataset()
- # print test.yaml
elif in_file:
try:
- in_file = io.open(in_file, 'r')
+ in_stream =- io.open(in_file, 'r').read()
except Exception, e:
print(' %s cannot be read.' % in_file)
sys.exit(65)
- file_ext = in_file.name.split('.')[-1]
-
- if file_ext.lower() in FORMATS:
- setattr(opts, file_ext, True)
- else:
+ try:
+ tablib.import_set(in_stream)
+ except Exception, e:
+ raise e
print('Import format not supported.')
sys.exit(65)
else:
@@ -63,7 +59,6 @@ def start(in_file=None, out_file=None, **opts):
sys.exit(65)
-
_formats_sum = sum(opts[f] for f in FORMATS)
# Multiple output formats given