From c303c149a01b8b9e27e82d72bb31e1eb2f1d9dc8 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 23 Oct 2021 16:43:22 +0200 Subject: [PATCH] Report files encoded as latin1 --- package_linter.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/package_linter.py b/package_linter.py index d17f1ad..00c016f 100755 --- a/package_linter.py +++ b/package_linter.py @@ -490,6 +490,16 @@ class App(TestSuite): if os.system("grep -I -qr 'REPLACEBYYOURAPP' %s 2>/dev/null" % self.path) == 0: yield Warning("You should replace all occurences of REPLACEBYYOURAPP.") + @test() + def bad_encoding(self): + + cmd = "file --mime-encoding $(find %s/ -type f) | grep 'iso-8859-1'" % self.path + bad_encoding_files = subprocess.check_output(cmd, shell=True).decode('utf-8').strip().split("\n") + for file_ in bad_encoding_files: + file_ = file_.split()[0] + yield Info("%s appears to be encoded as latin-1 / iso-8859-1. Please consider converting it to utf-8 to avoid funky issues. Something like 'iconv -f iso-8859-1 -t utf-8 SOURCE DEST' should do the trick." % file_) + + ####################################### # _ _ _ # # | | | | | | #