From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Linux Doc Mailing List <linux-doc@vger.kernel.org>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
linux-kernel@vger.kernel.org, Akira Yokosawa <akiyks@gmail.com>
Subject: [PATCH 25/27] scripts/lib/abi/abi_parser.py: make it backward-compatible with Python 3.6
Date: Mon, 10 Feb 2025 11:18:14 +0100 [thread overview]
Message-ID: <41d2f85df134a46db46fed73a0f9697a3d2ae9ba.1739182025.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1739182025.git.mchehab+huawei@kernel.org>
Despite being introduced on Python 3.6, the original implementation
was too limited: it doesn't accept anything but the argument.
Even on python 3.10.12, support was still limited, as more complex
operations cause SyntaxError:
Exception occurred:
File ".../linux/Documentation/sphinx/kernel_abi.py", line 48, in <module>
from get_abi import AbiParser
File ".../linux/scripts/lib/abi/abi_parser.py", line 525
msg += f"{part}\n{"-" * len(part)}\n\n"
^
SyntaxError: f-string: expecting '}'
Replace f-strings by normal string concatenation when it doesn't
work on Python 3.6.
Reported-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
scripts/lib/abi/abi_parser.py | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py
index 0c3837e52afa..f08de6d3bf7c 100644
--- a/scripts/lib/abi/abi_parser.py
+++ b/scripts/lib/abi/abi_parser.py
@@ -493,7 +493,7 @@ class AbiParser:
if cur_part and cur_part != part:
part = cur_part
- msg += f"{part}\n{"-" * len(part)}\n\n"
+ msg += part + "\n"+ "-" * len(part) +"\n\n"
msg += f".. _{key}:\n\n"
@@ -517,7 +517,7 @@ class AbiParser:
msg += f"Defined on file :ref:`{base} <{ref[1]}>`\n\n"
if wtype == "File":
- msg += f"{names[0]}\n{"-" * len(names[0])}\n\n"
+ msg += names[0] +"\n" + "-" * len(names[0]) +"\n\n"
desc = v.get("description")
if not desc and wtype != "File":
@@ -541,7 +541,8 @@ class AbiParser:
users = v.get("users")
if users and users.strip(" \t\n"):
- msg += f"Users:\n\t{users.strip("\n").replace('\n', '\n\t')}\n\n"
+ users = users.strip("\n").replace('\n', '\n\t')
+ msg += f"Users:\n\t{users}\n\n"
ln = v.get("line_no", 1)
@@ -567,7 +568,9 @@ class AbiParser:
elif len(lines) == 1:
f.append(f"{fname}:{lines[0]}")
else:
- f.append(f"{fname} lines {", ".join(str(x) for x in lines)}")
+ m = fname + "lines "
+ m += ", ".join(str(x) for x in lines)
+ f.append(m)
self.log.warning("%s is defined %d times: %s", what, len(f), "; ".join(f))
@@ -615,10 +618,11 @@ class AbiParser:
if users:
print(f"Users:\t\t\t{users}")
- print(f"Defined on file{'s'[:len(files) ^ 1]}:\t{", ".join(files)}")
+ print("Defined on file(s):\t" + ", ".join(files))
if desc:
- print(f"\n{desc.strip("\n")}\n")
+ desc = desc.strip("\n")
+ print(f"\n{desc}\n")
if not found_keys:
print(f"Regular expression /{expr}/ not found.")
--
2.48.1
next prev parent reply other threads:[~2025-02-10 10:18 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 10:17 [PATCH 00/27] Improve ABI documentation generation Mauro Carvalho Chehab
2025-02-10 10:17 ` [PATCH 01/27] docs: sphinx: remove kernellog.py file Mauro Carvalho Chehab
2025-02-10 10:17 ` [PATCH 02/27] docs: sphinx/kernel_abi: adjust coding style Mauro Carvalho Chehab
2025-02-10 10:17 ` [PATCH 03/27] docs: admin-guide: abi: add SPDX tags to ABI files Mauro Carvalho Chehab
2025-02-10 10:17 ` [PATCH 04/27] ABI: sysfs-class-rfkill: fix kernelversion tags Mauro Carvalho Chehab
2025-02-10 10:17 ` [PATCH 05/27] ABI: sysfs-bus-coresight-*: " Mauro Carvalho Chehab
2025-02-10 10:33 ` Suzuki K Poulose
2025-02-10 10:17 ` [PATCH 06/27] ABI: sysfs-driver-dma-idxd: fix date tags Mauro Carvalho Chehab
2025-02-10 10:17 ` [PATCH 07/27] ABI: sysfs-fs-f2fs: " Mauro Carvalho Chehab
2025-02-10 10:17 ` [PATCH 08/27] ABI: sysfs-power: fix a what tag Mauro Carvalho Chehab
2025-02-10 10:17 ` [PATCH 09/27] scripts/documentation-file-ref-check: don't check perl/python scripts Mauro Carvalho Chehab
2025-02-10 10:17 ` [PATCH 10/27] scripts/get_abi.py: add a Python tool to generate ReST output Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 11/27] scripts/get_abi.py: add support for symbol search Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 12/27] docs: use get_abi.py for ABI generation Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 13/27] scripts/lib/abi/abi_parser.py: optimize parse_abi() function Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 14/27] scripts/lib/abi/abi_parser.py: use an interactor for ReST output Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 15/27] docs: sphinx/kernel_abi: use AbiParser directly Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 16/27] docs: sphinx/kernel_abi: reduce buffer usage for ABI messages Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 17/27] docs: sphinx/kernel_abi: properly split lines Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 18/27] scripts/get_abi.pl: Add filtering capabilities to rest output Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 19/27] scripts/get_abi.pl: add support to parse ABI README file Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 20/27] docs: sphinx/kernel_abi: parse ABI files only once Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 21/27] docs: admin-guide/abi: split files from symbols Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 22/27] docs: sphinx/automarkup: add cross-references for ABI Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 23/27] docs: sphinx/kernel_abi: avoid warnings during Sphinx module init Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 24/27] scripts/lib/abi/abi_parser.py: Rename title name for ABI files Mauro Carvalho Chehab
2025-02-10 10:18 ` Mauro Carvalho Chehab [this message]
2025-02-10 10:18 ` [PATCH 26/27] scripts/get_abi.py: add support for undefined ABIs Mauro Carvalho Chehab
2025-02-10 10:18 ` [PATCH 27/27] scripts/get_abi.pl: drop now obsoleted script Mauro Carvalho Chehab
2025-02-10 18:30 ` [PATCH 00/27] Improve ABI documentation generation Jonathan Corbet
2025-02-10 20:27 ` Mauro Carvalho Chehab
2025-03-27 21:58 ` [f2fs-dev] " patchwork-bot+f2fs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41d2f85df134a46db46fed73a0f9697a3d2ae9ba.1739182025.git.mchehab+huawei@kernel.org \
--to=mchehab+huawei@kernel.org \
--cc=akiyks@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®