mirror of
https://git.yoctoproject.org/git/poky
synced 2026-01-04 16:10:04 +00:00
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>
This commit is contained in:
parent
90cc27f8ce
commit
72486700fb
|
|
@ -462,3 +462,18 @@ def skip_incompatible_package_licenses(d, pkgs):
|
|||
skipped_pkgs[pkg] = incompatible_lic
|
||||
|
||||
return skipped_pkgs
|
||||
|
||||
def tidy_licenses(value):
|
||||
"""
|
||||
Flat, split and sort licenses.
|
||||
"""
|
||||
from oe.license import flattened_licenses
|
||||
|
||||
def _choose(a, b):
|
||||
str_a, str_b = sorted((" & ".join(a), " & ".join(b)), key=str.casefold)
|
||||
return ["(%s | %s)" % (str_a, str_b)]
|
||||
|
||||
if not isinstance(value, str):
|
||||
value = " & ".join(value)
|
||||
|
||||
return sorted(list(set(flattened_licenses(value, _choose))), key=str.casefold)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ from urllib.parse import urlparse, urldefrag, urlsplit
|
|||
import hashlib
|
||||
import bb.fetch2
|
||||
logger = logging.getLogger('recipetool')
|
||||
from oe.license import tidy_licenses
|
||||
from oe.license_finder import find_licenses
|
||||
|
||||
tinfoil = None
|
||||
|
|
@ -950,16 +951,6 @@ def fixup_license(value):
|
|||
return '(' + value + ')'
|
||||
return value
|
||||
|
||||
def tidy_licenses(value):
|
||||
"""Flat, split and sort licenses"""
|
||||
from oe.license import flattened_licenses
|
||||
def _choose(a, b):
|
||||
str_a, str_b = sorted((" & ".join(a), " & ".join(b)), key=str.casefold)
|
||||
return ["(%s | %s)" % (str_a, str_b)]
|
||||
if not isinstance(value, str):
|
||||
value = " & ".join(value)
|
||||
return sorted(list(set(flattened_licenses(value, _choose))), key=str.casefold)
|
||||
|
||||
def handle_license_vars(srctree, lines_before, handled, extravalues, d):
|
||||
lichandled = [x for x in handled if x[0] == 'license']
|
||||
if lichandled:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user