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-16 22:50:20 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2022-07-16 23:07:44 +0300
commit8325fded1ccb121c57ad689470a76542a8609500 (patch)
tree147af48df6c53a795be5940288dd1c2ce4e671a6
parent4ef519f84b9da106f07677289f629787384cb469 (diff)
Workaround unexpected exceptions from license_expression.validate()
[...] File "/home/cygwin/.local/lib/python3.6/site-packages/license_expression/__init__.py", line 1214, in __init__ 'Invalid license key: the valid characters are: letters and ' license_expression.ExpressionError: Invalid license key: the valid characters are: letters and numbers, underscore, dot, colon or hyphen signs and spaces: 'LGPLv3+/GPLv2+/GPLv3+/GFDLv1.3+' During handling of the above exception, another exception occurred: [...] File "/home/cygwin/.local/lib/python3.6/site-packages/license_expression/__init__.py", line 780, in validate expression_info.invalid_symbols.append(e.token_string) AttributeError: 'ExpressionError' object has no attribute 'token_string'
-rwxr-xr-xcalm/hint.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/calm/hint.py b/calm/hint.py
index d464bbc..363cfb4 100755
--- a/calm/hint.py
+++ b/calm/hint.py
@@ -297,11 +297,13 @@ def hint_file_parse(fn, kind, strict=False):
# license must be a valid spdx license expression
if key == 'license' and licensing:
try:
+ licensing.parse(value, strict=True)
le = licensing.validate(value, strict=True)
except (license_expression.ExpressionParseError, license_expression.ExpressionError) as e:
errors.append('value for key %s not a valid license expression: %s' % (key, e))
- if le.original_expression != le.normalized_expression:
- errors.append("license expression: '%s' normalizes to '%s'" % (value, le.normalized_expression))
+ else:
+ if le.original_expression != le.normalized_expression:
+ errors.append("license expression: '%s' normalizes to '%s'" % (value, le.normalized_expression))
# warn if value starts with a quote followed by whitespace
if re.match(r'^"[ \t]+', value):