Skip to content

Commit

Permalink
fix license script (valkey-io#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
shohamazon authored Feb 7, 2024
1 parent 48e563f commit 5f0f13d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions utils/get_licenses_from_ort.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"PSF-2.0",
]


class OrtResults:
def __init__(self, name: str, ort_results_folder: str) -> None:
"""
Expand Down Expand Up @@ -61,10 +62,10 @@ def __init__(self, name: str, ort_results_folder: str) -> None:
ort_result.notice_file, "r"
) as notice_file:
json_file = json.load(ort_results)
notice_file = notice_file.read()
notice_file_text = notice_file.read()
for package in json_file["analyzer"]["result"]["packages"]:
package_name = package["id"].split(":")[2]
if package_name not in notice_file:
if package_name not in notice_file_text:
# skip packages not in the final report
print(f"Skipping package {package_name}")
continue
Expand All @@ -79,11 +80,13 @@ def __init__(self, name: str, ort_results_folder: str) -> None:
else:
licenses_set.add(license)
except Exception:
print(f"Received error for package {package} used by {ort_result.name}\n Found license={license}")
print(
f"Received error for package {package} used by {ort_result.name}\n Found license={license}"
)
raise

print("\n\n#### Found Licenses #####\n")
licenses_set = sorted(licenses_set)
licenses_set = set(sorted(licenses_set))
for license in licenses_set:
print(f"{license}")

Expand Down

0 comments on commit 5f0f13d

Please sign in to comment.