diff --git a/setup.py b/setup.py index 727eb550d2f3c26bc919e1b9379a75a45f98ec1d..a4166e4dfb4c89f0169b8e7c0a8c5f91fece069b 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ from setuptools import setup, find_packages entry_points = { "console_scripts": [ "robofish-io-validate=robofish.io.app:validate", - "robofish-io-print=robofish.io.app:print", + "robofish-io-print=robofish.io.app:print_file", # TODO: This should be called robofish-evaluate which is not possible because of the package name (guess) ask moritzs "robofish-io-evaluate=robofish.evaluate.app:evaluate", ] @@ -48,7 +48,14 @@ setup( version=source_version(), author="", author_email="", - install_requires=["h5py>=3.1.0", "numpy", "seaborn", "pandas", "deprecation"], + install_requires=[ + "h5py>=3.1.0", + "numpy", + "seaborn", + "pandas", + "deprecation", + "tqdm", + ], classifiers=[ "Development Status :: 3 - Alpha", "Intended Audience :: Science/Research", diff --git a/src/robofish/io/app.py b/src/robofish/io/app.py index e31e9ca38a8584312ec8250c6bb733a55b03c479..9e7fa858da781e990634b222ae01bb2cb3214e02 100644 --- a/src/robofish/io/app.py +++ b/src/robofish/io/app.py @@ -15,7 +15,7 @@ import argparse import logging -def print(args=None): +def print_file(args=None): """This function can be used to print hdf5 files from the command line Returns: @@ -39,12 +39,11 @@ def print(args=None): sf = robofish.io.File(path=args.path, strict_validate=False) - output_str = sf.to_string(args.output_format) - output_str += "\n" - output_str += ( - "Valid file" if sf.validate(strict_validate=False)[0] else "Invalid file" - ) - return output_str + print(sf.to_string(args.output_format)) + print() + valid = sf.validate(strict_validate=False)[0] + print("Valid file" if valid else "Invalid file") + return not valid def validate(args=None): @@ -93,10 +92,11 @@ def validate(args=None): return sf_dict max_filename_width = max([len((str)(f)) for f in sf_dict.keys()]) - text = "" + error_code = 0 for file, sf in sf_dict.items(): filled_file = (str)(file).ljust(max_filename_width + 3) validity, validity_message = sf.validate(strict_validate=False) - text += f"{filled_file}:{validity}\t{validity_message}\n" - - return text + if not validity: + error_code = 1 + print(f"{filled_file}:{validity}\t{validity_message}") + return error_code diff --git a/tests/robofish/io/test_app_io.py b/tests/robofish/io/test_app_io.py index 056d3d3191ea35d7a7ee5b62ac05e90b202c8bfd..6ac95611137f8de5634cc622ff05e8be4cfb5e0f 100644 --- a/tests/robofish/io/test_app_io.py +++ b/tests/robofish/io/test_app_io.py @@ -32,9 +32,9 @@ def test_app_print(): self.path = path self.output_format = output_format - app.print( + app.print_file( DummyArgs(utils.full_path(__file__, "../../resources/valid.hdf5"), "full") ) - app.print( + app.print_file( DummyArgs(utils.full_path(__file__, "../../resources/valid.hdf5"), "shape") )