add3prf.py: Add support for Boost license

Bug: 321067451
Test: Run against `ryu-1.0.15` crate and add unit test
Change-Id: Ie37e173e73bc0b3c75dd6d83f8c0ef48e428a395
diff --git a/scripts/add3prf.py b/scripts/add3prf.py
index 0d71f3e..60dfcc1 100755
--- a/scripts/add3prf.py
+++ b/scripts/add3prf.py
@@ -45,6 +45,8 @@
 # patterns to match different licence types in LICENSE*
 APACHE_PATTERN = r"^.*Apache License.*$"
 APACHE_MATCHER = re.compile(APACHE_PATTERN)
+BOOST_PATTERN = r"^.Boost Software License.*Version 1.0.*$"
+BOOST_MATCHER = re.compile(BOOST_PATTERN)
 MIT_PATTERN = r"^.*MIT License.*$"
 MIT_MATCHER = re.compile(MIT_PATTERN)
 BSD_PATTERN = r"^.*BSD .*License.*$"
@@ -139,6 +141,8 @@
     for line in input_file:
       if APACHE_MATCHER.match(line):
         return License(LicenseType.APACHE2, LicenseGroup.NOTICE, license_file)
+      if BOOST_MATCHER.match(line):
+        return License(LicenseType.BOOST, LicenseGroup.NOTICE, license_file)
       if MIT_MATCHER.match(line):
         return License(LicenseType.MIT, LicenseGroup.NOTICE, license_file)
       if BSD_MATCHER.match(line):
@@ -171,6 +175,7 @@
   ZERO_BSD = 6
   UNLICENSE = 7
   ZLIB = 8
+  BOOST = 9
 
 class LicenseGroup(enum.Enum):
   """A group of license as defined by go/thirdpartylicenses#types
@@ -202,6 +207,8 @@
     lowered_name = os.path.splitext(license_file.lower())[0]
     if lowered_name == "license-apache":
       licenses.append(License(LicenseType.APACHE2, LicenseGroup.NOTICE, license_file))
+    if lowered_name == "license-boost":
+      licenses.append(License(LicenseType.BOOST, LicenseGroup.NOTICE, license_file))
     elif lowered_name == "license-mit":
       licenses.append(License(LicenseType.MIT, LicenseGroup.NOTICE, license_file))
     elif lowered_name == "license-0bsd":
@@ -219,6 +226,8 @@
   # Cargo.toml.
   if "Apache" in cargo_license:
     return [License(LicenseType.APACHE2, LicenseGroup.NOTICE, license_file)]
+  if "BSL" in cargo_license:
+    return [License(LicenseType.BOOST, LicenseGroup.NOTICE, license_file)]
   if "MIT" in cargo_license:
     return [License(LicenseType.MIT, LicenseGroup.NOTICE, license_file)]
   if "0BSD" in cargo_license:
@@ -271,7 +280,7 @@
 def add_module_license(license_type):
   """Touch MODULE_LICENSE_type file."""
   # Do not change existing MODULE_* files.
-  for suffix in ["MIT", "APACHE", "APACHE2", "BSD_LIKE", "MPL", "0BSD", "UNLICENSE", "ZLIB"]:
+  for suffix in ["MIT", "APACHE", "APACHE2", "BSD_LIKE", "MPL", "0BSD", "UNLICENSE", "ZLIB", "BOOST"]:
     module_file = "MODULE_LICENSE_" + suffix
     if os.path.exists(module_file):
       if license_type.name != suffix: