add3prf.py: Support license files with extensions
Some crates place there license files in files with extensions, such as
LICENSE.txt or LICENSE-MIT.md.
We should account for extensions by removing them.
Bug: 321064939
Test: Ran script against `minimal-lexical-0.2.1` crate and added unit
tests
Change-Id: I0c385e8209969c0900909e764460fc551f07c20c
diff --git a/scripts/add3prf.py b/scripts/add3prf.py
index 6f808ef..44a8418 100755
--- a/scripts/add3prf.py
+++ b/scripts/add3prf.py
@@ -193,8 +193,8 @@
# Some crate like time-macros-impl uses lower case names like LICENSE-Apache.
licenses = []
license_file = None
- for license_file in glob.glob("LICENSE*") + glob.glob("COPYING*") + glob.glob("UNLICENSE"):
- lowered_name = license_file.lower()
+ for license_file in glob.glob("LICENSE*") + glob.glob("COPYING*") + glob.glob("UNLICENSE*"):
+ lowered_name = os.path.splitext(license_file.lower())[0]
if lowered_name == "license-apache":
licenses.append(License(LicenseType.APACHE2, LicenseGroup.NOTICE, license_file))
elif lowered_name == "license-mit":