[sdk/pology] pology: Handle SPDX-style author lines
Karl Ove Hufthammer <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 8fb677bae6669642b8e3a03ee2f37699305e7884 by Karl Ove Hufthammer. Committed on 04/08/2026 at 17:35. Pushed by aacid into branch 'master'. Handle SPDX-style author lines Author information using SPDX tags (as written by Lokalize) is now correctly parsed. That is, a line like this # SPDX-FileCopyrightText: 2024, 2026 John Doe <[email protected]> is handled exactly the same as a line like this # John Doe <[email protected]>, 2024, 2026. To accommodate other PO editors, the parsing is slightly more flexible than what is necessary for handling the syntax used in Lokalize (e.g., en-dashes instead of hyphens in year ranges are accepted). However, there is no attempt to handle SPDX tags in other formats, e.g., ‘incomplete’ tags without an email address or a copyright year. (The SPDX-FileCopyrightText is in theory a free-form field.) These non-standard tags will continue to be ignored or result in an error/warning from Pology’s default author line parsing. M +1 -0 pology/header.py M +4 -0 pology/normalize.py https://invent.kde.org/sdk/pology/-/commit/8fb677bae6669642b8e3a03ee2f37699305e7884 diff --git a/pology/header.py b/pology/header.py index 896c90d0..e3c67db3 100644 --- a/pology/header.py +++ b/pology/header.py @@ -109,6 +109,7 @@ class Header (Monitored): if 0: pass elif ( not self._copyright and re.search(r"copyright|\(C\)|©", c, re.I|re.U) + and not re.search(r"SPDX-FileCopyrightText:", c) # --> author comment ): self._copyright = c intitle = False diff --git a/pology/normalize.py b/pology/normalize.py index 3006f5ed..24bf7ab1 100644 --- a/pology/normalize.py +++ b/pology/normalize.py @@ -412,6 +412,10 @@ def _fix_authors (hdr, cat): for a in hdr.author: pos += 1 + # Change SPDX-style lines to normal gettext author format + a = re.sub(r"^SPDX-FileCopyrightText:\s*([0-9, —–-]+)\s+(.*)$", + r"\2, \1", a) + m = re.search(r"(.*?)<(.*?)>(.*)$", a) if not m: warning(_("@info",