Skip to content
Snippets Groups Projects
Commit f0b8416e authored by B13nch3n's avatar B13nch3n
Browse files

Reduce loc

parent 72f09e40
No related branches found
No related tags found
No related merge requests found
......@@ -355,8 +355,8 @@ def _main():
+ '"atom_site"',
],
},
# duplicated item in _loop category
# missing category (entity)
# duplicated item in _loop category
# parent-child relationship issue (remove an atom_type.symbol)
}
......
......@@ -57,14 +57,24 @@ def _parse_command_line():
+ "external files attached.",
default=None,
)
parser.add_argument(
dic_grp = parser.add_mutually_exclusive_group()
dic_grp.add_argument(
"--dict-sdb",
"-d",
type=str,
metavar="<SDB FILE>",
help="The dictionary in SDB format used for checking.",
help="The dictionary in SDB format used for checking. Can't be "
+ "combined with --modelcif-mode/-m and --pdbx-mmcif-mode/-p.",
default="/usr/local/share/mmcif-dict-suite/mmcif_ma.sdb",
)
dic_grp.add_argument(
"--pdbx-mmcif-mode",
"-p",
action="store_true",
help="Check with the PDBX/mmCIF dictionary, for verbatim mmCIF files. "
+ "Can't be combined with --dict-sdb/-d and --modelcif-mode/-m. "
+ "Default is to check with the ModelCIF dictionary.",
)
parser.add_argument(
"--out-file",
"-o",
......@@ -106,6 +116,8 @@ def _parse_command_line():
if opts.extend_validated_file is not None:
if opts.extend_validated_file == " same ":
opts.extend_validated_file = opts.model_cif
if opts.pdbx_mmcif_mode is True:
opts.dict_sdb = "/usr/local/share/mmcif-dict-suite/mmcif_pdbx_v50.sdb"
return opts
......@@ -135,42 +147,23 @@ def _parse_cifcheck_stderr(stderr):
return error_lst
def _parse_parser_file(filename):
"""Parse the parser output file of CifCheck."""
parserfile = filename + "-parser.log"
if not os.path.exists(parserfile):
return []
error_lst = []
with open(parserfile, encoding="utf-8") as dfh:
for line in dfh:
line = line.strip()
error_lst.append(line)
# remove the diag file
os.unlink(parserfile)
return error_lst
def _parse_diag_file(filename):
def _get_cifcheck_out(filename, suffix, encoding):
"""Parse the diagnosis file of CifCheck."""
# CifCheck places the diag file in the current working directory.
diagfile = filename + "-diag.log"
if not os.path.exists(diagfile):
cifcheck = filename + suffix
if not os.path.exists(cifcheck):
return []
error_lst = []
# CifCheck outputs diag files as iso-8859
with open(diagfile, encoding="iso-8859-1") as dfh:
with open(cifcheck, encoding=encoding) as dfh:
for line in dfh:
line = line.strip()
if line == "":
continue
error_lst.append(line)
# remove the diag file
os.unlink(diagfile)
os.unlink(cifcheck)
return error_lst
......@@ -592,12 +585,14 @@ class _CifCheck:
error_lst = []
# get error messages on the command line
error_lst.extend(_parse_cifcheck_stderr(cps.stderr))
error_lst.extend(_parse_parser_file(filepath))
error_lst.extend(_get_cifcheck_out(filepath, "-parser.log", "utf-8"))
if len(error_lst) > 0:
raise _CifCheckFailedError(cifcheck_cmd, error_lst)
# get messages from diagnosis file
error_lst.extend(_parse_diag_file(filepath))
error_lst.extend(
_get_cifcheck_out(filepath, "-diag.log", "iso-8859-1")
)
return error_lst
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment