{"action":"created","comment":{"url":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/comments/85642552","pull_request_review_id":6349389,"id":85642552,"diff_hunk":"@@ -26,20 +26,32 @@ class TagFix_Housenumber(Plugin):\n \n     def init(self, logger):\n         Plugin.init(self, logger)\n-        self.errors[10] = { \"item\": 2060, \"level\": 3, \"tag\": [\"addr\", \"fix:survey\"], \"desc\": T_(u\"addr:housenumber does not start by a number\") }\n-        self.errors[14] = { \"item\": 2060, \"level\": 3, \"tag\": [\"addr\", \"fix:chair\"], \"desc\": T_(u\"Invalid tag on interpolation way\") }\n-        self.errors[15] = { \"item\": 2060, \"level\": 3, \"tag\": [\"addr\", \"fix:chair\"], \"desc\": T_(u\"Invalid addr:interpolation or addr:inclusion value\") }\n-        self.CountryCZ = self.father.config.options.get(\"country\") == \"CZ\"\n-        self.CountryHousenumberWithoutNumber = self.father.config.options.get(\"country\") in ('RU', 'BG')\n+        self.errors[10] = {\"item\": 2060, \"level\": 3, \"tag\": [\"addr\", \"fix:survey\"], \"desc\": T_(u\"addr:housenumber does not start by a number\")}\n+        self.errors[14] = {\"item\": 2060, \"level\": 3, \"tag\": [\"addr\", \"fix:chair\"], \"desc\": T_(u\"Invalid tag on interpolation way\")}\n+        self.errors[15] = {\"item\": 2060, \"level\": 3, \"tag\": [\"addr\", \"fix:chair\"], \"desc\": T_(u\"Invalid addr:interpolation or addr:inclusion value\")}\n+        self.Country = self.father.config.options.get(\"country\")\n+        import re\n+        from collections import defaultdict\n+\n+        # By default, validate that house number starts with 1-9\n+        housenumberRegexByCountry = defaultdict(re.compile(\"^[1-9]\"))\n+\n+        # More specific rules by country\n+\n+        # From open data from cantons Zurich and Bern. See also https://github.com/ltog/osmi-addresses/issues/93\n+        housenumberRegexByCountry[\"CH\"] = re.compile(\"^[1-9][0-9]{0,3}( ?[a-zA-Z])?$\")\n+\n+        # https://wiki.openstreetmap.org/wiki/Cs:WikiProject_Czech_Republic/Address_system\n+        housenumberRegexByCountry[\"CZ\"] = re.compile(\"^(ev\\.)?[1-9]\")\n+\n+        # From open data from CACLR, https://data.public.lu/en/datasets/registre-national-des-localites-et-des-rues/\n+        housenumberRegexByCountry[\"LU\"] = re.compile(\"^[1-9][0-9]{0,3}([A-Z]){0,3}(-[1-9][0-9]{0,3}([A-Z]){0,3})?$\")\n \n     def node(self, data, tags):\n         err = []\n-        if self.CountryHousenumberWithoutNumber:\n-          return []\n-        if \"addr:housenumber\" in tags and (len(tags[\"addr:housenumber\"]) == 0 or not (\n-            tags[\"addr:housenumber\"][0].isdigit() or\n-            (self.CountryCZ and tags[\"addr:housenumber\"].startswith('ev.') and tags[\"addr:housenumber\"][3].isdigit())\n-            )):\n+        if self.Country in ('RU', 'BG'):  # Countries with no house numbers\n+            return []","path":"plugins/TagFix_Housenumber.py","position":null,"original_position":39,"commit_id":"f96b508211d754d4358eb0c30e6b7834da919836","original_commit_id":"55ccbe7488c908f4e251c49c1c9ead7aa792d7b6","user":{"login":"grischard","id":1556567,"avatar_url":"https://avatars.githubusercontent.com/u/1556567?v=3","gravatar_id":"","url":"https://api.github.com/users/grischard","html_url":"https://github.com/grischard","followers_url":"https://api.github.com/users/grischard/followers","following_url":"https://api.github.com/users/grischard/following{/other_user}","gists_url":"https://api.github.com/users/grischard/gists{/gist_id}","starred_url":"https://api.github.com/users/grischard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grischard/subscriptions","organizations_url":"https://api.github.com/users/grischard/orgs","repos_url":"https://api.github.com/users/grischard/repos","events_url":"https://api.github.com/users/grischard/events{/privacy}","received_events_url":"https://api.github.com/users/grischard/received_events","type":"User","site_admin":false},"body":"I've used `not_for` to replace this check.","created_at":"2016-10-29T15:29:46Z","updated_at":"2016-10-29T15:30:23Z","html_url":"https://github.com/osm-fr/osmose-backend/pull/156#discussion_r85642552","pull_request_url":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/156","_links":{"self":{"href":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/comments/85642552"},"html":{"href":"https://github.com/osm-fr/osmose-backend/pull/156#discussion_r85642552"},"pull_request":{"href":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/156"}}},"pull_request":{"url":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/156","id":91489658,"html_url":"https://github.com/osm-fr/osmose-backend/pull/156","diff_url":"https://github.com/osm-fr/osmose-backend/pull/156.diff","patch_url":"https://github.com/osm-fr/osmose-backend/pull/156.patch","issue_url":"https://api.github.com/repos/osm-fr/osmose-backend/issues/156","number":156,"state":"open","locked":false,"title":"Housenumber check for LU and CH","user":{"login":"grischard","id":1556567,"avatar_url":"https://avatars.githubusercontent.com/u/1556567?v=3","gravatar_id":"","url":"https://api.github.com/users/grischard","html_url":"https://github.com/grischard","followers_url":"https://api.github.com/users/grischard/followers","following_url":"https://api.github.com/users/grischard/following{/other_user}","gists_url":"https://api.github.com/users/grischard/gists{/gist_id}","starred_url":"https://api.github.com/users/grischard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grischard/subscriptions","organizations_url":"https://api.github.com/users/grischard/orgs","repos_url":"https://api.github.com/users/grischard/repos","events_url":"https://api.github.com/users/grischard/events{/privacy}","received_events_url":"https://api.github.com/users/grischard/received_events","type":"User","site_admin":false},"body":"Hello,\r\n\r\nThis adds regex checks for house numbers in two countries, and refactors the code to make the addition of new countries easier.\r\n\r\nAdditionally, this cleans up the plugin's code according to PEP8.\r\n\r\n@ltog helped out with the original idea, the implementation, and the Swiss regex.\r\n\r\nThis is my first real PR to Osmose, please be critical and generous in your feedback :)","created_at":"2016-10-29T13:49:12Z","updated_at":"2016-10-29T15:30:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4200ea6756da809a3ad223173e4a1783c6cbf37c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/156/commits","review_comments_url":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/156/comments","review_comment_url":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/osm-fr/osmose-backend/issues/156/comments","statuses_url":"https://api.github.com/repos/osm-fr/osmose-backend/statuses/f96b508211d754d4358eb0c30e6b7834da919836","head":{"label":"grischard:housenumber-check","ref":"housenumber-check","sha":"f96b508211d754d4358eb0c30e6b7834da919836","user":{"login":"grischard","id":1556567,"avatar_url":"https://avatars.githubusercontent.com/u/1556567?v=3","gravatar_id":"","url":"https://api.github.com/users/grischard","html_url":"https://github.com/grischard","followers_url":"https://api.github.com/users/grischard/followers","following_url":"https://api.github.com/users/grischard/following{/other_user}","gists_url":"https://api.github.com/users/grischard/gists{/gist_id}","starred_url":"https://api.github.com/users/grischard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grischard/subscriptions","organizations_url":"https://api.github.com/users/grischard/orgs","repos_url":"https://api.github.com/users/grischard/repos","events_url":"https://api.github.com/users/grischard/events{/privacy}","received_events_url":"https://api.github.com/users/grischard/received_events","type":"User","site_admin":false},"repo":{"id":72284405,"name":"osmose-backend","full_name":"grischard/osmose-backend","owner":{"login":"grischard","id":1556567,"avatar_url":"https://avatars.githubusercontent.com/u/1556567?v=3","gravatar_id":"","url":"https://api.github.com/users/grischard","html_url":"https://github.com/grischard","followers_url":"https://api.github.com/users/grischard/followers","following_url":"https://api.github.com/users/grischard/following{/other_user}","gists_url":"https://api.github.com/users/grischard/gists{/gist_id}","starred_url":"https://api.github.com/users/grischard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grischard/subscriptions","organizations_url":"https://api.github.com/users/grischard/orgs","repos_url":"https://api.github.com/users/grischard/repos","events_url":"https://api.github.com/users/grischard/events{/privacy}","received_events_url":"https://api.github.com/users/grischard/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/grischard/osmose-backend","description":"Part of osmose that runs the analysis, and send the results to the frontend.","fork":true,"url":"https://api.github.com/repos/grischard/osmose-backend","forks_url":"https://api.github.com/repos/grischard/osmose-backend/forks","keys_url":"https://api.github.com/repos/grischard/osmose-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grischard/osmose-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grischard/osmose-backend/teams","hooks_url":"https://api.github.com/repos/grischard/osmose-backend/hooks","issue_events_url":"https://api.github.com/repos/grischard/osmose-backend/issues/events{/number}","events_url":"https://api.github.com/repos/grischard/osmose-backend/events","assignees_url":"https://api.github.com/repos/grischard/osmose-backend/assignees{/user}","branches_url":"https://api.github.com/repos/grischard/osmose-backend/branches{/branch}","tags_url":"https://api.github.com/repos/grischard/osmose-backend/tags","blobs_url":"https://api.github.com/repos/grischard/osmose-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grischard/osmose-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grischard/osmose-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/grischard/osmose-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grischard/osmose-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/grischard/osmose-backend/languages","stargazers_url":"https://api.github.com/repos/grischard/osmose-backend/stargazers","contributors_url":"https://api.github.com/repos/grischard/osmose-backend/contributors","subscribers_url":"https://api.github.com/repos/grischard/osmose-backend/subscribers","subscription_url":"https://api.github.com/repos/grischard/osmose-backend/subscription","commits_url":"https://api.github.com/repos/grischard/osmose-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/grischard/osmose-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/grischard/osmose-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/grischard/osmose-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/grischard/osmose-backend/contents/{+path}","compare_url":"https://api.github.com/repos/grischard/osmose-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grischard/osmose-backend/merges","archive_url":"https://api.github.com/repos/grischard/osmose-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grischard/osmose-backend/downloads","issues_url":"https://api.github.com/repos/grischard/osmose-backend/issues{/number}","pulls_url":"https://api.github.com/repos/grischard/osmose-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/grischard/osmose-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/grischard/osmose-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grischard/osmose-backend/labels{/name}","releases_url":"https://api.github.com/repos/grischard/osmose-backend/releases{/id}","deployments_url":"https://api.github.com/repos/grischard/osmose-backend/deployments","created_at":"2016-10-29T12:48:42Z","updated_at":"2016-10-29T12:48:44Z","pushed_at":"2016-10-29T15:27:36Z","git_url":"git://github.com/grischard/osmose-backend.git","ssh_url":"git@github.com:grischard/osmose-backend.git","clone_url":"https://github.com/grischard/osmose-backend.git","svn_url":"https://github.com/grischard/osmose-backend","homepage":null,"size":92393,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"osm-fr:master","ref":"master","sha":"cc16ba2b265b926858f505beb060ab4f1e749ab0","user":{"login":"osm-fr","id":3309327,"avatar_url":"https://avatars.githubusercontent.com/u/3309327?v=3","gravatar_id":"","url":"https://api.github.com/users/osm-fr","html_url":"https://github.com/osm-fr","followers_url":"https://api.github.com/users/osm-fr/followers","following_url":"https://api.github.com/users/osm-fr/following{/other_user}","gists_url":"https://api.github.com/users/osm-fr/gists{/gist_id}","starred_url":"https://api.github.com/users/osm-fr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osm-fr/subscriptions","organizations_url":"https://api.github.com/users/osm-fr/orgs","repos_url":"https://api.github.com/users/osm-fr/repos","events_url":"https://api.github.com/users/osm-fr/events{/privacy}","received_events_url":"https://api.github.com/users/osm-fr/received_events","type":"Organization","site_admin":false},"repo":{"id":7705170,"name":"osmose-backend","full_name":"osm-fr/osmose-backend","owner":{"login":"osm-fr","id":3309327,"avatar_url":"https://avatars.githubusercontent.com/u/3309327?v=3","gravatar_id":"","url":"https://api.github.com/users/osm-fr","html_url":"https://github.com/osm-fr","followers_url":"https://api.github.com/users/osm-fr/followers","following_url":"https://api.github.com/users/osm-fr/following{/other_user}","gists_url":"https://api.github.com/users/osm-fr/gists{/gist_id}","starred_url":"https://api.github.com/users/osm-fr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osm-fr/subscriptions","organizations_url":"https://api.github.com/users/osm-fr/orgs","repos_url":"https://api.github.com/users/osm-fr/repos","events_url":"https://api.github.com/users/osm-fr/events{/privacy}","received_events_url":"https://api.github.com/users/osm-fr/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/osm-fr/osmose-backend","description":"Part of osmose that runs the analysis, and send the results to the frontend.","fork":false,"url":"https://api.github.com/repos/osm-fr/osmose-backend","forks_url":"https://api.github.com/repos/osm-fr/osmose-backend/forks","keys_url":"https://api.github.com/repos/osm-fr/osmose-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/osm-fr/osmose-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/osm-fr/osmose-backend/teams","hooks_url":"https://api.github.com/repos/osm-fr/osmose-backend/hooks","issue_events_url":"https://api.github.com/repos/osm-fr/osmose-backend/issues/events{/number}","events_url":"https://api.github.com/repos/osm-fr/osmose-backend/events","assignees_url":"https://api.github.com/repos/osm-fr/osmose-backend/assignees{/user}","branches_url":"https://api.github.com/repos/osm-fr/osmose-backend/branches{/branch}","tags_url":"https://api.github.com/repos/osm-fr/osmose-backend/tags","blobs_url":"https://api.github.com/repos/osm-fr/osmose-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/osm-fr/osmose-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/osm-fr/osmose-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/osm-fr/osmose-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/osm-fr/osmose-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/osm-fr/osmose-backend/languages","stargazers_url":"https://api.github.com/repos/osm-fr/osmose-backend/stargazers","contributors_url":"https://api.github.com/repos/osm-fr/osmose-backend/contributors","subscribers_url":"https://api.github.com/repos/osm-fr/osmose-backend/subscribers","subscription_url":"https://api.github.com/repos/osm-fr/osmose-backend/subscription","commits_url":"https://api.github.com/repos/osm-fr/osmose-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/osm-fr/osmose-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/osm-fr/osmose-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/osm-fr/osmose-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/osm-fr/osmose-backend/contents/{+path}","compare_url":"https://api.github.com/repos/osm-fr/osmose-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/osm-fr/osmose-backend/merges","archive_url":"https://api.github.com/repos/osm-fr/osmose-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/osm-fr/osmose-backend/downloads","issues_url":"https://api.github.com/repos/osm-fr/osmose-backend/issues{/number}","pulls_url":"https://api.github.com/repos/osm-fr/osmose-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/osm-fr/osmose-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/osm-fr/osmose-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/osm-fr/osmose-backend/labels{/name}","releases_url":"https://api.github.com/repos/osm-fr/osmose-backend/releases{/id}","deployments_url":"https://api.github.com/repos/osm-fr/osmose-backend/deployments","created_at":"2013-01-19T16:01:41Z","updated_at":"2016-10-28T20:18:56Z","pushed_at":"2016-10-29T15:27:37Z","git_url":"git://github.com/osm-fr/osmose-backend.git","ssh_url":"git@github.com:osm-fr/osmose-backend.git","clone_url":"https://github.com/osm-fr/osmose-backend.git","svn_url":"https://github.com/osm-fr/osmose-backend","homepage":null,"size":92414,"stargazers_count":9,"watchers_count":9,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":28,"forks":15,"open_issues":28,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/156"},"html":{"href":"https://github.com/osm-fr/osmose-backend/pull/156"},"issue":{"href":"https://api.github.com/repos/osm-fr/osmose-backend/issues/156"},"comments":{"href":"https://api.github.com/repos/osm-fr/osmose-backend/issues/156/comments"},"review_comments":{"href":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/156/comments"},"review_comment":{"href":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/osm-fr/osmose-backend/pulls/156/commits"},"statuses":{"href":"https://api.github.com/repos/osm-fr/osmose-backend/statuses/f96b508211d754d4358eb0c30e6b7834da919836"}}}}
{"actor":{"display_login":"grischard"}}