Pylint reports many coding style issues of scripts/checktransupdate.py
This patch fixes most issues with the following contents:
- add or revise comments for all functions
- use format string suggested by python
Signed-off-by: Dongliang Mu <[email protected]>
---
scripts/checktransupdate.py | 55 ++++++++++++++++---------------------
1 file changed, 24 insertions(+), 31 deletions(-)
diff --git a/scripts/checktransupdate.py b/scripts/checktransupdate.py
index 5a0fc99e3f93..70a5dab1a17b 100755
--- a/scripts/checktransupdate.py
+++ b/scripts/checktransupdate.py
@@ -4,19 +4,9 @@
"""
This script helps track the translation status of the documentation
in different locales, e.g., zh_CN. More specially, it uses `git log`
-commit to find the latest english commit from the translation commit
-(order by author date) and the latest english commits from HEAD. If
+command to find the latest English commit from the translation commit
+(order by author date) and the latest English commits from HEAD. If
differences occur, report the file and commits that need to be updated.
-
-The usage is as follows:
-- ./scripts/checktransupdate.py -l zh_CN
-This will print all the files that need to be updated 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.
-
-The output is something like:
-Documentation/translations/zh_CN/dev-tools/testing-overview.rst (1 commits)
-commit 42fb9cfd5b18 ("Documentation: dev-tools: Add link to RV docs")
"""
import os
@@ -29,12 +19,14 @@ flag_debug = False
def dprint(*args, **kwargs):
+ """Print debug information if the debug flag is set"""
if flag_debug:
print("[DEBUG] ", end="")
print(*args, **kwargs)
def get_origin_path(file_path):
+ """Get the origin path from the translation path"""
paths = file_path.split("/")
tidx = paths.index("translations")
opaths = paths[:tidx]
@@ -43,9 +35,8 @@ def get_origin_path(file_path):
def get_latest_commit_from(file_path, commit):
- command = "git log --pretty=format:%H%n%aD%n%cD%n%n%B {} -1 -- {}".format(
- commit, file_path
- )
+ """Get the latest commit from the specified commit for the specified file"""
+ command = f"git log --pretty=format:%H%n%aD%n%cD%n%n%B {commit} -1 -- {file_path}"
dprint(command)
pipe = os.popen(command)
result = pipe.read()
@@ -53,7 +44,7 @@ def get_latest_commit_from(file_path, commit):
if len(result) <= 1:
return None
- dprint("Result: {}".format(result[0]))
+ dprint(f"Result: {result[0]}")
return {
"hash": result[0],
@@ -64,16 +55,18 @@ def get_latest_commit_from(file_path, commit):
def get_origin_from_trans(origin_path, t_from_head):
+ """Get the latest origin commit from the translation commit"""
o_from_t = get_latest_commit_from(origin_path, t_from_head["hash"])
while o_from_t is not None and o_from_t["author_date"] > t_from_head["author_date"]:
o_from_t = get_latest_commit_from(origin_path, o_from_t["hash"] + "^")
if o_from_t is not None:
- dprint("tracked origin commit id: {}".format(o_from_t["hash"]))
+ dprint(f"tracked origin commit id: {o_from_t['hash']}")
return o_from_t
def get_commits_count_between(opath, commit1, commit2):
- command = "git log --pretty=format:%H {}...{} -- {}".format(commit1, commit2, opath)
+ """Get the commits count between two commits for the specified file"""
+ command = f"git log --pretty=format:%H {commit1}...{commit2} -- {opath}"
dprint(command)
pipe = os.popen(command)
result = pipe.read().split("\n")
@@ -83,50 +76,52 @@ def get_commits_count_between(opath, commit1, commit2):
def pretty_output(commit):
- command = "git log --pretty='format:%h (\"%s\")' -1 {}".format(commit)
+ """Pretty print the commit message"""
+ command = f"git log --pretty='format:%h (\"%s\")' -1 {commit}"
dprint(command)
pipe = os.popen(command)
return pipe.read()
def check_per_file(file_path):
+ """Check the translation status for the specified file"""
opath = get_origin_path(file_path)
if not os.path.isfile(opath):
- dprint("Error: Cannot find the origin path for {}".format(file_path))
+ dprint(f"Error: Cannot find the origin path for {file_path}")
return
o_from_head = get_latest_commit_from(opath, "HEAD")
t_from_head = get_latest_commit_from(file_path, "HEAD")
if o_from_head is None or t_from_head is None:
- print("Error: Cannot find the latest commit for {}".format(file_path))
+ print(f"Error: Cannot find the latest commit for {file_path}")
return
o_from_t = get_origin_from_trans(opath, t_from_head)
if o_from_t is None:
- print("Error: Cannot find the latest origin commit for {}".format(file_path))
+ print(f"Error: Cannot find the latest origin commit for {file_path}")
return
if o_from_head["hash"] == o_from_t["hash"]:
if flag_p_uf:
- print("No update needed for {}".format(file_path))
- return
+ print(f"No update needed for {file_path}")
else:
- print("{}".format(file_path), end="\t")
+ print(f"{file_path}", end="\t")
commits = get_commits_count_between(
opath, o_from_t["hash"], o_from_head["hash"]
)
- print("({} commits)".format(len(commits)))
+ print(f"({len(commits)} commits)")
if flag_p_c:
for commit in commits:
msg = pretty_output(commit)
if "Merge tag" not in msg:
- print("commit", msg)
+ print(f"commit {msg}")
def main():
+ """Main function of the script"""
script_path = os.path.dirname(os.path.abspath(__file__))
linux_path = os.path.join(script_path, "..")
@@ -173,9 +168,7 @@ def main():
if args.locale is not None:
files = (
os.popen(
- "find {}/Documentation/translations/{} -type f".format(
- linux_path, args.locale
- )
+ f"find {linux_path}/Documentation/translations/{args.locale} -type f"
)
.read()
.split("\n")
@@ -183,7 +176,7 @@ def main():
else:
files = (
os.popen(
- "find {}/Documentation/translations -type f".format(linux_path)
+ f"find {linux_path}/Documentation/translations -type f"
)
.read()
.split("\n")
--
2.39.2
This commit adds help documents - Documentation/doc-guide/checktransupdate.rst
and Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
for scripts/checktransupdate.py, including English and Chinese versions
Signed-off-by: Dongliang Mu <[email protected]>
---
v1->v2: fix some issues according to Randy
Documentation/doc-guide/checktransupdate.rst | 63 +++++++++++++++++++
Documentation/doc-guide/index.rst | 1 +
.../zh_CN/doc-guide/checktransupdate.rst | 62 ++++++++++++++++++
.../translations/zh_CN/doc-guide/index.rst | 1 +
4 files changed, 127 insertions(+)
create mode 100644 Documentation/doc-guide/checktransupdate.rst
create mode 100644 Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
diff --git a/Documentation/doc-guide/checktransupdate.rst b/Documentation/doc-guide/checktransupdate.rst
new file mode 100644
index 000000000000..4ece330882d6
--- /dev/null
+++ b/Documentation/doc-guide/checktransupdate.rst
@@ -0,0 +1,63 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Check translation update
+==========================
+
+This script helps track the translation status of the documentation in
+different locales, i.e., whether the documentation is up-to-date with
+the English counterpart.
+
+How it works
+------------
+
+It uses ``git log`` command to track the latest English commit from the
+translation commit (order by author date) and the latest English commits
+from HEAD. If any differences occur, the file is considered as out-of-date,
+then commits that need to be updated will be collected and reported.
+
+Features implemented
+--------------------
+
+- check all files in a certain locale
+- check a single file or a set of files
+- provide options to change output format
+
+Usage
+-----
+
+::
+
+ checktransupdate.py [-h] [-l LOCALE] [--print-commits | --no-print-commits] [--print-updated-files | --no-print-updated-files] [--debug | --no-debug] [files ...]
+
+Options
+~~~~~~~
+
+- ``-l``, ``--locale``: locale to check when file is not specified
+- ``--[no-]print-commits``: whether to print commits between origin and
+ translation
+- ``--[no-]print-updated-files``: whether to print files that do no
+ need to be updated
+- ``files``: files to check, if this option is specified, the locale
+ option will be ignored.
+
+Samples
+~~~~~~~
+
+- ``./scripts/checktransupdate.py -l zh_CN``
+ This will print all the files that need to be updated in the zh_CN locale.
+- ``./scripts/checktransupdate.py Documentation/translations/zh_CN/process/coding-style.rst``
+ This will only print the status of the specified file.
+
+Then the output is something like:
+
+::
+
+ Documentation/translations/zh_CN/process/coding-style.rst (2 commits)
+ commit 6813216bbdba ("Documentation: coding-style: ask function-like macros to evaluate parameters")
+ commit 185ea7676ef3 ("Documentation: coding-style: Update syntax highlighting for code-blocks")
+
+Features to be implemented
+----------------------------
+
+- track the translation status of files that have no translation
+- files can be a folder instead of only a file
diff --git a/Documentation/doc-guide/index.rst b/Documentation/doc-guide/index.rst
index 7c7d97784626..24d058faa75c 100644
--- a/Documentation/doc-guide/index.rst
+++ b/Documentation/doc-guide/index.rst
@@ -12,6 +12,7 @@ How to write kernel documentation
parse-headers
contributing
maintainer-profile
+ checktransupdate
.. only:: subproject and html
diff --git a/Documentation/translations/zh_CN/doc-guide/checktransupdate.rst b/Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
new file mode 100644
index 000000000000..37c0bb518ab8
--- /dev/null
+++ b/Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
@@ -0,0 +1,62 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. include:: ../disclaimer-zh_CN.rst
+
+:Original: Documentation/doc-guide/checktransupdate.rst
+
+:译者: 慕冬亮 Dongliang Mu <[email protected]>
+
+检查翻译更新
+=============
+
+这个脚本帮助跟踪不同语言的文档翻译状态,即文档是否与对应的英文版本保持更新。
+
+工作原理
+------------
+
+它使用 ``git log`` 命令来跟踪翻译提交的最新英文提交(按作者日期排序)和英文文档的
+最新提交。如果有任何差异,则该文件被认为是过期的,然后需要更新的提交将被收集并报告。
+
+实现的功能
+--------------------
+
+- 检查特定语言中的所有文件
+- 检查单个文件或一组文件
+- 提供更改输出格式的选项
+
+用法
+-----
+
+::
+
+ checktransupdate.py [-h] [-l LOCALE] [--print-commits | --no-print-commits] [--print-updated-files | --no-print-updated-files] [--debug | --no-debug] [files ...]
+
+选项
+~~~~~~~
+
+- ``-l``, ``--locale``: 检查指定的文件语言,如果未指定文件
+- ``--[no-]print-commits``: 是否打印英文原始版本和翻译版本之间的提交
+- ``--[no-]print-updated-files``: 是否打印无需更新的文件
+- ``files``: 要检查的文件,如果指定了此选项,将忽略语言选项
+
+示例
+~~~~~~~
+
+- ``./scripts/checktransupdate.py -l zh_CN``
+ 这将打印 zh_CN 语言中需要更新的所有文件。
+- ``./scripts/checktransupdate.py Documentation/translations/zh_CN/process/coding-style.rst``
+ 这将只打印指定文件的状态。
+
+然后输出类似如下的内容:
+
+::
+
+ Documentation/translations/zh_CN/process/coding-style.rst (2 commits)
+ commit 6813216bbdba ("Documentation: coding-style: ask function-like macros to evaluate parameters")
+ commit 185ea7676ef3 ("Documentation: coding-style: Update syntax highlighting for code-blocks")
+
+待实现的功能
+-------------
+
+- 跟踪没有翻译过的文件的翻译状态
+- 文件参数可以是文件夹而不仅仅是单个文件
diff --git a/Documentation/translations/zh_CN/doc-guide/index.rst b/Documentation/translations/zh_CN/doc-guide/index.rst
index 78c2e9a1697f..0ac1fc9315ea 100644
--- a/Documentation/translations/zh_CN/doc-guide/index.rst
+++ b/Documentation/translations/zh_CN/doc-guide/index.rst
@@ -18,6 +18,7 @@
parse-headers
contributing
maintainer-profile
+ checktransupdate
.. only:: subproject and html
--
2.39.2
2024年6月15日 11:53, "Dongliang Mu" <[email protected]> 写到:
>
> This commit adds help documents - Documentation/doc-guide/checktransupdate.rst
>
> and Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
>
> for scripts/checktransupdate.py, including English and Chinese versions
>
> Signed-off-by: Dongliang Mu <[email protected]>
>
> ---
>
> v1->v2: fix some issues according to Randy
>
> Documentation/doc-guide/checktransupdate.rst | 63 +++++++++++++++++++
>
> Documentation/doc-guide/index.rst | 1 +
>
> .../zh_CN/doc-guide/checktransupdate.rst | 62 ++++++++++++++++++
>
> .../translations/zh_CN/doc-guide/index.rst | 1 +
>
> 4 files changed, 127 insertions(+)
>
> create mode 100644 Documentation/doc-guide/checktransupdate.rst
>
> create mode 100644 Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
>
> diff --git a/Documentation/doc-guide/checktransupdate.rst b/Documentation/doc-guide/checktransupdate.rst
>
> new file mode 100644
>
> index 000000000000..4ece330882d6
>
> --- /dev/null
>
> +++ b/Documentation/doc-guide/checktransupdate.rst
>
> @@ -0,0 +1,63 @@
>
> +.. SPDX-License-Identifier: GPL-2.0
>
> +
>
> +Check translation update
>
> +==========================
Let's get rid of unnecessary symbols.
>
> +
>
> +This script helps track the translation status of the documentation in
>
> +different locales, i.e., whether the documentation is up-to-date with
>
> +the English counterpart.
>
> +
>
> +How it works
>
> +------------
>
> +
>
> +It uses ``git log`` command to track the latest English commit from the
>
> +translation commit (order by author date) and the latest English commits
>
> +from HEAD. If any differences occur, the file is considered as out-of-date,
>
> +then commits that need to be updated will be collected and reported.
>
> +
>
> +Features implemented
>
> +--------------------
>
> +
>
> +- check all files in a certain locale
>
> +- check a single file or a set of files
>
> +- provide options to change output format
>
> +
>
> +Usage
>
> +-----
>
> +
>
> +::
>
> +
>
> + checktransupdate.py [-h] [-l LOCALE] [--print-commits | --no-print-commits] [--print-updated-files | --no-print-updated-files] [--debug | --no-debug] [files ...]
>
> +
>
> +Options
>
> +~~~~~~~
>
> +
>
> +- ``-l``, ``--locale``: locale to check when file is not specified
>
> +- ``--[no-]print-commits``: whether to print commits between origin and
>
> + translation
>
> +- ``--[no-]print-updated-files``: whether to print files that do no
>
> + need to be updated
>
> +- ``files``: files to check, if this option is specified, the locale
>
> + option will be ignored.
>
> +
>
> +Samples
>
> +~~~~~~~
>
> +
>
> +- ``./scripts/checktransupdate.py -l zh_CN``
>
> + This will print all the files that need to be updated in the zh_CN locale.
>
> +- ``./scripts/checktransupdate.py Documentation/translations/zh_CN/process/coding-style.rst``
>
> + This will only print the status of the specified file.
>
> +
>
> +Then the output is something like:
>
> +
>
> +::
>
> +
>
> + Documentation/translations/zh_CN/process/coding-style.rst (2 commits)
>
> + commit 6813216bbdba ("Documentation: coding-style: ask function-like macros to evaluate parameters")
>
> + commit 185ea7676ef3 ("Documentation: coding-style: Update syntax highlighting for code-blocks")
>
> +
>
> +Features to be implemented
>
> +----------------------------
ditto
>
> +
>
> +- track the translation status of files that have no translation
>
> +- files can be a folder instead of only a file
>
> diff --git a/Documentation/doc-guide/index.rst b/Documentation/doc-guide/index.rst
>
> index 7c7d97784626..24d058faa75c 100644
>
> --- a/Documentation/doc-guide/index.rst
>
> +++ b/Documentation/doc-guide/index.rst
>
> @@ -12,6 +12,7 @@ How to write kernel documentation
>
> parse-headers
>
> contributing
>
> maintainer-profile
>
> + checktransupdate
>
>
>
> .. only:: subproject and html
>
>
>
> diff --git a/Documentation/translations/zh_CN/doc-guide/checktransupdate.rst b/Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
>
> new file mode 100644
>
> index 000000000000..37c0bb518ab8
>
> --- /dev/null
>
> +++ b/Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
>
> @@ -0,0 +1,62 @@
>
> +.. SPDX-License-Identifier: GPL-2.0
>
> +
>
> +.. include:: ../disclaimer-zh_CN.rst
>
> +
>
> +:Original: Documentation/doc-guide/checktransupdate.rst
>
> +
>
> +:译者: 慕冬亮 Dongliang Mu <[email protected]>
>
> +
>
> +检查翻译更新
>
> +=============
ditto
>
> +
>
> +这个脚本帮助跟踪不同语言的文档翻译状态,即文档是否与对应的英文版本保持更新。
>
> +
>
> +工作原理
>
> +------------
>
> +
>
> +它使用 ``git log`` 命令来跟踪翻译提交的最新英文提交(按作者日期排序)和英文文档的
>
> +最新提交。如果有任何差异,则该文件被认为是过期的,然后需要更新的提交将被收集并报告。
>
> +
>
> +实现的功能
>
> +--------------------
ditto
...
>
> +
>
> +- 检查特定语言中的所有文件
>
> +- 检查单个文件或一组文件
>
> +- 提供更改输出格式的选项
>
> +
>
> +用法
>
> +-----
>
> +
>
> +::
>
> +
>
> + checktransupdate.py [-h] [-l LOCALE] [--print-commits | --no-print-commits] [--print-updated-files | --no-print-updated-files] [--debug | --no-debug] [files ...]
>
> +
>
> +选项
>
> +~~~~~~~
>
> +
>
> +- ``-l``, ``--locale``: 检查指定的文件语言,如果未指定文件
>
> +- ``--[no-]print-commits``: 是否打印英文原始版本和翻译版本之间的提交
>
> +- ``--[no-]print-updated-files``: 是否打印无需更新的文件
>
> +- ``files``: 要检查的文件,如果指定了此选项,将忽略语言选项
>
> +
>
> +示例
>
> +~~~~~~~
ditto
Thanks,
Yanteng
>
> +
>
> +- ``./scripts/checktransupdate.py -l zh_CN``
>
> + 这将打印 zh_CN 语言中需要更新的所有文件。
>
> +- ``./scripts/checktransupdate.py Documentation/translations/zh_CN/process/coding-style.rst``
>
> + 这将只打印指定文件的状态。
>
> +
>
> +然后输出类似如下的内容:
>
> +
>
> +::
>
> +
>
> + Documentation/translations/zh_CN/process/coding-style.rst (2 commits)
>
> + commit 6813216bbdba ("Documentation: coding-style: ask function-like macros to evaluate parameters")
>
> + commit 185ea7676ef3 ("Documentation: coding-style: Update syntax highlighting for code-blocks")
>
> +
>
> +待实现的功能
>
> +-------------
>
> +
>
> +- 跟踪没有翻译过的文件的翻译状态
>
> +- 文件参数可以是文件夹而不仅仅是单个文件
>
> diff --git a/Documentation/translations/zh_CN/doc-guide/index.rst b/Documentation/translations/zh_CN/doc-guide/index.rst
>
> index 78c2e9a1697f..0ac1fc9315ea 100644
>
> --- a/Documentation/translations/zh_CN/doc-guide/index.rst
>
> +++ b/Documentation/translations/zh_CN/doc-guide/index.rst
>
> @@ -18,6 +18,7 @@
>
> parse-headers
>
> contributing
>
> maintainer-profile
>
> + checktransupdate
>
>
>
> .. only:: subproject and html
>
>
>
> --
>
> 2.39.2
>
On 2024/6/15 15:57, [email protected] wrote:
> 2024年6月15日 11:53, "Dongliang Mu" <[email protected]> 写到:
>
>
>
>> This commit adds help documents - Documentation/doc-guide/checktransupdate.rst
>>
>> and Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
>>
>> for scripts/checktransupdate.py, including English and Chinese versions
>>
>> Signed-off-by: Dongliang Mu <[email protected]>
>>
>> ---
>>
>> v1->v2: fix some issues according to Randy
>>
>> Documentation/doc-guide/checktransupdate.rst | 63 +++++++++++++++++++
>>
>> Documentation/doc-guide/index.rst | 1 +
>>
>> .../zh_CN/doc-guide/checktransupdate.rst | 62 ++++++++++++++++++
>>
>> .../translations/zh_CN/doc-guide/index.rst | 1 +
>>
>> 4 files changed, 127 insertions(+)
>>
>> create mode 100644 Documentation/doc-guide/checktransupdate.rst
>>
>> create mode 100644 Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
>>
>> diff --git a/Documentation/doc-guide/checktransupdate.rst b/Documentation/doc-guide/checktransupdate.rst
>>
>> new file mode 100644
>>
>> index 000000000000..4ece330882d6
>>
>> --- /dev/null
>>
>> +++ b/Documentation/doc-guide/checktransupdate.rst
>>
>> @@ -0,0 +1,63 @@
>>
>> +.. SPDX-License-Identifier: GPL-2.0
>>
>> +
>>
>> +Check translation update
>>
>> +==========================
> Let's get rid of unnecessary symbols.
>> +
>>
>> +This script helps track the translation status of the documentation in
>>
>> +different locales, i.e., whether the documentation is up-to-date with
>>
>> +the English counterpart.
>>
>> +
>>
>> +How it works
>>
>> +------------
>>
>> +
>>
>> +It uses ``git log`` command to track the latest English commit from the
>>
>> +translation commit (order by author date) and the latest English commits
>>
>> +from HEAD. If any differences occur, the file is considered as out-of-date,
>>
>> +then commits that need to be updated will be collected and reported.
>>
>> +
>>
>> +Features implemented
>>
>> +--------------------
>>
>> +
>>
>> +- check all files in a certain locale
>>
>> +- check a single file or a set of files
>>
>> +- provide options to change output format
>>
>> +
>>
>> +Usage
>>
>> +-----
>>
>> +
>>
>> +::
>>
>> +
>>
>> + checktransupdate.py [-h] [-l LOCALE] [--print-commits | --no-print-commits] [--print-updated-files | --no-print-updated-files] [--debug | --no-debug] [files ...]
>>
>> +
>>
>> +Options
>>
>> +~~~~~~~
>>
>> +
>>
>> +- ``-l``, ``--locale``: locale to check when file is not specified
>>
>> +- ``--[no-]print-commits``: whether to print commits between origin and
>>
>> + translation
>>
>> +- ``--[no-]print-updated-files``: whether to print files that do no
>>
>> + need to be updated
>>
>> +- ``files``: files to check, if this option is specified, the locale
>>
>> + option will be ignored.
>>
>> +
>>
>> +Samples
>>
>> +~~~~~~~
>>
>> +
>>
>> +- ``./scripts/checktransupdate.py -l zh_CN``
>>
>> + This will print all the files that need to be updated in the zh_CN locale.
>>
>> +- ``./scripts/checktransupdate.py Documentation/translations/zh_CN/process/coding-style.rst``
>>
>> + This will only print the status of the specified file.
>>
>> +
>>
>> +Then the output is something like:
>>
>> +
>>
>> +::
>>
>> +
>>
>> + Documentation/translations/zh_CN/process/coding-style.rst (2 commits)
>>
>> + commit 6813216bbdba ("Documentation: coding-style: ask function-like macros to evaluate parameters")
>>
>> + commit 185ea7676ef3 ("Documentation: coding-style: Update syntax highlighting for code-blocks")
>>
>> +
>>
>> +Features to be implemented
>>
>> +----------------------------
> ditto
>
>> +
>>
>> +- track the translation status of files that have no translation
>>
>> +- files can be a folder instead of only a file
>>
>> diff --git a/Documentation/doc-guide/index.rst b/Documentation/doc-guide/index.rst
>>
>> index 7c7d97784626..24d058faa75c 100644
>>
>> --- a/Documentation/doc-guide/index.rst
>>
>> +++ b/Documentation/doc-guide/index.rst
>>
>> @@ -12,6 +12,7 @@ How to write kernel documentation
>>
>> parse-headers
>>
>> contributing
>>
>> maintainer-profile
>>
>> + checktransupdate
>>
>>
>>
>> .. only:: subproject and html
>>
>>
>>
>> diff --git a/Documentation/translations/zh_CN/doc-guide/checktransupdate.rst b/Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
>>
>> new file mode 100644
>>
>> index 000000000000..37c0bb518ab8
>>
>> --- /dev/null
>>
>> +++ b/Documentation/translations/zh_CN/doc-guide/checktransupdate.rst
>>
>> @@ -0,0 +1,62 @@
>>
>> +.. SPDX-License-Identifier: GPL-2.0
>>
>> +
>>
>> +.. include:: ../disclaimer-zh_CN.rst
>>
>> +
>>
>> +:Original: Documentation/doc-guide/checktransupdate.rst
>>
>> +
>>
>> +:译者: 慕冬亮 Dongliang Mu <[email protected]>
>>
>> +
>>
>> +检查翻译更新
>>
>> +=============
> ditto
>> +
>>
>> +这个脚本帮助跟踪不同语言的文档翻译状态,即文档是否与对应的英文版本保持更新。
>>
>> +
>>
>> +工作原理
>>
>> +------------
>>
>> +
>>
>> +它使用 ``git log`` 命令来跟踪翻译提交的最新英文提交(按作者日期排序)和英文文档的
>>
>> +最新提交。如果有任何差异,则该文件被认为是过期的,然后需要更新的提交将被收集并报告。
>>
>> +
>>
>> +实现的功能
>>
>> +--------------------
> ditto
>
> ...
>
>> +
>>
>> +- 检查特定语言中的所有文件
>>
>> +- 检查单个文件或一组文件
>>
>> +- 提供更改输出格式的选项
>>
>> +
>>
>> +用法
>>
>> +-----
>>
>> +
>>
>> +::
>>
>> +
>>
>> + checktransupdate.py [-h] [-l LOCALE] [--print-commits | --no-print-commits] [--print-updated-files | --no-print-updated-files] [--debug | --no-debug] [files ...]
>>
>> +
>>
>> +选项
>>
>> +~~~~~~~
>>
>> +
>>
>> +- ``-l``, ``--locale``: 检查指定的文件语言,如果未指定文件
>>
>> +- ``--[no-]print-commits``: 是否打印英文原始版本和翻译版本之间的提交
>>
>> +- ``--[no-]print-updated-files``: 是否打印无需更新的文件
>>
>> +- ``files``: 要检查的文件,如果指定了此选项,将忽略语言选项
>>
>> +
>>
>> +示例
>>
>> +~~~~~~~
> ditto
Yanteng,
the requested changes does not match between English and Chinse translation.
Dongliang Mu
>
>
> Thanks,
> Yanteng
>> +
>>
>> +- ``./scripts/checktransupdate.py -l zh_CN``
>>
>> + 这将打印 zh_CN 语言中需要更新的所有文件。
>>
>> +- ``./scripts/checktransupdate.py Documentation/translations/zh_CN/process/coding-style.rst``
>>
>> + 这将只打印指定文件的状态。
>>
>> +
>>
>> +然后输出类似如下的内容:
>>
>> +
>>
>> +::
>>
>> +
>>
>> + Documentation/translations/zh_CN/process/coding-style.rst (2 commits)
>>
>> + commit 6813216bbdba ("Documentation: coding-style: ask function-like macros to evaluate parameters")
>>
>> + commit 185ea7676ef3 ("Documentation: coding-style: Update syntax highlighting for code-blocks")
>>
>> +
>>
>> +待实现的功能
>>
>> +-------------
>>
>> +
>>
>> +- 跟踪没有翻译过的文件的翻译状态
>>
>> +- 文件参数可以是文件夹而不仅仅是单个文件
>>
>> diff --git a/Documentation/translations/zh_CN/doc-guide/index.rst b/Documentation/translations/zh_CN/doc-guide/index.rst
>>
>> index 78c2e9a1697f..0ac1fc9315ea 100644
>>
>> --- a/Documentation/translations/zh_CN/doc-guide/index.rst
>>
>> +++ b/Documentation/translations/zh_CN/doc-guide/index.rst
>>
>> @@ -18,6 +18,7 @@
>>
>> parse-headers
>>
>> contributing
>>
>> maintainer-profile
>>
>> + checktransupdate
>>
>>
>>
>> .. only:: subproject and html
>>
>>
>>
>> --
>>
>> 2.39.2
>>
Dongliang Mu <[email protected]> writes:
> Pylint reports many coding style issues of scripts/checktransupdate.py
>
> This patch fixes most issues with the following contents:
> - add or revise comments for all functions
> - use format string suggested by python
>
> Signed-off-by: Dongliang Mu <[email protected]>
> ---
> scripts/checktransupdate.py | 55 ++++++++++++++++---------------------
> 1 file changed, 24 insertions(+), 31 deletions(-)
How does this differ from v1? Please always give that information so
reviewers know what's going on.
Thanks,
jon