From 3bdf19adeb952cdd3ee1d0c477c2a08be899b865 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Sat, 9 May 2020 01:01:12 +0200 Subject: [PATCH] STY: autoformatting python scripts --- makefile | 1 + scripting/bin/administration/diagnostics.py | 14 ++++++++++++-- scripting/bin/xls_from_csv.py | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index 55631222..e900742b 100644 --- a/makefile +++ b/makefile @@ -47,6 +47,7 @@ run-single: formatting: mvn fmt:format + autopep8 -ari scripting/ # Compile into a standalone jar file jar: easy-units diff --git a/scripting/bin/administration/diagnostics.py b/scripting/bin/administration/diagnostics.py index 3c1f2eed..a4df7400 100755 --- a/scripting/bin/administration/diagnostics.py +++ b/scripting/bin/administration/diagnostics.py @@ -47,12 +47,15 @@ def get_option(name, default=None): return arg[index:] return default + def get_exit_code(): return int(get_option("exit", 0)) + def get_auth_token(): return get_option("auth-token") + def get_query(): return get_option("query") @@ -62,7 +65,9 @@ def get_caosdb_info(auth_token): result = dict() try: - db.configure_connection(auth_token=auth_token, password_method="auth_token") + db.configure_connection( + auth_token=auth_token, + password_method="auth_token") info = db.Info() @@ -81,17 +86,22 @@ def get_caosdb_info(auth_token): result["exception"] = str(e) return result + def test_imports(modules): result = dict() for m in modules: try: i = __import__(m) - v = i.__version__ if hasattr(i, "__version__") and i.__version__ is not None else "unknown version" + if hasattr(i, "__version__") and i.__version__ is not None: + v = i.__version__ + else: + v = "unknown version" result[m] = (True, v) except ImportError as e: result[m] = (False, str(e)) return result + def main(): try: import json diff --git a/scripting/bin/xls_from_csv.py b/scripting/bin/xls_from_csv.py index 38dfbc1c..73bb6b0a 100755 --- a/scripting/bin/xls_from_csv.py +++ b/scripting/bin/xls_from_csv.py @@ -93,7 +93,8 @@ def _parse_arguments(): parser.add_argument('-t', '--tempdir', required=False, default=tempdir, help="Temporary dir for saving the result.") parser.add_argument('-a', '--auth-token', required=False, - help="An authentication token (not needed, only for compatibility).") + help=("An authentication token (not needed, only for " + "compatibility).")) parser.add_argument('tsv', help="The tsv file.") return parser.parse_args() @@ -104,5 +105,6 @@ def main(): filename = _write_xls(dataframe, directory=args.tempdir) print(filename) + if __name__ == "__main__": main() -- GitLab