Return value from main rather than print

We only really want to print if we are running the module as a script.
It's nice to allow `main` to be imported and used from other code, and
that code probably wants a returned value rather than having to read
from stdout.
main
Eric Ihli 4 years ago
parent 37483148c8
commit 85f864cd17

@ -905,15 +905,15 @@ def main(files):
cv2.imwrite(table_filepath, table)
if tables:
results.append((f, files))
for image_filename, table_filenames in results:
print("\n".join(table_filenames))
# Results is [[<input image>, [<images of detected tables>]]]
return results
if __name__ == "__main__":
args = parser.parse_args()
files = args.files
main(files)
results = main(files)
for image, tables in results:
print("\n".join(tables))
#+END_SRC
*** table_ocr/extract_cells/

@ -28,12 +28,12 @@ def main(files):
cv2.imwrite(table_filepath, table)
if tables:
results.append((f, files))
for image_filename, table_filenames in results:
print("\n".join(table_filenames))
# Results is [[<input image>, [<images of detected tables>]]]
return results
if __name__ == "__main__":
args = parser.parse_args()
files = args.files
main(files)
results = main(files)
for image, tables in results:
print("\n".join(tables))

Loading…
Cancel
Save