Skip to content

Commit 85b4da6

Browse files
authored
Normalize licenses as they occur in ROS Humble packages (#110)
1 parent 5eaab9f commit 85b4da6

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

vinca/license_utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,24 @@
1414
"bsd-3": "BSD-3-Clause",
1515
"bsd 3-clause": "BSD-3-Clause",
1616
"3-clause bsd": "BSD-3-Clause",
17+
"bsd clause 3": "BSD-3-Clause",
18+
"bsd 3 clause": "BSD-3-Clause",
19+
"bsd 3-clause license": "BSD-3-Clause",
20+
"bds-3": "BSD-3-Clause",
1721
"bsd 2-clause": "BSD-2-Clause",
1822
"bsd license 2.0": "BSD-2-Clause",
1923
# Apache variants
2024
"apache": "Apache-2.0",
2125
"apache 2": "Apache-2.0",
26+
"apache-2": "Apache-2.0",
2227
"apache2": "Apache-2.0",
2328
"apache2.0": "Apache-2.0",
2429
"apache 2.0": "Apache-2.0",
30+
"apache 2.0 license": "Apache-2.0",
2531
"apache license 2.0": "Apache-2.0",
2632
"apache license, version 2.0": "Apache-2.0",
33+
"apache-2.0 license": "Apache-2.0",
34+
"alv2": "Apache-2.0",
2735
# GPL variants
2836
"gplv2": "GPL-2.0-only",
2937
"gpl-2": "GPL-2.0-only",
@@ -42,13 +50,18 @@
4250
"lgplv2.1": "LGPL-2.1-or-later",
4351
"lgpl-2": "LGPL-2.1-or-later",
4452
"lgpl-2.1": "LGPL-2.1-or-later",
53+
"lgpl v2.1": "LGPL-2.1-or-later",
4554
"lgplv3": "LGPL-3.0-only",
4655
"lgpl-3": "LGPL-3.0-only",
4756
"lgpl-3.0": "LGPL-3.0-only",
57+
"lgpl-v3": "LGPL-3.0-only",
4858
"LGPL (amcl)": "LGPL-2.1-or-later",
59+
"gnu lesser public license 2.1": "LGPL-2.1-only",
4960
# Mozilla/MPL variants
5061
"mozilla": "MPL-2.0",
5162
"mpl": "MPL-2.0",
63+
"mpl-2.0 license": "MPL-2.0",
64+
"mozilla public license 2.0": "MPL-2.0",
5265
"mozilla public license version 1.1": "MPL-1.1",
5366
# Eclipse variants
5467
"eclipse public license 2.0": "EPL-2.0",
@@ -63,7 +76,9 @@
6376
"zlib license": "Zlib",
6477
# Creative Commons
6578
"cc by-nc-sa 4.0": "CC-BY-NC-SA-4.0",
79+
"cc0": "CC0-1.0",
6680
"creative commons zero v1.0 universal": "CC0-1.0",
81+
"creative commons attribution-noncommercial-noderivatives 4.0 international public license": "CC-BY-NC-ND-4.0",
6782
"creative commons": "CC0-1.0", # The version is an assumption
6883
# Public Domain (choosing Unlicense as more appropriate for code)
6984
"public domain": "Unlicense",

vinca/test_license_utils.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ def test_case_insensitive_lookup():
212212

213213
def test_new_license_variants():
214214
"""Test newly added common license variants."""
215+
# BSD variants
216+
assert convert_to_spdx_license(["BSD Clause 3"]) == "BSD-3-Clause"
217+
assert convert_to_spdx_license(["BDS-3"]) == "BSD-3-Clause"
218+
assert convert_to_spdx_license(["BSD 3-Clause License"]) == "BSD-3-Clause"
219+
assert convert_to_spdx_license(["BSD 3 Clause"]) == "BSD-3-Clause"
220+
215221
# GPL variants
216222
assert convert_to_spdx_license(["GPLv2"]) == "GPL-2.0-only"
217223
assert convert_to_spdx_license(["GPL-2"]) == "GPL-2.0-only"
@@ -221,7 +227,10 @@ def test_new_license_variants():
221227
assert convert_to_spdx_license(["LGPL"]) == "LGPL-2.1-or-later"
222228
assert convert_to_spdx_license(["LGPLv2"]) == "LGPL-2.1-or-later"
223229
assert convert_to_spdx_license(["LGPL-2.1"]) == "LGPL-2.1-or-later"
230+
assert convert_to_spdx_license(["LGPL v2.1"]) == "LGPL-2.1-or-later"
224231
assert convert_to_spdx_license(["LGPLv3"]) == "LGPL-3.0-only"
232+
assert convert_to_spdx_license(["LGPL-v3"]) == "LGPL-3.0-only"
233+
assert convert_to_spdx_license(["GNU Lesser Public License 2.1"]) == "LGPL-2.1-only"
225234

226235
# AGPL variants
227236
assert convert_to_spdx_license(["AGPLv3"]) == "AGPL-3.0-only"
@@ -235,6 +244,26 @@ def test_new_license_variants():
235244
# MIT variants
236245
assert convert_to_spdx_license(["MIT License"]) == "MIT"
237246

247+
# Apache variants
248+
assert convert_to_spdx_license(["Apache-2"]) == "Apache-2.0"
249+
assert convert_to_spdx_license(["Apache 2.0 License"]) == "Apache-2.0"
250+
assert convert_to_spdx_license(["ALv2"]) == "Apache-2.0"
251+
252+
# MPL variants
253+
assert convert_to_spdx_license(["MPL-2.0 license"]) == "MPL-2.0"
254+
assert convert_to_spdx_license(["Mozilla Public License 2.0"]) == "MPL-2.0"
255+
256+
# Creative Commons variants
257+
assert (
258+
convert_to_spdx_license(
259+
[
260+
"Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License"
261+
]
262+
)
263+
== "CC-BY-NC-ND-4.0"
264+
)
265+
assert convert_to_spdx_license(["CC0"]) == "CC0-1.0"
266+
238267
# Public Domain
239268
assert convert_to_spdx_license(["Public Domain"]) == "Unlicense"
240269

0 commit comments

Comments
 (0)