From f958c3494560b7222f951726aa9d8f0866211433 Mon Sep 17 00:00:00 2001 From: JKatzwinkel Date: Mon, 2 Oct 2023 20:21:43 +0200 Subject: [PATCH] fix linting issues --- peret/pre.py | 2 +- peret/proc.py | 14 +++++++++----- peret/providers/aed.py | 2 +- peret/providers/bts.py | 17 ++++++++--------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/peret/pre.py b/peret/pre.py index 71976d58..496d1c14 100644 --- a/peret/pre.py +++ b/peret/pre.py @@ -7,7 +7,7 @@ INVERSE = dict( reduce( - lambda l, e: l + [e, e[::-1]], + lambda mappings, e: mappings + [e, e[::-1]], [ ("partOf", "contains"), ("predecessor", "successor"), diff --git a/peret/proc.py b/peret/proc.py index a42e57d1..c4774dca 100644 --- a/peret/proc.py +++ b/peret/proc.py @@ -12,8 +12,8 @@ def patch_vocab(vocab: dict, functions: List[Callable] = None) -> dict: - """ iterate through all key value pairs in vocab registry and apply one or more - functions to each. + """ iterate through all key value pairs in vocab registry and apply one or + more functions to each. >>> from .pre import _verify_relations, _mirror_relations >>> wlist = {'1': {'relations': {'root': ['3']}}, @@ -21,9 +21,13 @@ def patch_vocab(vocab: dict, functions: List[Callable] = None) -> dict: >>> patch_vocab(wlist, [_verify_relations, _mirror_relations])['1'] {'relations': {'root': ['2']}} - >>> ths = {'D3R5CH5NZBDA7IZMCKKJPWYZKU': {'dates': {'beginning': ['0'], 'end': ['0']}}} - >>> patch_vocab(ths, [bts.fill_in_missing_dateranges])['D3R5CH5NZBDA7IZMCKKJPWYZKU'] - {'dates': {'beginning': ['-900'], 'end': ['-1']}} + >>> ths = {'D3R5CH5NZBDA7IZMCKKJPWYZKU': { + ... 'dates': {'beginning': ['0'], 'end': ['0']} + ... }} + >>> patch_vocab( + ... ths, [bts.fill_in_missing_dateranges] + ... )['D3R5CH5NZBDA7IZMCKKJPWYZKU'] + {'dates': {'beginning': [' -900'], 'end': [' -1']}} """ for _id, entry in vocab.items(): diff --git a/peret/providers/aed.py b/peret/providers/aed.py index f2609ae1..4cb97e3f 100644 --- a/peret/providers/aed.py +++ b/peret/providers/aed.py @@ -107,7 +107,7 @@ def load_lemmata( zip_file.namelist() ) ): - if i+1 > num > 0: + if i + 1 > num > 0: break with zip_file.open(lemmafile) as file: html = str(file.read()) diff --git a/peret/providers/bts.py b/peret/providers/bts.py index 8ff55771..968d5ed1 100644 --- a/peret/providers/bts.py +++ b/peret/providers/bts.py @@ -135,27 +135,26 @@ def fill_in_missing_dateranges(entry_id: str, entry: dict, ths: dict) -> dict: ''' missing_dateranges = { - 'MXWX4WG43ZHI7D4RLTGK3IBGXY': ['-5500', '900'], # 9 = Datierungen - 'FKLXKTC5RJFSZCBDU5HWK6KHGU': ['-5500', '900'], # (unbekannt) - 'GTIHALKZWJFTNCLZ3ITXK7HBXA': ['-5500', '900'], # (unbestimmt) - 'DUVGWT7GSRCKDM5LFTGU6MZ3GY': ['-5500', '641'], # (Epochen und Dynastien) + 'MXWX4WG43ZHI7D4RLTGK3IBGXY': ['-5500', ' 900'], # 9 = Datierungen + 'FKLXKTC5RJFSZCBDU5HWK6KHGU': ['-5500', ' 900'], # (unbekannt) + 'GTIHALKZWJFTNCLZ3ITXK7HBXA': ['-5500', ' 900'], # (unbestimmt) + 'DUVGWT7GSRCKDM5LFTGU6MZ3GY': ['-5500', ' 641'], # (Epochen und Dynastien) '6YAAR2WRI5F6BLP6YMW3G67P6Q': ['-5500', '-5000'], # Neolithikum vor der Badari-Kultur 'FMNBFXWGA5C2TEXFRDXOGXBEPE': ['-5000', '-3900'], # Badari-Kultur 'P5F2WOP6YZGBHK5KCSCP2UXJHM': ['-3900', '-3650'], # Naqada I 'WLIRCHQ3DRF4ZOTIREDVCPKC5A': ['-3650', '-3300'], # Naqada II 'IPXSCTKV4REDHIXWTZWDXVXJWY': ['-3300', '-3151'], # Naqada III 'MM4QYACJOJCCLJWBD6VAX2FLKE': ['-2135', '-1794'], # Mittleres Reich - 'JS32JKX2CNG25GZ3B6MGYMDU4I': ['-1070', '-656'], # Dritte Zwischenzeit - 'HYYNMJRFTVFIHB7JUA6M2QW3LQ': [ '-332', '-30'], # Makedonen, Ptolemäer - 'D3R5CH5NZBDA7IZMCKKJPWYZKU': [ '-900', '-1'], # (Jahrhunderte v.Chr.) - 'FHZEINDCEJAOTHIVC35NYGMC2Q': [ '1', '900'], # (Jahrhunderte n.Chr.) + 'JS32JKX2CNG25GZ3B6MGYMDU4I': ['-1070', ' -656'], # Dritte Zwischenzeit + 'HYYNMJRFTVFIHB7JUA6M2QW3LQ': [' -332', ' -30'], # Makedonen, Ptolemäer + 'D3R5CH5NZBDA7IZMCKKJPWYZKU': [' -900', ' -1'], # (Jahrhunderte v.Chr.) + 'FHZEINDCEJAOTHIVC35NYGMC2Q': [' 1', ' 900'], # (Jahrhunderte n.Chr.) } if amendment := missing_dateranges.get(entry_id): entry['dates'] |= {'beginning': [amendment[0]], 'end': [amendment[1]]} return entry - def apply_functions( entry: dict, functions: List[Callable] = [get_translations] ) -> dict: