Skip to content

Commit 867b463

Browse files
Famlamfrodrigo
authored andcommitted
Do not warn on newlines in values
- Keep the warning on keys - Keep the warning for other "control" characters (like bell, backspace, ...) Also remove the newline from the example, and fix a few typos
1 parent 56487a5 commit 867b463

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

plugins/Name_Script.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Name_Script(Plugin):
3535
def init(self, logger):
3636
Plugin.init(self, logger)
3737
self.errors[50701] = self.def_class(item = 5070, level = 2, tags = ['name', 'fix:chair'],
38-
title = T_('Some value chars does not match the language charset'),
38+
title = T_("Some characters don't match the language charset"),
3939
detail = T_(
4040
'''Words are not written in the appropriate alphabet of the
4141
language.'''),
@@ -46,10 +46,9 @@ def init(self, logger):
4646
untranslated name) or `name:en=Peace` (translated) or `name:ar=سلام`
4747
(original).'''))
4848
self.errors[50702] = self.def_class(item = 5070, level = 2, tags = ['name', 'fix:chair'],
49-
title = T_('Non printable char'),
49+
title = T_('Non-printable character'),
5050
detail = T_(
51-
'''A non-printable character such as linefeed (0x000a) has been
52-
used.'''),
51+
'''A non-printable character has been used.'''),
5352
fix = T_(
5453
'''Remove the character.'''))
5554
self.errors[50703] = self.def_class(item = 5070, level = 2, tags = ['name', 'fix:chair'],
@@ -130,7 +129,7 @@ def node(self, data, tags):
130129
err.append({"class": 50702, "subclass": 0 + stablehash64(key), "text": T_("\"{0}\" unexpected non printable char ({1}, 0x{2:04x}) in key at position {3}", key, unicodedata.name(m.group(0), ''), ord(m.group(0)), m.start() + 1)})
131130
break
132131

133-
m = self.non_printable.search(value)
132+
m = self.non_printable.search(value.replace('\n', ' '))
134133
if m:
135134
err.append({"class": 50702, "subclass": 1 + stablehash64(key), "text": T_("\"{0}\"=\"{1}\" unexpected non printable char ({2}, 0x{3:04x}) in value at position {4}", key, value, unicodedata.name(m.group(0), ''), ord(m.group(0)), m.start() + 1)})
136135
break
@@ -229,10 +228,13 @@ class father:
229228
a.father = father()
230229
a.init(None)
231230

232-
assert not a.node(None, {u"name": u"test ь"})
233-
assert not a.node(None, {u"name": u"Sacré-Cœur"})
231+
assert not a.node(None, {"name": u"test ь"})
232+
assert not a.node(None, {"name": u"Sacré-Cœur"})
234233

235-
self.check_err(a.node(None, {u"name:uk": u"Sacré-Cœur"}))
234+
assert not a.node(None, {"inscription": "Statue build in celebration of\nOsmose and OSM"})
235+
236+
self.check_err(a.node(None, {"name:uk": u"Sacré-Cœur"}))
237+
self.check_err(a.node(None, {"inscription": "Special bell character \a"}))
236238

237239
def test_NL(self):
238240
a = Name_Script(None)

0 commit comments

Comments
 (0)