Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JKatzwinkel committed Oct 2, 2023
1 parent d2cdeed commit f958c34
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion peret/pre.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
14 changes: 9 additions & 5 deletions peret/proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@


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']}},
... '2': {'relations': {'rootOf': ['1']}}}
>>> 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():
Expand Down
2 changes: 1 addition & 1 deletion peret/providers/aed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
17 changes: 8 additions & 9 deletions peret/providers/bts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f958c34

Please sign in to comment.