Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TagFix_Tree due to new column in wiki table #2389

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions plugins/TagFix_Tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ def _read_leaf_properties_table(self):
data = urlread(u"https://wiki.openstreetmap.org/w/index.php?title=Tag:natural%3Dtree/List_of_Species&action=raw", 1)
data = read_wiki_table(data)
species_map = {}
for row in data: # data: list of [species, species:wikidata, leaf_cycle, leaf_type]
for row in data: # data: list of [species, genus, species:wikidata, leaf_cycle, leaf_type]
this_species = {}
if row[2] in allowed_leaf_cycle:
this_species['leaf_cycle'] = row[2]
if row[3] in allowed_leaf_type:
this_species['leaf_type'] = row[3]
if row[1] in row[0]:
this_species['genus'] = row[1]
if row[3] in allowed_leaf_cycle:
this_species['leaf_cycle'] = row[3]
if row[4] in allowed_leaf_type:
this_species['leaf_type'] = row[4]
if len(this_species) > 0:
if len(row[1]) > 2 and row[1][0] == "Q":
this_species['species:wikidata'] = row[1]
if len(row[2]) > 2 and row[2][0] == "Q":
this_species['species:wikidata'] = row[2]
species_map[row[0]] = this_species
return species_map

Expand Down Expand Up @@ -74,7 +76,7 @@ def _check_leaf_properties(self, tags):
# and unclear difference between semi_evergreen and semi_deciduous, see #2224 first comment
expected_tags = {x: expected_tags[x] for x in filter(lambda x: x != "leaf_cycle", expected_tags)}

# The tags do not match with the data on the wiki. Don't check for wikidata (handled in item 3031)
# The tags do not match with the data on the wiki. Don't check for wikidata mismatches (handled in item 3031), but wikidata is still part of fix suggestions.
mismatches = set(filter(lambda t: t in tags and expected_tags[t] != tags[t] and t != "species:wikidata", expected_tags.keys()))
if len(mismatches) > 0:
err.append({
Expand Down
Loading