Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/cygwin-apps/calm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2022-07-04 21:00:52 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2022-07-04 21:03:08 +0300
commit91763a3f68af2db7c2b90f61926a75c33b1b8306 (patch)
tree17007659b9a8a2ca5e4050fce3b46e0528fff37a
parent879bfc586924cdaf42fc425fb71e7e145b8752a0 (diff)
Make license_expression an optional dependency
-rwxr-xr-xcalm/hint.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/calm/hint.py b/calm/hint.py
index 99408d7..d464bbc 100755
--- a/calm/hint.py
+++ b/calm/hint.py
@@ -27,19 +27,23 @@
from collections import OrderedDict
import argparse
-import license_expression
import re
-# reach inside license_expression to add custom license ids we permit
-json = license_expression.get_license_index()
-extra_licenses = [
- 'Linux-man-pages-copyleft', # requires SPDX license-list 3.15
- 'Public-Domain',
- 'XVIEW',
-]
-for l in extra_licenses:
- json.append({"spdx_license_key": l})
-licensing = license_expression.build_spdx_licensing(json)
+try:
+ import license_expression
+except ModuleNotFoundError:
+ licensing = None
+else:
+ # reach inside license_expression to add custom license ids we permit
+ json = license_expression.get_license_index()
+ extra_licenses = [
+ 'Linux-man-pages-copyleft', # requires SPDX license-list 3.15
+ 'Public-Domain',
+ 'XVIEW',
+ ]
+ for l in extra_licenses:
+ json.append({"spdx_license_key": l})
+ licensing = license_expression.build_spdx_licensing(json)
# types of key:
# 'multilineval' - always have a value, which may be multiline
@@ -291,7 +295,7 @@ def hint_file_parse(fn, kind, strict=False):
errors.append('message value must have id and text')
# license must be a valid spdx license expression
- if key == 'license':
+ if key == 'license' and licensing:
try:
le = licensing.validate(value, strict=True)
except (license_expression.ExpressionParseError, license_expression.ExpressionError) as e: