Fix insertion of newlines in license conversion comments

We would end up with not-enough/one-too-many in various cases.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-11-23 10:57:49 +01:00
parent 1482f79e28
commit 1100c60d7b

View file

@ -26,7 +26,7 @@ def dump_sdpx_to_fedora_map(file):
print(f"{k}{v}", file=file)
def translate_license_fedora(license):
comments = ''
comments = []
final = []
for tag in license.split():
# We accept all variant cases, but output lowercase which is what Fedora LicensingGuidelines specify
@ -43,18 +43,18 @@ def translate_license_fedora(license):
mapped = spdx_to_fedora_map().get(key, None)
if mapped is None:
comments += f'# FIXME: Upstream uses unknown SPDX tag {fulltag}!'
comments += [f'# FIXME: Upstream uses unknown SPDX tag {fulltag}!']
final.append(tag)
elif mapped == '':
comments += f"# FIXME: Upstream SPDX tag {fulltag} not listed in Fedora's good licenses list.\n"
comments += "# FIXME: This package might not be allowed in Fedora!\n"
comments += [f"# FIXME: Upstream SPDX tag {fulltag} not listed in Fedora's good licenses list.",
"# FIXME: This package might not be allowed in Fedora!"]
final.append(tag)
else:
final.append(mapped)
if mapped != tag:
print(f'Upstream license tag {fulltag} translated to {mapped}',
file=_sys.stderr)
return (' '.join(final), comments or None)
return (' '.join(final), '\n'.join(comments) or None)
def translate_license(target, license):
license = translate_slashes(license)