|
41 | 41 | import sys
|
42 | 42 | from pathlib import Path
|
43 | 43 |
|
44 |
| -from pip._vendor import tomli |
45 |
| -from pip._vendor.packaging.specifiers import SpecifierSet |
| 44 | +from pip._vendor import tomli # pylint: disable=no-name-in-module |
| 45 | +from pip._vendor.packaging.specifiers import SpecifierSet # pylint: disable=no-name-in-module |
46 | 46 |
|
47 | 47 | # Approved license identifiers in SPDX "short identifier" format
|
48 | 48 | ALLOWED_LICENSES = {
|
@@ -75,10 +75,10 @@ def validate_metadata(package_dir, metadata):
|
75 | 75 | patch_path = package_dir / patch
|
76 | 76 | assert patch_path.is_file(), f"Patch file does not exists: {patch_path}"
|
77 | 77 | patches.add(patch_path)
|
78 |
| - license = rule.get('license') |
79 |
| - assert license, f"'license' not specified for patch {patch}" |
80 |
| - license = re.sub(r'[()]', ' ', license) |
81 |
| - for part in re.split(f'AND|OR', license): |
| 78 | + license_id = rule.get('license') |
| 79 | + assert license_id, f"'license' not specified for patch {patch}" |
| 80 | + license_id = re.sub(r'[()]', ' ', license_id) |
| 81 | + for part in re.split(f'AND|OR', license_id): |
82 | 82 | part = part.strip()
|
83 | 83 | if ' WITH ' in part:
|
84 | 84 | part, exception = re.split(r'\s+WITH\s+', part, 1)
|
@@ -121,7 +121,7 @@ def main():
|
121 | 121 | validate_metadata(package_dir, metadata)
|
122 | 122 | else:
|
123 | 123 | assert False, f"Patch directory without metadata: {package_dir}"
|
124 |
| - except Exception as e: |
| 124 | + except AssertionError as e: |
125 | 125 | errors.append(f"\t{package_dir.name}: {e}")
|
126 | 126 | if errors:
|
127 | 127 | sys.exit("Patch metadata validation failed:\n" + '\n'.join(errors))
|
|
0 commit comments