forked from osm-fr/osmose-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Source.py
92 lines (77 loc) · 3.8 KB
/
Source.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#-*- coding: utf-8 -*-
###########################################################################
## ##
## Copyrights Etienne Chové <[email protected]> 2010 ##
## Copyrights Frédéric Rodrigo 2011-2014 ##
## ##
## This program is free software: you can redistribute it and/or modify ##
## it under the terms of the GNU General Public License as published by ##
## the Free Software Foundation, either version 3 of the License, or ##
## (at your option) any later version. ##
## ##
## This program is distributed in the hope that it will be useful, ##
## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
## GNU General Public License for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
## ##
###########################################################################
from plugins.Plugin import Plugin
class Source(Plugin):
not_for = ["HT"] # Google made drone imagery for after-earthquake in Haiti
def init(self, logger):
Plugin.init(self, logger)
if self.father.config.options.get("project") != 'openstreetmap':
return False
self.errors[706] = self.def_class(item = 3020, level = 1, tags = ['source', 'fix:chair'],
title = T_('Illegal or incomplete source tag'),
detail = T_(
'''The `source` tag is incorrect. For example, an illegal source like
Google.'''),
fix = T_(
'''Correct the source and the location of the object if necessary. If the
source is illegal, promptly notify the contributor to remove
contributions.'''))
self.errors[707] = self.def_class(item = 2040, level = 3, tags = ['source', 'fix:chair'],
title = T_('Missing source tag'),
detail = T_(
'''An administrative boundary does not contain tag `source=*` sourcing
the origin.'''),
fix = T_(
'''If the limit comes from the French Cadastre, add the appropriate
`source=*`.'''))
def check(self, tags):
if u"source" not in tags and u"ref" not in tags:
return
for tag in (u"source", u"ref"):
if tag in tags:
value = tags[tag].lower()
if u"google" in value:
return {"class": 706, "subclass": 2, "text": {"en": u"Google {0}={1}".format(tag, value)}}
def node(self, data, tags):
return self.check(tags)
def way(self, data, tags, nds):
return self.check(tags)
def relation(self, data, tags, members):
return self.check(tags)
###########################################################################
from plugins.Plugin import TestPluginCommon
class Test(TestPluginCommon):
def test(self):
a = Source(None)
class _config:
options = {"country": "MD", "project": "openstreetmap"}
class father:
config = _config()
a.father = father()
a.init(None)
for d in [{u"name": u"Free"},
{u"source": u"Free"},
]:
assert not a.node(None, d), d
for d in [{u"source":u"google maps"}]:
self.check_err(a.node(None, d), d)
self.check_err(a.way(None, d, None), d)
self.check_err(a.relation(None, d, None), d)