Add verbose
This commit is contained in:
+10
-5
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python2
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
@@ -25,6 +26,7 @@ options:
|
||||
Example: -p 1,3-6,10 [default: 1]
|
||||
-f, --format <format> Output format. (csv,tsv,html,json,xlsx) [default: csv]
|
||||
-l, --log Print log to file.
|
||||
-V, --verbose Verbose.
|
||||
-o, --output <directory> Output directory.
|
||||
|
||||
camelot methods:
|
||||
@@ -128,7 +130,7 @@ def write_to_disk(data, f='csv', output=None, filename=None):
|
||||
[row for row in data[page][table]]})
|
||||
save_data(os.path.join(output, '{}.xlsx'.format(froot)), xlsx_data)
|
||||
except ImportError:
|
||||
print "link to install docs"
|
||||
print("link to install docs")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -141,6 +143,7 @@ if __name__ == '__main__':
|
||||
elif args['<method>'] == 'stream':
|
||||
args.update(docopt(stream_doc, argv=argv))
|
||||
|
||||
vprint = print if args['--verbose'] else lambda *a, **k: None
|
||||
filename = args['<file>']
|
||||
filedir = os.path.dirname(args['<file>'])
|
||||
logname, __ = os.path.splitext(filename)
|
||||
@@ -178,7 +181,8 @@ if __name__ == '__main__':
|
||||
jtol=int(args['--jtol']),
|
||||
mtol=int(args['--mtol']),
|
||||
invert=args['--invert'],
|
||||
debug=args['--debug'])
|
||||
debug=args['--debug'],
|
||||
verbose=args['--verbose'])
|
||||
data = extractor.get_tables()
|
||||
if args['--debug']:
|
||||
extractor.plot_geometry(args['--debug'])
|
||||
@@ -195,7 +199,8 @@ if __name__ == '__main__':
|
||||
ncolumns=int(args['--ncols']),
|
||||
columns=args['--columns'],
|
||||
ytol=int(args['--ytol']),
|
||||
debug=args['--debug'])
|
||||
debug=args['--debug'],
|
||||
verbose=args['--verbose'])
|
||||
data = extractor.get_tables()
|
||||
if args['--debug']:
|
||||
extractor.plot_text()
|
||||
@@ -204,11 +209,11 @@ if __name__ == '__main__':
|
||||
sys.exit()
|
||||
|
||||
if data is None:
|
||||
print "See 'camelot <method> -h' for various parameters you can tweak."
|
||||
print("See 'camelot <method> -h' for various parameters you can tweak.")
|
||||
else:
|
||||
output = filedir if args['--output'] is None else args['--output']
|
||||
write_to_disk(data, f=args['--format'],
|
||||
output=output, filename=filename)
|
||||
|
||||
print "finished in", time.time() - start_time, "seconds"
|
||||
vprint("finished in", time.time() - start_time, "seconds")
|
||||
logging.info("Time taken: " + str(time.time() - start_time) + " seconds")
|
||||
|
||||
Reference in New Issue
Block a user