commit 3ab5c497f3c47f3d9dc4b5056b5f06663fe9bbdb
Author: José Matos <[email protected]>
Date: Wed Feb 11 09:26:53 2026 +0000
Work around limitation in f-string parser for older Python
Before Python 3.12 the f-string parser did not allow backslashes.
This patch deals with those cases.
I took the opportunity to fix a small annoyance where even if there were
no missing contributors or missing license the program would still
return:
```
WARNING!
The following contributors do not have a CREDITS entry:
These ones have no explicit licence statement:
....
```
Now we only get a warning if, at least, one of those cases is missing.
We will also only get the category, and information, about what is
missing.
---
lib/generate_contributions.py | 36 ++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git a/lib/generate_contributions.py b/lib/generate_contributions.py
index 0009f67ff7..0d67eac813 100755
--- a/lib/generate_contributions.py
+++ b/lib/generate_contributions.py
@@ -53,18 +53,21 @@ class contributor:
result = [ f'@b{self.name}\n' ]
if len(self.contact) != 0:
if self.contact.find("https") != -1:
- result.append(f'@i{self.contact}\n')
+ result.append(f'@i{self.contact}' + '\n')
else:
- result.append(f'@iE-mail: {self.contact}\n')
- result.append(f' {self.credit.replace("\n", "\n ")}\n')
+ result.append(f'@iE-mail: {self.contact}' + '\n')
+ # Python fstrings parser did not like backslashes until 3.12
+ tidy_credit = self.credit.replace("\n", "\n ")
+ result.append(f' {tidy_credit}' + '\n')
return "".join(result)
def as_php_credits(self, wrapper):
+ credit = "\n".join(wrapper.wrap(xml_escape(self.credit)))
return f'''
$output=$output.credits_contrib("{xml_escape(self.name)}",
"{xml_escape(self.contact)}",
- "{"\n".join(wrapper.wrap(xml_escape(self.credit)))}");
+ "{credit}");
'''
@@ -106,13 +109,26 @@ def collate_incomplete(contributors):
if len(contributor.licence) == 0:
missing_licence.append(contributor.name)
- return f'''WARNING!
-The following contributors do not have a CREDITS entry:
- {",\n ".join(missing_credit)}
+ missing_credit = ",\n ".join(missing_credit)
+ missing_license = ",\n ".join(missing_licence)
-These ones have no explicit licence statement:
- {",\n ".join(missing_licence)}
-'''
+ if not missing_credit and not missing_license:
+ return ""
+
+ info = "WARNING!"
+
+ if missing_credit:
+ info += f"""
+The following contributors do not have a CREDITS entry:
+ {missing_credit}
+"""
+
+ if missing_license:
+ info += f"""
+The following contributors have no explicit licence statement:
+ {missing_license}
+"""
+ return info
def as_txt_credits(contributors):
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs