Skip to content

Commit fb4f5b0

Browse files
committed
Invert license alias table to avoid duplicated SPDX literals
1 parent 4b2df61 commit fb4f5b0

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

je_auto_control/utils/license_policy/license_policy.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,21 @@
2121
"LGPL-3.0-or-later", "MPL-2.0", "EPL-2.0", "CDDL-1.0",
2222
})
2323

24-
_ALIASES = {
25-
"mit license": "MIT", "the mit license": "MIT", "mit": "MIT",
26-
"apache 2.0": "Apache-2.0", "apache-2": "Apache-2.0",
27-
"apache 2": "Apache-2.0", "apache2": "Apache-2.0",
28-
"apache software license": "Apache-2.0", "apache license 2.0": "Apache-2.0",
29-
"bsd": "BSD-3-Clause", "bsd license": "BSD-3-Clause",
30-
"new bsd license": "BSD-3-Clause", "gplv2": "GPL-2.0-only",
31-
"gplv3": "GPL-3.0-only", "gnu gplv3": "GPL-3.0-only",
32-
"lgplv3": "LGPL-3.0-only", "mpl 2.0": "MPL-2.0", "isc license": "ISC",
24+
# Canonical SPDX id -> the loose names that should normalize to it. Inverted
25+
# below so each SPDX id literal appears exactly once (no duplicated literals).
26+
_ALIAS_GROUPS = {
27+
"MIT": ("mit license", "the mit license", "mit"),
28+
"Apache-2.0": ("apache 2.0", "apache-2", "apache 2", "apache2",
29+
"apache software license", "apache license 2.0"),
30+
"BSD-3-Clause": ("bsd", "bsd license", "new bsd license"),
31+
"GPL-2.0-only": ("gplv2",),
32+
"GPL-3.0-only": ("gplv3", "gnu gplv3"),
33+
"LGPL-3.0-only": ("lgplv3",),
34+
"MPL-2.0": ("mpl 2.0",),
35+
"ISC": ("isc license",),
3336
}
37+
_ALIASES = {alias: spdx for spdx, names in _ALIAS_GROUPS.items()
38+
for alias in names}
3439

3540
_OPERATOR_RE = re.compile(r"\b(?:OR|AND|WITH)\b|[()]", re.IGNORECASE)
3641

0 commit comments

Comments
 (0)