forked from fosslight/fosslight_util
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from fosslight/develop
Add the function to write opossum format result file and modify the function write result file.
- Loading branch information
Showing
13 changed files
with
8,918 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ tox | |
pytest | ||
pytest-cov | ||
pytest-flake8 | ||
flake8==3.9.2 | ||
tox-wheel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021 LG Electronics Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from urllib.request import urlopen | ||
import os | ||
import json | ||
import traceback | ||
|
||
|
||
def create_frequentlicenses(): | ||
success = True | ||
error_msg = '' | ||
licenses = '' | ||
licenses_file = 'licenses.json' | ||
frequentLicenses = {} | ||
_frequentLicenses_key = 'frequentLicenses' | ||
|
||
# spdx_txt_url = _spdx_txt_base_url + version + /text/ + licenseId + '.txt' | ||
_spdx_txt_base_url = 'https://raw.githubusercontent.com/spdx/license-list-data/' | ||
|
||
base_dir = os.path.dirname(__file__) | ||
# https://github.com/spdx/license-list-data/blob/v3.14/json/licenses.json | ||
file_withpath = os.path.join(base_dir, licenses_file) | ||
|
||
try: | ||
with open(file_withpath, 'r') as f: | ||
licenses = json.load(f) | ||
version = licenses['licenseListVersion'] | ||
frequentLicenses[_frequentLicenses_key] = [] | ||
for lic in licenses['licenses']: | ||
tmp_lic = {} | ||
tmp_lic["fullName"] = lic['name'] | ||
tmp_lic["shortName"] = lic['licenseId'] | ||
|
||
deprecated = lic['isDeprecatedLicenseId'] | ||
if deprecated: | ||
spdx_txt_url = _spdx_txt_base_url + 'v' + version + '/text/' + 'deprecated_' + lic['licenseId'] + '.txt' | ||
else: | ||
spdx_txt_url = _spdx_txt_base_url + 'v' + version + '/text/' + lic['licenseId'] + '.txt' | ||
|
||
with urlopen(spdx_txt_url) as url: | ||
licenseText = url.read().decode('utf-8') | ||
tmp_lic["defaultText"] = licenseText | ||
|
||
frequentLicenses[_frequentLicenses_key].append(tmp_lic) | ||
|
||
except Exception as e: | ||
success = False | ||
error_msg = 'Failed to open and parse ' + licenses_file | ||
print(error_msg, ": ", e) | ||
print(traceback.format_exc()) | ||
|
||
return frequentLicenses, success, error_msg | ||
|
||
|
||
def main(): | ||
_frequencyLicense = 'frequentLicenselist.json' | ||
frequentLicenses, success, error_msg = create_frequentlicenses() | ||
if success: | ||
with open(_frequencyLicense, 'w', encoding='utf-8') as f: | ||
json.dump(frequentLicenses, f, sort_keys=True, indent=4) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.