diff options
| author | Ross Burton <ross.burton@arm.com> | 2025-06-27 14:48:46 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-07-01 08:49:37 +0100 |
| commit | 72486700fb17153bb777a1fdf4abeb6d249a2657 (patch) | |
| tree | 133321c208f4211ead19d6ac34e804bb8fad4a9a /scripts | |
| parent | 90cc27f8ce15f2b51de95aa3b6628516030349ee (diff) | |
| download | poky-72486700fb17153bb777a1fdf4abeb6d249a2657.tar.gz | |
oe/licenses: move tidy_licenses from recipetool
This function, to tidy a license string, is useful outside of recipetool
so move it to oe.license.
(From OE-Core rev: 9d57b53169bc60b281510c49e54123941a17a8f5)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/lib/recipetool/create.py | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index 5d7fcbbb98..ef0ba974a9 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py | |||
| @@ -18,6 +18,7 @@ from urllib.parse import urlparse, urldefrag, urlsplit | |||
| 18 | import hashlib | 18 | import hashlib |
| 19 | import bb.fetch2 | 19 | import bb.fetch2 |
| 20 | logger = logging.getLogger('recipetool') | 20 | logger = logging.getLogger('recipetool') |
| 21 | from oe.license import tidy_licenses | ||
| 21 | from oe.license_finder import find_licenses | 22 | from oe.license_finder import find_licenses |
| 22 | 23 | ||
| 23 | tinfoil = None | 24 | tinfoil = None |
| @@ -950,16 +951,6 @@ def fixup_license(value): | |||
| 950 | return '(' + value + ')' | 951 | return '(' + value + ')' |
| 951 | return value | 952 | return value |
| 952 | 953 | ||
| 953 | def tidy_licenses(value): | ||
| 954 | """Flat, split and sort licenses""" | ||
| 955 | from oe.license import flattened_licenses | ||
| 956 | def _choose(a, b): | ||
| 957 | str_a, str_b = sorted((" & ".join(a), " & ".join(b)), key=str.casefold) | ||
| 958 | return ["(%s | %s)" % (str_a, str_b)] | ||
| 959 | if not isinstance(value, str): | ||
| 960 | value = " & ".join(value) | ||
| 961 | return sorted(list(set(flattened_licenses(value, _choose))), key=str.casefold) | ||
| 962 | |||
| 963 | def handle_license_vars(srctree, lines_before, handled, extravalues, d): | 954 | def handle_license_vars(srctree, lines_before, handled, extravalues, d): |
| 964 | lichandled = [x for x in handled if x[0] == 'license'] | 955 | lichandled = [x for x in handled if x[0] == 'license'] |
| 965 | if lichandled: | 956 | if lichandled: |
