Skip to content
Snippets Groups Projects
Commit 170bfc8d authored by Andi Gerken's avatar Andi Gerken
Browse files

Merge branch 'error-codes' into 'master'

Fix #12: Return error codes instead of ouput text

Closes #12

See merge request !13
parents 81dec7eb 636b8416
Branches
Tags
1 merge request!13Fix #12: Return error codes instead of ouput text
Pipeline #37802 passed
......@@ -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",
......
......@@ -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
......@@ -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")
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment