From 7ab7d7a27bc29b37af3afa6dace4064a4d571102 Mon Sep 17 00:00:00 2001 From: Famlam Date: Sun, 27 Oct 2024 10:37:34 +0100 Subject: [PATCH] Whitelist uppercase PT infrastructure in Greece See #2368 --- plugins/Name_UpperCase.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/plugins/Name_UpperCase.py b/plugins/Name_UpperCase.py index a0d62fc35..0fc6b77f1 100644 --- a/plugins/Name_UpperCase.py +++ b/plugins/Name_UpperCase.py @@ -46,21 +46,26 @@ def init(self, logger): ) self.UpperTitleCase = re.compile(r".*[\p{Lu}\p{Lt}]{5,}") self.RomanNumber = re.compile(r".*[IVXCDLM]{5,}") + self.country = None if "country" in self.father.config.options: - country = self.father.config.options.get("country")[:2] - self.whitelist = set(UpperCase_WhiteList.get(country, [])) + self.country = self.father.config.options.get("country")[:2] + self.whitelist = set(UpperCase_WhiteList.get(self.country, [])) nsi_whitelist = set(filter(lambda name: self.UpperTitleCase.match(name) and not self.RomanNumber.match(name), - whitelist_from_nsi(country.lower()))) + whitelist_from_nsi(self.country.lower()))) self.whitelist.update(nsi_whitelist) else: self.whitelist = set() def node(self, data, tags): err = [] - if u"name" in tags: + if "name" in tags: + # Whitelist bus stops in Greece, see #2368 + if self.country and self.country == "GR" and "public_transport" in tags and tags["public_transport"] in ("stop_position", "platform", "station"): + return err + # first check if the name *might* match - if self.UpperTitleCase.match(tags[u"name"]) and not self.RomanNumber.match(tags[u"name"]): + if self.UpperTitleCase.match(tags["name"]) and not self.RomanNumber.match(tags["name"]): if not self.whitelist or not any(map(lambda whitelist: whitelist in tags["name"], self.whitelist)): err.append({"class": 803, "text": T_("Concerns tag: `{0}`", '='.join(['name', tags['name']])) }) else: @@ -102,3 +107,21 @@ class father: {u"name": u"ƻאᎯᚦ京"}, ]: assert not a.node(None, t), t + + def test_GR(self): + a = Name_UpperCase(None) + class _config: + options = {"country": "GR", "language": "el"} + class father: + config = _config() + a.father = father() + a.init(None) + for t in [{"name": u"ΠΛΑΤΕΙΑ ΕΛΕΥΘΕΡΙΑΣ"}, + {"name": "ABCDEFGHIJKLMNOPQRSTUVWXYZ"}, + ]: + self.check_err(a.node(None, t), t) + self.check_err(a.way(None, t, None), t) + + for t in [{"name": u"ΠΛΑΤΕΙΑ ΕΛΕΥΘΕΡΙΑΣ", "public_transport": "stop_position"}, + ]: + assert not a.node(None, t), t