[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210510171127.15056-1-dwaipayanray1@gmail.com>
Date: Mon, 10 May 2021 22:41:27 +0530
From: Dwaipayan Ray <dwaipayanray1@...il.com>
To: joe@...ches.com
Cc: linux-kernel@...r.kernel.org, lukas.bulwahn@...il.com,
Dwaipayan Ray <dwaipayanray1@...il.com>
Subject: [PATCH] checkpatch: auto detect codespell dictionary path
The codespell dictionary was moved from
`/usr/share/codespell/dictionary.txt` to data/dictionary.txt
under the codespell_lib installation directory.
Checkpatch still uses a default absolute path for it which will
no longer work on new codespell installations unless the path
is specified through --codespellfile.
Detect the codespell dictionary path dynamically during
runtime if the default path or the user provided dictionary
path does not exist.
Signed-off-by: Dwaipayan Ray <dwaipayanray1@...il.com>
---
scripts/checkpatch.pl | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 23697a6b1eaa..cc69d2c758a3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -889,6 +889,13 @@ if (open(my $spelling, '<', $spelling_file)) {
}
if ($codespell) {
+ if (! -e "$codespellfile" && which("python3") ne "") {
+ my $output = `python3 -c "import codespell_lib; print(codespell_lib.__file__, end='');" 2>/dev/null`;
+ my $dictionary_path = dirname($output) . "/data/dictionary.txt";
+ if (-e "$dictionary_path") {
+ $codespellfile = $dictionary_path;
+ }
+ }
if (open(my $spelling, '<', $codespellfile)) {
while (<$spelling>) {
my $line = $_;
--
2.28.0
Powered by blists - more mailing lists