Skip to content

Commit 8a5a2a9

Browse files
Remove unnecessary changes and fix flake8
Signed-off-by: Wonjae Park <[email protected]>
1 parent 5ec2fb0 commit 8a5a2a9

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/fosslight_source/_parsing_scancode_file_item.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
KEY_OR = r"(?<=\s)or(?=\s)"
3535

3636

37-
3837
def get_error_from_header(header_item: list) -> Tuple[bool, str]:
3938
has_error = False
4039
str_error = ""
@@ -166,8 +165,12 @@ def parsing_scancode_32_earlier(scancode_file_list: list, has_error: bool = Fals
166165
result_item.is_license_text = matched_rule.get("is_license_text", False)
167166

168167
if len(license_detected) > 0:
169-
# unknown-license-reference를 제거하고 lge-proprietary만 남김
170-
if KEYWORD_UNKNOWN_LICENSE_REFERENCE.lower() in [x.lower() for x in license_detected] and KEYWORD_LGE_PROPRIETARY.lower() in [x.lower() for x in license_detected]:
168+
# Remove unknown-license-reference and leave only lge-proprietary
169+
license_lower = [x.lower() for x in license_detected]
170+
if (
171+
KEYWORD_UNKNOWN_LICENSE_REFERENCE.lower() in license_lower
172+
and KEYWORD_LGE_PROPRIETARY.lower() in license_lower
173+
):
171174
license_detected.remove(KEYWORD_UNKNOWN_LICENSE_REFERENCE)
172175
result_item.licenses = license_detected
173176

@@ -236,22 +239,22 @@ def parsing_scancode_32_later(
236239
licenses = file.get("license_detections", [])
237240
if not licenses:
238241
continue
239-
print("file path:", file.get('path', ''))
240242
for lic in licenses:
241243
matched_lic_list = lic.get("matches", [])
242244
for matched_lic in matched_lic_list:
243245
found_lic_list = matched_lic.get("license_expression", "")
244-
print("found_lic_list:", found_lic_list)
245246
matched_txt = matched_lic.get("matched_text", "")
246-
print("matched_txt:", matched_txt)
247247
if found_lic_list:
248248
found_lic_list = found_lic_list.lower()
249249
for found_lic in split_spdx_expression(found_lic_list):
250250
if found_lic:
251251
found_lic = found_lic.strip()
252252
if found_lic in REMOVE_LICENSE:
253253
continue
254-
elif found_lic == KEYWORD_SCANCODE_UNKNOWN or found_lic == KEYWORD_SCANCODE_PROPRIETARY_LICENSE:
254+
elif (
255+
found_lic == KEYWORD_SCANCODE_UNKNOWN
256+
or found_lic == KEYWORD_SCANCODE_PROPRIETARY_LICENSE
257+
):
255258
try:
256259
matched = regex.search(matched_txt.lower())
257260
if matched:
@@ -268,11 +271,15 @@ def parsing_scancode_32_later(
268271
lic_info = MatchedLicense(found_lic, "", matched_txt, file_path)
269272
license_list[lic_matched_key] = lic_info
270273
license_detected.append(found_lic)
271-
272-
# unknown-license-reference를 제거하고 lge-proprietary만 남김
273-
if KEYWORD_UNKNOWN_LICENSE_REFERENCE.lower() in [x.lower() for x in license_detected] and KEYWORD_LGE_PROPRIETARY.lower() in [x.lower() for x in license_detected]:
274+
275+
# Remove unknown-license-reference and leave only lge-proprietary
276+
license_lower = [x.lower() for x in license_detected]
277+
if (
278+
KEYWORD_UNKNOWN_LICENSE_REFERENCE.lower() in license_lower
279+
and KEYWORD_LGE_PROPRIETARY.lower() in license_lower
280+
):
274281
license_detected.remove(KEYWORD_UNKNOWN_LICENSE_REFERENCE)
275-
282+
276283
result_item.licenses = license_detected
277284
if len(license_detected) > 1:
278285
license_expression_spdx = file.get("detected_license_expression_spdx", "")

tox.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ commands =
4141
pytest -v --flake8
4242

4343
[testenv:flake8]
44+
basepython = python3.11
4445
deps = flake8
45-
commands =
46-
pytest tests/test_tox.py::test_flake8
46+
changedir = {toxinidir}
47+
commands =
48+
flake8 src/fosslight_source tests

0 commit comments

Comments
 (0)