From 0a3c7dc4397ef50079b5fafd5d04cb72b40f4421 Mon Sep 17 00:00:00 2001 From: B13nch3n <b13nch3n_01@theb-si.de> Date: Mon, 27 Jun 2022 14:47:29 +0200 Subject: [PATCH] Change error handling --- .gitignore | 1 + validation/validate-mmcif-file.py | 22 +++++----------------- 2 files changed, 6 insertions(+), 17 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..60ce4b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +\.DS_Store diff --git a/validation/validate-mmcif-file.py b/validation/validate-mmcif-file.py index 3eaa64e..dff916f 100755 --- a/validation/validate-mmcif-file.py +++ b/validation/validate-mmcif-file.py @@ -423,16 +423,16 @@ class _CifCheck: universal_newlines=True, cwd=cifcheck_wd, ) + error_lst = [] # get error messages on the command line - filename = os.path.basename(filepath) - if cps.returncode != 0: - error_lst = _parse_cifcheck_stderr(cps.stderr) - error_lst.extend(_parse_parser_file(filename)) + error_lst.extend(_parse_cifcheck_stderr(cps.stderr)) + error_lst.extend(_parse_parser_file(filepath)) + if len(error_lst) > 0: raise _CifCheckFailedError(cifcheck_cmd, error_lst) # get messages from diagnosis file - error_lst.extend(_parse_diag_file(os.path.join(cifcheck_wd, filename))) + error_lst.extend(_parse_diag_file(filepath)) return error_lst @@ -625,12 +625,6 @@ def _main(): cifcheck.make_json_output() sys.exit(1) - # do a first check of the model cif alone to make sure its actual cif - success = cifcheck.run(opts.model_cif) - if not success: - cifcheck.make_json_output() - sys.exit(1) - # check for associated files referenced by the model cif file assoc_files, model_cif_data, entry_id_map = _get_associated_files( opts.model_cif @@ -641,12 +635,6 @@ def _main(): # make sure associated files exist and merge all of them into the model for assoc, entry_id in assoc_files: assoc_path = os.path.join(opts.associates_dir, assoc) - # CifCheck the file to make sure its actually cif, diagnosis messages do - # not matter at this point as an incomplete file is tested. - success = cifcheck.run(assoc_path) - if not success: - cifcheck.make_json_output() - sys.exit(1) # merge the model.cif and the associated file msgs = _merge_cif_data( model_cif_data, assoc_path, entry_id, entry_id_map -- GitLab