Skip to content

Commit

Permalink
Fix validator logic
Browse files Browse the repository at this point in the history
  • Loading branch information
George V. Kouryachy (Fr. Br. George) committed Oct 8, 2023
1 parent a5119e9 commit be2746f
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions hworker/check/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,20 @@ def validate_wo_store(validator: Check, solution: Solution, check_num: int = 0)
module = module_from_spec(spec)
spec.loader.exec_module(module)

validator_type = None
if get_validator_name() in dir(module):
validator_type = get_validator_name()
elif get_version_validator_name() in dir(module):
validator_type = get_version_validator_name()

validator_type = (set(dir(module)) & {get_validator_name(), get_version_validator_name()} or {None}).pop()
stderr, result = b"", 0.0

if validator_type:
v = getattr(module, validator_type)
if validator_type == get_validator_name():

This comment has been minimized.

Copy link
@FrBrGeorge

FrBrGeorge Oct 8, 2023

Owner

Вот это очень не сразу я нашёл ☹

try:
if validator_type == get_validator_name():
result = v(solution, *validator_args)
else:
result = v(search(Solution, Criteria("ID", "==", solution.ID)), *validator_args)
except Exception as error:
stderr = str(error).encode()
finally:
module_path.unlink(missing_ok=True)
try:
if validator_type == get_validator_name():
result = v(solution, *validator_args)
else:
result = v(search(Solution, Criteria("ID", "==", solution.ID)), *validator_args)
except Exception as error:
stderr = str(error).encode()
finally:
module_path.unlink(missing_ok=True)
verdict = VerdictEnum.passed if not stderr else VerdictEnum.failed
else:
verdict = VerdictEnum.missing
Expand Down

0 comments on commit be2746f

Please sign in to comment.