1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 17:42:20 +03:00

EngineerProgress: Rank/RankProgress is complicated.

And, yes, flake8 checks, validating these events *is* complex.
This commit is contained in:
Athanasius 2021-05-20 15:51:28 +01:00
parent a82099fe53
commit 2184afba9b

View File

@ -1635,7 +1635,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
# TODO: *This* will need refactoring and a proper validation infrastructure
# designed for this in the future. This is a bandaid for a known issue.
def event_valid_engineerprogress(self, entry) -> bool: # noqa: CCR001
def event_valid_engineerprogress(self, entry) -> bool: # noqa: CCR001 C901
"""
Check an `EngineerProgress` Journal event for validity.
@ -1668,14 +1668,20 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
for e in entry['Engineers']:
for f in ('Engineer', 'EngineerID', 'Rank', 'Progress', 'RankProgress'):
if f not in e:
logger.warning(f"Engineer entry without '{f}' key: {e=}")
# For some Progress there's no Rank/RankProgress yet
if f in ('Rank', 'RankProgress'):
if (progress := e.get('Progress', None)) is not None:
if progress in ('Invited', 'Known'):
continue
logger.warning(f"Engineer entry without '{f}' key: {e=} in {entry=}")
return False
if 'Progress' in entry:
for e in entry['Engineers']:
for f in ('Engineer', 'EngineerID', 'Rank', 'Progress', 'RankProgress'):
if f not in e:
logger.warning(f"Engineer entry without '{f}' key: {e=}")
logger.warning(f"Engineer entry without '{f}' key: {e=} in {entry=}")
return False
return True