diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2022-08-15 12:59:41 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2022-08-15 13:00:33 +0300 |
commit | 7157342b6c04ce3dfeace4ba92053e6e4793b21a (patch) | |
tree | 4068bf67ee83d1464acf1cf5a367a8e729eeef6f | |
parent | 8325fded1ccb121c57ad689470a76542a8609500 (diff) |
Report non-exception errors from license.expression.validate()
Also make that error reporting a bit more consistent
Also allow hint checker to be run on src.hint files
-rwxr-xr-x | calm/hint.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/calm/hint.py b/calm/hint.py index 363cfb4..9ae25aa 100755 --- a/calm/hint.py +++ b/calm/hint.py @@ -299,10 +299,14 @@ def hint_file_parse(fn, kind, strict=False): 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)) + except license_expression.ExpressionParseError as e: + errors.append('errors parsing license expression: %s' % (e)) + except license_expression.ExpressionError as e: + errors.append('errors validating license expression: %s' % (e)) else: - if le.original_expression != le.normalized_expression: + if not le.normalized_expression: + errors.append('errors in license expression: %s' % (le.errors)) + elif 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 @@ -415,7 +419,7 @@ def main(args): status = 0 for fn in args.files: - hints = hint_file_parse(fn, pvr) + hints = hint_file_parse(fn, spvr if fn.endswith('src.hint') else pvr) if args.verbose > 1: print(hints) |