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

PEP8 for validator code, improved dev-mode in validator container

parent 9bc58fb1
No related branches found
No related tags found
No related merge requests found
......@@ -12,3 +12,23 @@ extension-pkg-allow-list='rapidjson'
[tool.pylint.FORMAT]
max-line-length=80
[tool.pylint.deprecated_builtins]
# We want to use proper logging, so we can control *ALL* output bei the Abseil
# logger, hence: deprecate 'print'
bad-functions = ["map", "filter", "print"]
# Run the spell check every once in a while, having it enabled always, is too
# annoying.
[tool.pylint.spelling]
max-spelling-suggestions = 4
spelling-dict = "en_GB"
spelling-ignore-comment-directives = "fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy:"
spelling-ignore-words = ""
spelling-private-dict-file = ".spelling"
spelling-store-unknown-words = false
ARG VERSION_PYTHON="3.9"
ARG VERSION_BASE_IMAGE="python:${VERSION_PYTHON}-alpine3.17"
ARG VERSION_BASE_IMAGE="python:${VERSION_PYTHON}-alpine3.19"
FROM ${VERSION_BASE_IMAGE}
# We need to declare ARGs again which were declared before the build stage
# (FROM directive), otherwise they won't be available in this stage.
......@@ -141,10 +141,22 @@ RUN set -e pipefail; \
ARG ADD_DEV
RUN set -e pipefail; \
if test xYES = x`echo ${ADD_DEV} | tr '[:lower:]' '[:upper:]'`; then \
apk add bash emacs gcc build-base; \
/usr/local/bin/python -m pip install pylint black; \
apk add bash \
binutils \
build-base \
emacs \
enchant2-dev \
gcc \
hunspell-en-gb \
py3-enchant; \
/usr/local/bin/python -m pip install pylint[spelling] black; \
apk del gcc build-base; \
fi
fi; \
# the alias assumes you are in the directory containing the code \
echo "alias black_n_pylint=\"black --config ../pyproject.toml " \
"test-suite.py validate-mmcif-file.py && pylint " \
"--rc-file=../pyproject.toml test-suite.py validate-mmcif-file.py\"" \
>> /etc/bash/bashrc
## Add a dedicated user for mmCIF file validation
## MMCIF_USER_ID can be used to avoid file permission issues in development.
......
......@@ -490,7 +490,11 @@ class _CifCheck:
def __init__(self, dict_sdb, json_out_file=None, verbose=False):
self._version = None
self.check_results = {"errors": [], "diagnosis": [], "cifcheck-errors": []}
self.check_results = {
"errors": [],
"diagnosis": [],
"cifcheck-errors": [],
}
self.dict_sdb = os.path.abspath(dict_sdb)
self.json_out_file = json_out_file
self.verbose = verbose
......@@ -812,12 +816,20 @@ class _CifCheck:
"missing_files": {},
}
for line in self.check_results["errors"]:
match = re.match(r"ma_entry_associated_files.file_url '(?P<arc>.*)' is missing ma_associated_archive_file_details.file_path '(?P<fle>.*)'", line)
match = re.match(
r"ma_entry_associated_files.file_url '(?P<arc>.*)' is missing "
+ r"ma_associated_archive_file_details.file_path '(?P<fle>.*)'",
line,
)
if match is not None:
try:
rprt["missing_files"][match.group('arc')].append(match.group('fle'))
rprt["missing_files"][match.group("arc")].append(
match.group("fle")
)
except KeyError:
rprt["missing_files"][match.group('arc')] = [match.group('fle')]
rprt["missing_files"][match.group("arc")] = [
match.group("fle")
]
continue
# Unmatched lines need to be added to above evaluation
raise RuntimeError(f'Unmatched error line found:\n"""{line}"""')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment