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

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

Loading…
Cancel
Save