Support custom licenses

This commit is contained in:
Lain Iwakura 2025-02-05 08:19:59 -03:00
parent fe4d2f02bb
commit bd351b71fe
No known key found for this signature in database
GPG key ID: 89686F4239E80508
2 changed files with 7 additions and 2 deletions

View file

@ -88,7 +88,10 @@ def init(name: str, id: str, version: Version, license: str, config: bool) -> No
file.write(meta) file.write(meta)
if license: if license:
with open("LICENSE", "w") as file: with open("LICENSE", "w") as file:
file.write(spdx.get(license)["licenseText"]) if license.startswith("LicenseRef-"):
file.write("** You must include the license text here **")
else:
file.write(spdx.get(license)["licenseText"])
if not os.path.isdir(name): if not os.path.isdir(name):
os.mkdir(name) os.mkdir(name)
mod = mod_template.render(config=config, name=main_class) mod = mod_template.render(config=config, name=main_class)

View file

@ -16,6 +16,7 @@
from __future__ import annotations from __future__ import annotations
import json import json
import re
import zipfile import zipfile
import pkg_resources import pkg_resources
@ -42,4 +43,5 @@ def get(id: str) -> dict[str, str]:
def valid(id: str) -> bool: def valid(id: str) -> bool:
if not spdx_list: if not spdx_list:
load() load()
return id in spdx_list custom_license = re.compile('LicenseRef-[a-zA-Z0-9.-]*$')
return bool(custom_license.match(id)) or id in spdx_list