utils/check-package: warn about utf-8 characters in .mk files

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Tested-by: Titouan Christophe <titouan.christophe@railnova.eu>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Peter Seiderer 2019-05-08 19:34:27 +02:00 committed by Thomas Petazzoni
parent dff08793ee
commit 8e352c32b0
2 changed files with 14 additions and 0 deletions

View File

@ -52,3 +52,16 @@ class TrailingSpace(_CheckFunction):
return ["{}:{}: line contains trailing whitespace" return ["{}:{}: line contains trailing whitespace"
.format(self.filename, lineno), .format(self.filename, lineno),
text] text]
class Utf8Characters(_CheckFunction):
def is_ascii(self, s):
try:
return all(ord(c) < 128 for c in s)
except TypeError:
return False
def check_line(self, lineno, text):
if not self.is_ascii(text):
return ["{}:{}: line contains UTF-8 characters"
.format(self.filename, lineno),
text]

View File

@ -11,6 +11,7 @@ from checkpackagelib.lib import ConsecutiveEmptyLines # noqa: F401
from checkpackagelib.lib import EmptyLastLine # noqa: F401 from checkpackagelib.lib import EmptyLastLine # noqa: F401
from checkpackagelib.lib import NewlineAtEof # noqa: F401 from checkpackagelib.lib import NewlineAtEof # noqa: F401
from checkpackagelib.lib import TrailingSpace # noqa: F401 from checkpackagelib.lib import TrailingSpace # noqa: F401
from checkpackagelib.lib import Utf8Characters # noqa: F401
# used in more than one check # used in more than one check
start_conditional = ["ifdef", "ifeq", "ifndef", "ifneq"] start_conditional = ["ifdef", "ifeq", "ifndef", "ifneq"]