Output Overpass query for problematic IDs

This commit is contained in:
Midgard 2022-12-18 22:39:35 +01:00
parent 6dff91ecbc
commit a9d5b983cd
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -29,6 +29,21 @@ def ids(elements):
def first(iterable, default=None):
return next(iter(iterable), default)
def overpass_query(wd_ids):
return f""" [out:json][timeout:25]; (
{overpass_selectors(wd_ids)}
); out body; >; out skel qt;"""
def overpass_selector(wd_id):
return ' nwr["wikidata"=' + wd_id + ']({{bbox}});\n nwr[~":wikidata$"~' + wd_id + ']({{bbox}});'
def overpass_selectors(wd_ids):
return "\n".join(overpass_selector(wd_id) for wd_id in wd_ids)
s = requests.Session()
data = json.load(sys.stdin)
@ -68,7 +83,11 @@ try:
finally:
print()
print()
print(f"Not found: {notfound}")
print(f"Redirects: {redirects}")
print()
if notfound:
print(f"Not found:")
print(overpass_query(notfound))
print()
if redirects:
print(f"Redirects: {redirects}")
print(overpass_query(redirects))
print()