Skip to content

Commit

Permalink
Fix TagFix_Tree due to new column in wiki table
Browse files Browse the repository at this point in the history
  • Loading branch information
Famlam authored and frodrigo committed Nov 16, 2024
1 parent fdd7399 commit 37b4785
Showing 1 changed file with 10 additions and 8 deletions.
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

0 comments on commit 37b4785

Please sign in to comment.