Skip to content

Commit dee7703

Browse files
Apply comment
Signed-off-by: Wonjae Park <[email protected]>
1 parent 3561edf commit dee7703

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/fosslight_source/_parsing_scancode_file_item.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,7 @@
3030
SPDX_REPLACE_WORDS = ["(", ")"]
3131
KEY_AND = r"(?<=\s)and(?=\s)"
3232
KEY_OR = r"(?<=\s)or(?=\s)"
33-
GPL_LICENSE_PATTERNS = [
34-
r'gpl', # gpl, gpl-2.0, gpl-3.0
35-
r'lgpl', # lgpl, lgpl-2.1, lgpl-3.0
36-
r'agpl', # agpl, agpl-3.0
37-
r'gnu.*general.*public.*license', # GNU General Public License
38-
r'gnu.*lesser.*general.*public.*license', # GNU Lesser General Public License
39-
r'gnu.*affero.*general.*public.*license' # GNU Affero General Public License
40-
]
33+
GPL_LICENSE_PATTERN = r'((a|l)?gpl|gfdl)' # GPL, LGPL, AGPL, GFDL
4134

4235

4336
def is_gpl_family_license(licenses: list) -> bool:
@@ -49,10 +42,9 @@ def is_gpl_family_license(licenses: list) -> bool:
4942
continue
5043

5144
license_lower = license_name.lower()
52-
for pattern in GPL_LICENSE_PATTERNS:
53-
if re.search(pattern, license_lower):
54-
logger.debug(f"GPL family license detected: {license_name}")
55-
return True
45+
if re.search(GPL_LICENSE_PATTERN, license_lower):
46+
logger.debug(f"GPL family license detected: {license_name}")
47+
return True
5648

5749
return False
5850

tests/test_tox.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ def test_is_gpl_family_license():
4646
["GPL-2.0"],
4747
["LGPL-2.1"],
4848
["AGPL-3.0"],
49-
["gnu-general-public-license"],
50-
["gnu-lesser-general-public-license"],
51-
["gnu-affero-general-public-license"],
49+
["gpl-2.0-only"],
50+
["lgpl-2.1-only"],
51+
["agpl-3.0-only"],
52+
["gfdl-1.3"],
5253
["gpl-2.0", "mit"],
5354
["mit", "lgpl-3.0"]
5455
]

0 commit comments

Comments
 (0)