From bd351b71fee803f139d1ea1aa369725f2f2777c1 Mon Sep 17 00:00:00 2001 From: Lain Iwakura Date: Wed, 5 Feb 2025 08:19:59 -0300 Subject: [PATCH] Support custom licenses --- maubot/cli/commands/init.py | 5 ++++- maubot/cli/util/spdx.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/maubot/cli/commands/init.py b/maubot/cli/commands/init.py index d24def9..a6361e8 100644 --- a/maubot/cli/commands/init.py +++ b/maubot/cli/commands/init.py @@ -88,7 +88,10 @@ def init(name: str, id: str, version: Version, license: str, config: bool) -> No file.write(meta) if license: 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): os.mkdir(name) mod = mod_template.render(config=config, name=main_class) diff --git a/maubot/cli/util/spdx.py b/maubot/cli/util/spdx.py index 69f58b7..f02958b 100644 --- a/maubot/cli/util/spdx.py +++ b/maubot/cli/util/spdx.py @@ -16,6 +16,7 @@ from __future__ import annotations import json +import re import zipfile import pkg_resources @@ -42,4 +43,5 @@ def get(id: str) -> dict[str, str]: def valid(id: str) -> bool: if not spdx_list: 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