Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2455917pxb; Tue, 12 Oct 2021 07:03:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxm+tt476CcA6zKzwSrd+NN/RdAUTAtV6ka7MOQV+ixTCSp+e5BbY+ieAGS46L+9eAp4e+s X-Received: by 2002:a17:906:3891:: with SMTP id q17mr33888363ejd.220.1634047411859; Tue, 12 Oct 2021 07:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634047411; cv=none; d=google.com; s=arc-20160816; b=qPEjSO0yHfl6naHujfyGrBwE6HHCAsHDUjY6j3kFE9pPagPLwp5YfklCHTcQKKalKr g+JjOs0O8TvIQYhfM6H+pR2BoeIoz+8G9AbaF/bSC8Ys8F0Eub8qhkfyWcX7Eu7YerMr vakfmus7LlVcGs3VxEyY4czlz5rQx3cBmoSUqUisO4HmQA4i9IVFSGwFFDs2c/wVE8mX A/AC6AaEIBtrVefbl/DdbV4wsJSiV6XKKDc8Ftkp+/LVKTlgw0LBHhQhX3w7elxDssET 8+y+rj6cMuJm9qYERAaw7R+hdpHWV7pOH+vCpDlViZGd8cqZ7KJeGnh5HSan4jDd9xUn YOSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=J7gKAf3WwUYpejAwVqBlQgQDW9LHpW98tj6z0aYRyQs=; b=eiAPky9dF/+N3XAug9ooVUZ4HyWSYrUROFZY86EdWj7mnBkwsUk0ALSI0tjLCakK7z sDY0J9pt9iS/EnxJ1chYPBVrpQb4loNrKIU0nV6/E8ALk//qhv9bcgvyfNDuu0vPkO+5 onCtD4R6vdCgR3jTbpnJeNJP58EVVcOAmH6YBKqAvWZ9l7dVuLkX1EwYduQHr8mYI8a2 +qMCthdoMfktm6QDv6XpVontqxFh67QNPtlbHGArUasaM788qqPW43XKG6zdUlwsq6Is ETYn3EgMHPOLrCvvGR2jnJ2dcm6HTADVj4YjGJa1YVNTBOq2g6wf1rI3ij4463tHj4xG y+pg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b15si17250095edm.143.2021.10.12.07.03.02; Tue, 12 Oct 2021 07:03:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237127AbhJLN7r (ORCPT + 99 others); Tue, 12 Oct 2021 09:59:47 -0400 Received: from smtprelay0114.hostedemail.com ([216.40.44.114]:36592 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237132AbhJLN7f (ORCPT ); Tue, 12 Oct 2021 09:59:35 -0400 Received: from omf03.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 6DC6D182CED5B; Tue, 12 Oct 2021 13:57:31 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf03.hostedemail.com (Postfix) with ESMTPA id 7B27813D9B; Tue, 12 Oct 2021 13:57:30 +0000 (UTC) Message-ID: <307188c4a27dc488437e74d5f8980dfcad65ecbd.camel@perches.com> Subject: Re: [PATCH v5] checkpatch: get default codespell dictionary path from package location From: Joe Perches To: Peter Ujfalusi , apw@canonical.com Cc: dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com, linux-kernel@vger.kernel.org Date: Tue, 12 Oct 2021 06:57:28 -0700 In-Reply-To: <20211012112918.19166-1-peter.ujfalusi@linux.intel.com> References: <20211012112918.19166-1-peter.ujfalusi@linux.intel.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.89 X-Rspamd-Server: rspamout04 X-Rspamd-Queue-Id: 7B27813D9B X-Stat-Signature: zxmwxpf1i3oeuaug5iuqgk87m9oru66a X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+yidMOXpPusMV77e6+YUwDL63pQxdUkW4= X-HE-Tag: 1634047050-932530 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2021-10-12 at 14:29 +0300, Peter Ujfalusi wrote: > The standard location of dictionary.txt is under codespell's package, on > my machine atm (codespell 2.1, Artix Linux): > /usr/lib/python3.9/site-packages/codespell_lib/data/dictionary.txt > > Since we enable the codespell by default for SOF I have constant: > No codespell typos will be found - \ > file '/usr/share/codespell/dictionary.txt': No such file or directory > > The patch proposes to try to fix up the path following the recommendation > found here: > https://github.com/codespell-project/codespell/issues/1540 trivia: > @@ -325,9 +326,31 @@ GetOptions( > ? 'kconfig-prefix=s' => \${CONFIG_}, > ? 'h|help' => \$help, > ? 'version' => \$help > -) or help(1); > +) or $help = 2; > + > +my $python_codespell_dict = << "EOF"; Because you add a semicolon after "EOF" > +import os.path as op > +import codespell_lib > +codespell_dir = op.dirname(codespell_lib.__file__) > +codespell_file = op.join(codespell_dir, 'data', 'dictionary.txt') > +print(codespell_file, end='') > +EOF > +; this is an extra semicolon > +if ($user_codespellfile) { > + # Use the user provided codespell file unconditionally > + $codespellfile = $user_codespellfile; > +} else { > + # Try to find the codespell install location to use it as default path > + if (($codespell || $help) && which("codespell") ne "" && which("python") ne "") { and I would keep the my $python_codespell_dict definition local to this block. > + my $codespell_dict = `python3 -c "$python_codespell_dict" 2> /dev/null`; > + $codespellfile = $codespell_dict if (-e $codespell_dict); > + } > +} It's wrong to check which("python") and then exec `python3 ...`