[PATCH] scripts/checktransupdate.py: add support for scanning directory

19 views
Skip to first unread message

Haoyang LIU

unread,
Aug 10, 2025, 3:38:06 AMAug 10
to hust-os-ker...@googlegroups.com, Haoyang LIU
Origin script can only accept a file as parameter, this commit enables
it to scan a directory.

Usage example:
./scripts/checktransupdate.py Documentation/translations/zh_CN/dev-tools

Signed-off-by: Haoyang LIU <hli...@connect.ust.hk>
---
scripts/checktransupdate.py | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/scripts/checktransupdate.py b/scripts/checktransupdate.py
index e39529e46c3d..f974ec6f2826 100755
--- a/scripts/checktransupdate.py
+++ b/scripts/checktransupdate.py
@@ -13,6 +13,8 @@ The usage is as follows:
This will print all the files that need to be updated or translated in the zh_CN locale.
- ./scripts/checktransupdate.py Documentation/translations/zh_CN/dev-tools/testing-overview.rst
This will only print the status of the specified file.
+- ./scripts/checktransupdate.py Documentation/translations/zh_CN/dev-tools
+This will print all the files in the specified folder and its subfolders.

The output is something like:
Documentation/dev-tools/kfence.rst
@@ -21,6 +23,17 @@ No translation in the locale of zh_CN
Documentation/translations/zh_CN/dev-tools/testing-overview.rst
commit 42fb9cfd5b18 ("Documentation: dev-tools: Add link to RV docs")
1 commits needs resolving in total
+
+Documentation/translations/zh_CN/dev-tools/index.rst
+commit d5af79c05e93 ("Documentation: move dev-tools debugging files to process/debugging/")
+commit d5dc95836147 ("kbuild: Add Propeller configuration for kernel build")
+commit 315ad8780a12 ("kbuild: Add AutoFDO support for Clang build")
+3 commits needs resolving in total
+
+Documentation/translations/zh_CN/dev-tools/kcsan.rst
+commit b37221cc861d ("Documentation: kcsan: fix "Plain Accesses and Data Races" URL in kcsan.rst")
+commit 72ffee678f6f ("docs: update dev-tools/kcsan.rst url about KTSAN")
+2 commits needs resolving in total
"""

import os
@@ -131,7 +144,7 @@ def check_per_file(file_path):
opath = get_origin_path(file_path)

if not os.path.isfile(opath):
- logging.error("Cannot find the origin path for {file_path}")
+ logging.error(f"Cannot find the origin path for {file_path}")
return

o_from_head = get_latest_commit_from(opath, "HEAD")
@@ -293,6 +306,17 @@ def main():
if args.print_missing_translations:
logging.info(os.path.relpath(os.path.abspath(file), linux_path))
logging.info("No translation in the locale of %s\n", args.locale)
+ else:
+ # check if the files are directories or files
+ new_files = []
+ for file in files.copy():
+ if os.path.isfile(file):
+ new_files.append(file)
+ elif os.path.isdir(file):
+ # for directories, list all files in the directory and its subfolders
+ new_files.extend(list_files_with_excluding_folders(
+ file, [], "rst"))
+ files = new_files

files = list(map(lambda x: os.path.relpath(os.path.abspath(x), linux_path), files))

--
2.50.1

Dongliang Mu

unread,
Aug 10, 2025, 11:33:40 AMAug 10
to Haoyang LIU, hust-os-ker...@googlegroups.com, Haoyang LIU
Oops, good catch!

> return
>
> o_from_head = get_latest_commit_from(opath, "HEAD")
> @@ -293,6 +306,17 @@ def main():
> if args.print_missing_translations:
> logging.info(os.path.relpath(os.path.abspath(file), linux_path))
> logging.info("No translation in the locale of %s\n", args.locale)
> + else:
> + # check if the files are directories or files
> + new_files = []
> + for file in files.copy():
It seems this copy is no need since there is no modification during the
loop.

Haoyang LIU

unread,
Aug 10, 2025, 11:55:36 AMAug 10
to hust-os-ker...@googlegroups.com, Haoyang LIU
Origin script can only accept a file as parameter, this commit enables
it to scan a directory.

Usage example:
./scripts/checktransupdate.py Documentation/translations/zh_CN/dev-tools

Signed-off-by: Haoyang LIU <ttttur...@gmail.com>
---
scripts/checktransupdate.py | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/scripts/checktransupdate.py b/scripts/checktransupdate.py
index e39529e46c3d..0d197d036650 100755
return

o_from_head = get_latest_commit_from(opath, "HEAD")
@@ -293,6 +306,17 @@ def main():
if args.print_missing_translations:
logging.info(os.path.relpath(os.path.abspath(file), linux_path))
logging.info("No translation in the locale of %s\n", args.locale)
+ else:
+ # check if the files are directories or files
+ new_files = []
+ for file in files:
+ if os.path.isfile(file):
+ new_files.append(file)
+ elif os.path.isdir(file):
+ # for directories, list all files in the directory and its subfolders
+ new_files.extend(list_files_with_excluding_folders(
+ file, [], "rst"))
+ files = new_files

files = list(map(lambda x: os.path.relpath(os.path.abspath(x), linux_path), files))

--
2.50.1

Haoyang LIU

unread,
Aug 10, 2025, 12:17:38 PMAug 10
to Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, hust-os-ker...@googlegroups.com, Haoyang LIU, linux-...@vger.kernel.org, ll...@lists.linux.dev

Dongliang Mu

unread,
Aug 11, 2025, 2:15:42 AMAug 11
to Haoyang LIU, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, dz...@hust.edu.cn, Yanteng Si, Alex Shi, Jonathan Corbet, hust-os-ker...@googlegroups.com, linux-...@vger.kernel.org, ll...@lists.linux.dev, open list:DOCUMENTATION
+to Yanteng, Dongliang, Alex and Jon

+cc linux-doc mailing list

Dan Carpenter

unread,
Aug 11, 2025, 3:12:10 AMAug 11
to Haoyang LIU, hust-os-ker...@googlegroups.com, Haoyang LIU
On Sun, Aug 10, 2025 at 03:37:38PM +0800, Haoyang LIU wrote:
>
> import os
> @@ -131,7 +144,7 @@ def check_per_file(file_path):
> opath = get_origin_path(file_path)
>
> if not os.path.isfile(opath):
> - logging.error("Cannot find the origin path for {file_path}")
> + logging.error(f"Cannot find the origin path for {file_path}")

This line should be submitted as its own patch with a Fixes tag.

regards,
dan carpenter


Dan Carpenter

unread,
Aug 11, 2025, 3:18:48 AMAug 11
to Haoyang LIU, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, hust-os-ker...@googlegroups.com, linux-...@vger.kernel.org, ll...@lists.linux.dev
On Mon, Aug 11, 2025 at 12:17:30AM +0800, Haoyang LIU wrote:
>
> import os
> @@ -131,7 +144,7 @@ def check_per_file(file_path):
> opath = get_origin_path(file_path)
>
> if not os.path.isfile(opath):
> - logging.error("Cannot find the origin path for {file_path}")
> + logging.error(f"Cannot find the origin path for {file_path}")

Send this as a separate patch with a Fixes tag.
Fixes: 63e96ce050e5 ("scripts: fix all issues reported by pylint")

Ideally, pylint should be modified to complain about this or something...
I have a script for kernel patches which checks these kinds of mechanical
changes and someone could make a similar script which checks pylint
changes. https://github.com/error27/rename_rev

regards,
dan carpenter

Haoyang LIU

unread,
Aug 11, 2025, 1:01:00 PMAug 11
to Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, hust-os-ker...@googlegroups.com, Haoyang LIU, linux-...@vger.kernel.org, ll...@lists.linux.dev
Origin script can only accept a file as parameter, this commit enables
it to scan a directory.

Usage example:
./scripts/checktransupdate.py Documentation/translations/zh_CN/dev-tools

Signed-off-by: Haoyang LIU <ttttur...@gmail.com>
---
V1 -> V2: remove the fix of missing "f" in f-string and make it a new patch

scripts/checktransupdate.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/scripts/checktransupdate.py b/scripts/checktransupdate.py
index e39529e46c3d..01271fb30cbe 100755
@@ -293,6 +306,17 @@ def main():
if args.print_missing_translations:
logging.info(os.path.relpath(os.path.abspath(file), linux_path))
logging.info("No translation in the locale of %s\n", args.locale)
+ else:
+ # check if the files are directories or files
+ new_files = []
+ for file in files:
+ if os.path.isfile(file):
+ new_files.append(file)
+ elif os.path.isdir(file):
+ # for directories, list all files in the directory and its subfolders
+ new_files.extend(list_files_with_excluding_folders(
+ file, [], "rst"))
+ files = new_files

files = list(map(lambda x: os.path.relpath(os.path.abspath(x), linux_path), files))

--
2.50.1

Nathan Chancellor

unread,
Aug 11, 2025, 5:24:54 PMAug 11
to Haoyang LIU, Dongliang Mu, Yanteng Si, Alex Shi, Jonathan Corbet, Nick Desaulniers, Bill Wendling, Justin Stitt, hust-os-ker...@googlegroups.com, linux-...@vger.kernel.org, ll...@lists.linux.dev, linu...@vger.kernel.org
Hi Haoyang,

On Tue, Aug 12, 2025 at 01:00:50AM +0800, Haoyang LIU wrote:
> Origin script can only accept a file as parameter, this commit enables
> it to scan a directory.
>
> Usage example:
> ./scripts/checktransupdate.py Documentation/translations/zh_CN/dev-tools
>
> Signed-off-by: Haoyang LIU <ttttur...@gmail.com>
> ---
>
> V1 -> V2: remove the fix of missing "f" in f-string and make it a new patch
>
> scripts/checktransupdate.py | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)

Thanks for the update. While this seems reasonable to me from a purely
surface level glance over the actual Python, I have added the
Documentation folks that Dongliang added from the previous thread, who
really own and maintain this file (the original patch is at [1]). Please
include them in future revisions should they be necessary. It would
probably be good for something like this to be applied?

diff --git a/MAINTAINERS b/MAINTAINERS
index fe168477caa4..b7e3a8c8832e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7302,6 +7302,7 @@ P: Documentation/doc-guide/maintainer-profile.rst
T: git git://git.lwn.net/linux.git docs-next
F: Documentation/
F: scripts/check-variable-fonts.sh
+F: scripts/checktransupdate.py
F: scripts/documentation-file-ref-check
F: scripts/get_abi.py
F: scripts/kernel-doc*

[1]: https://lore.kernel.org/20250811170050.949...@gmail.com/

Cheers,
Nathan

Dongliang Mu

unread,
Aug 12, 2025, 12:35:47 AMAug 12
to Dan Carpenter, Haoyang LIU, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, hust-os-ker...@googlegroups.com, linux-...@vger.kernel.org, ll...@lists.linux.dev
Yes, this seems really wired. We have a project - Linux Kernel Patch
Statistic among Universities[1]. In one PR[2], Haoyang also found a
quote string issue.

Interestingly, this PR is trying to fix issues raised by pylint.


[1] https://github.com/hust-open-atom-club/linux-edu-rank

[2] https://github.com/hust-open-atom-club/linux-edu-rank/pull/45


>
> regards,
> dan carpenter
>

Dongliang Mu

unread,
Aug 12, 2025, 1:11:48 AMAug 12
to Nathan Chancellor, Haoyang LIU, Yanteng Si, Alex Shi, Jonathan Corbet, Nick Desaulniers, Bill Wendling, Justin Stitt, hust-os-ker...@googlegroups.com, linux-...@vger.kernel.org, ll...@lists.linux.dev, linu...@vger.kernel.org

On 8/12/25 5:24 AM, 'Nathan Chancellor' via HUST OS Kernel Contribution
wrote:
> Hi Haoyang,
>
> On Tue, Aug 12, 2025 at 01:00:50AM +0800, Haoyang LIU wrote:
>> Origin script can only accept a file as parameter, this commit enables
>> it to scan a directory.
>>
>> Usage example:
>> ./scripts/checktransupdate.py Documentation/translations/zh_CN/dev-tools
>>
>> Signed-off-by: Haoyang LIU <ttttur...@gmail.com>
>> ---
>>
>> V1 -> V2: remove the fix of missing "f" in f-string and make it a new patch
>>
>> scripts/checktransupdate.py | 24 ++++++++++++++++++++++++
>> 1 file changed, 24 insertions(+)
> Thanks for the update. While this seems reasonable to me from a purely
> surface level glance over the actual Python, I have added the
> Documentation folks that Dongliang added from the previous thread, who
> really own and maintain this file (the original patch is at [1]). Please
> include them in future revisions should they be necessary. It would
> probably be good for something like this to be applied?

Thanks for the suggestion. I've submitted a patch[1].

[1]
https://lore.kernel.org/linux-doc/20250812050711....@hust.edu.cn/

Haoyang LIU

unread,
Aug 12, 2025, 6:09:55 AMAug 12
to Nathan Chancellor, Dongliang Mu, Yanteng Si, Alex Shi, Jonathan Corbet, Nick Desaulniers, Bill Wendling, Justin Stitt, hust-os-ker...@googlegroups.com, linux-...@vger.kernel.org, ll...@lists.linux.dev, linu...@vger.kernel.org


> On 12 Aug 2025, at 05:24, Nathan Chancellor <nat...@kernel.org> wrote:
>
> Hi Haoyang,
>
> On Tue, Aug 12, 2025 at 01:00:50AM +0800, Haoyang LIU wrote:
>> Origin script can only accept a file as parameter, this commit enables
>> it to scan a directory.
>>
>> Usage example:
>> ./scripts/checktransupdate.py Documentation/translations/zh_CN/dev-tools
>>
>> Signed-off-by: Haoyang LIU <ttttur...@gmail.com>
>> ---
>>
>> V1 -> V2: remove the fix of missing "f" in f-string and make it a new patch
>>
>> scripts/checktransupdate.py | 24 ++++++++++++++++++++++++
>> 1 file changed, 24 insertions(+)
>
> Thanks for the update. While this seems reasonable to me from a purely
> surface level glance over the actual Python, I have added the
> Documentation folks that Dongliang added from the previous thread, who
> really own and maintain this file (the original patch is at [1]). Please
> include them in future revisions should they be necessary. It would
> probably be good for something like this to be applied?
Hi Nathan
That makes sense. My V1 patch also missed Dongliang Mu and the other maintainers. Thanks for pointing it out.

Sincerely,
Haoyang
Reply all
Reply to author
Forward
0 new messages