From d59156fcd06db5540857230f3637e92258b41ab6 Mon Sep 17 00:00:00 2001 From: Jaekwon Bang Date: Tue, 27 Dec 2022 09:30:50 +0900 Subject: [PATCH] Add frequent license nick list file --- .reuse/dep5 | 4 ++ .../resources/frequent_license_nick_list.json | 39 +++++++++++++++++++ src/fosslight_util/spdx_licenses.py | 20 ++++++++++ 3 files changed, 63 insertions(+) create mode 100644 src/fosslight_util/resources/frequent_license_nick_list.json diff --git a/.reuse/dep5 b/.reuse/dep5 index d313177..149584e 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -26,6 +26,10 @@ Files: src/fosslight_util/resources/frequentLicenselist.json Copyright: 2021 LG Electronics License: Apache-2.0 +Files: src/fosslight_util/resources/frequent_license_nick_list.json +Copyright: 2022 LG Electronics +License: Apache-2.0 + Files: src/fosslight_util/resources/licenses.json Copyright: SPDX License: CC-BY-3.0 diff --git a/src/fosslight_util/resources/frequent_license_nick_list.json b/src/fosslight_util/resources/frequent_license_nick_list.json new file mode 100644 index 0000000..bee1a95 --- /dev/null +++ b/src/fosslight_util/resources/frequent_license_nick_list.json @@ -0,0 +1,39 @@ +{ + "gpl-2.0": "GPL-2.0-only", + "gpl2.0": "GPL-2.0-only", + "gpl 2.0": "GPL-2.0-only", + "gpl-2.0-only": "GPL-2.0-only", + "gpl-3.0": "GPL-3.0-only", + "gpl3.0": "GPL-3.0-only", + "gpl 3.0": "GPL-3.0-only", + "gpl-3.0-only": "GPL-3.0-only", + "lgpl-2.1": "LGPL-2.1-only", + "lgpl-2.0": "LGPL-2.1-only", + "lgpl 2.0": "LGPL-2.1-only", + "lgpl 2.1": "LGPL-2.1-only", + "lgpl2.0": "LGPL-2.1-only", + "lgpl2.1": "LGPL-2.1-only", + "lgpl-2.1-only": "LGPL-2.1-only", + "apache-2.0": "Apache-2.0", + "apache2.0": "Apache-2.0", + "apache 2.0": "Apache-2.0", + "bsd-3-clause": "BSD-3-clause", + "bsd 3 clause": "BSD-3-clause", + "bsd-3 clause": "BSD-3-clause", + "bsd 3-clause": "BSD-3-clause", + "agpl 3.0": "AGPL-3.0", + "apgl-3.0": "APGL-3.0", + "apgl3.0": "APGL-3.0", + "agplv3": "AGPL-3.0", + "mit": "MIT", + "epl-1.0": "EPL-1.0", + "epl 1.0": "EPL-1.0", + "epl1.0": "EPL-1.0", + "epl-2.0": "EPL-2.0", + "epl 2.0": "EPL-2.0", + "epl2.0": "EPL-2.0", + "lge": "LicenseRef-LGE_Proprietary_License", + "lge license": "LicenseRef-LGE_Proprietary_License", + "lge proprietary": "LicenseRef-LGE_Proprietary_License", + "lge-proprietary": "LicenseRef-LGE_Proprietary_License" +} diff --git a/src/fosslight_util/spdx_licenses.py b/src/fosslight_util/spdx_licenses.py index a2dbe04..b150785 100755 --- a/src/fosslight_util/spdx_licenses.py +++ b/src/fosslight_util/spdx_licenses.py @@ -12,6 +12,26 @@ _resources_dir = 'resources' _licenses_json_file = 'licenses.json' _frequentLicenselist_file = 'frequentLicenselist.json' +_frequent_lic_nick_json_file = 'frequent_license_nick_list.json' + + +def get_license_from_nick(): + licenses = {} + licenses_file = os.path.join(_resources_dir, _frequent_lic_nick_json_file) + + try: + base_dir = sys._MEIPASS + except Exception: + base_dir = os.path.dirname(__file__) + + file_withpath = os.path.join(base_dir, licenses_file) + try: + with open(file_withpath, 'r') as f: + licenses = json.load(f) + except Exception as ex: + print(f"Error to get license from json file : {ex}") + + return licenses def get_spdx_licenses_json():