Skip to content

Commit 37b4785

Browse files
Famlamfrodrigo
authored andcommitted
Fix TagFix_Tree due to new column in wiki table
1 parent fdd7399 commit 37b4785

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

plugins/TagFix_Tree.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ def _read_leaf_properties_table(self):
3737
data = urlread(u"https://wiki.openstreetmap.org/w/index.php?title=Tag:natural%3Dtree/List_of_Species&action=raw", 1)
3838
data = read_wiki_table(data)
3939
species_map = {}
40-
for row in data: # data: list of [species, species:wikidata, leaf_cycle, leaf_type]
40+
for row in data: # data: list of [species, genus, species:wikidata, leaf_cycle, leaf_type]
4141
this_species = {}
42-
if row[2] in allowed_leaf_cycle:
43-
this_species['leaf_cycle'] = row[2]
44-
if row[3] in allowed_leaf_type:
45-
this_species['leaf_type'] = row[3]
42+
if row[1] in row[0]:
43+
this_species['genus'] = row[1]
44+
if row[3] in allowed_leaf_cycle:
45+
this_species['leaf_cycle'] = row[3]
46+
if row[4] in allowed_leaf_type:
47+
this_species['leaf_type'] = row[4]
4648
if len(this_species) > 0:
47-
if len(row[1]) > 2 and row[1][0] == "Q":
48-
this_species['species:wikidata'] = row[1]
49+
if len(row[2]) > 2 and row[2][0] == "Q":
50+
this_species['species:wikidata'] = row[2]
4951
species_map[row[0]] = this_species
5052
return species_map
5153

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

77-
# The tags do not match with the data on the wiki. Don't check for wikidata (handled in item 3031)
79+
# 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.
7880
mismatches = set(filter(lambda t: t in tags and expected_tags[t] != tags[t] and t != "species:wikidata", expected_tags.keys()))
7981
if len(mismatches) > 0:
8082
err.append({

0 commit comments

Comments
 (0)