<!--
Copyright (c) 2021 LG Electronics
SPDX-License-Identifier: Apache-2.0
-->
# FOSSLight Util
<img src="https://img.shields.io/pypi/l/fosslight_util" alt="FOSSLight Util is released under the Apache-2.0." /> <img src="https://img.shields.io/pypi/v/fosslight_util" alt="Current python package version." /> <img src="https://img.shields.io/pypi/pyversions/fosslight_util" /> [](https://api.reuse.software/info/github.com/fosslight/fosslight_util)
It is a package that supports common utils used by FOSSLight Scanner.
## Features
1. It simplifies the logger setup.
2. It provides a simple function to create a output file.
3. It provides a spdx license list with json format.
4. It defines common constant variables.
5. It provides a thread that prints the spinner.
6. Download source code.
[or]: http://collab.lge.com/main/x/xDHlFg
## Contents
- [Prerequisite](#-prerequisite)
- [How to install](#-how-to-install)
- [How to run](#-how-to-run)
- [How to report issue](#-how-to-report-issue)
- [License](#-license)
## 📋 Prerequisite
FOSSLight Util needs a Python 3.10+.
## 🎉 How to install
It can be installed using pip3.
```
$ pip3 install fosslight_util
```
## 🚀 How to use
Three modules can be called. Please refer to each file for detailed calling method.
### 1. Setup logger (tests/test_log.py)
```
from fosslight_util.set_log import init_log
# 1st param : log file path
# 2nd param : create file (True/False)
# 3rd param : stream log level
# 4th param : file log level
# =>log level(CRITICAL:50, ERROR:40, WARNING:30, INFO:20, DEBUG:10, NOTSET:0)
# 5th param : package name of fosslight scanners (fosslight_source / fosslight_dependency / fosslight_reuse)
# 6th param : path to analyze
#
# 1st return value : a logger
# 2nd return value : log items to print
def test():
logger, log_item = init_log("test_result/log_file1.txt", True, 30, 20)
logger.warning("TESTING - Print log")
```
### 2. Write result files (tests/test_output_format.py)
```
from fosslight_util.output_format import write_output_file
# 2nd param : output file format
# => file format(excel: .xlsx, csv: .csv, opossum: .json)
def test():
sheet_contents = {'SRC':[['run_scancode.py', 'fosslight_source',
'3.0.6', 'Apache-2.0', 'https://github.com/LGE-OSS/fosslight_source', 'https://github.com/LGE-OSS/fosslight_source', 'Copyright (c) 2021 LG Electronics, Inc.', 'Exclude', 'Comment message'],
['dependency_unified.py', 'fosslight_dependency',
'3.0.6', 'Apache-2.0', 'https://github.com/LGE-OSS/fosslight_dependency', 'https://github.com/LGE-OSS/fosslight_dependency', 'Copyright (c) 2020 LG Electronics, Inc.', '', '']],
'BIN':[['askalono.exe', 'askalono',
'0.4.3', 'Apache-2.0', 'https://github.com/jpeddicord/askalono', '', 'Copyright (c) 2018 Amazon.com, Inc. or its affiliates.', '', '']]}
success, msg = write_output_file('test_result/excel/FOSSLight-Report', '.xlsx', sheet_contents)
```
### 3. Get spdx licenses (tests/test_spdx_licenses.py)
```
from fosslight_util.spdx_licenses import get_spdx_licenses_json
def test():
success, error_msg, licenses = get_spdx_licenses_json()
```
### 4. Load common constant (tests/_print_log_with_another_logger.py)
```
import fosslight_util.constant as constant
logger = logging.getLogger(constant.LOGGER_NAME)
logger.warning("Get a logger after init_log is called once.")
```
### 5. Call a spinner (tests/test_timer.py)
```
from fosslight_util.timer_thread import TimerThread
timer = TimerThread()
timer.setDaemon(True)
timer.start()
```
### 6. Download the source code (tests/test_download.py)
If you give a link, the source is downloaded to the target directory through git clone or wget.
#### How it works
1. Try git clone.
1-1. If the link is ssh-url, convert to https-url.
2. If git clone fails, download it with wget and extract the compressed file.
3. After extracting the compressed file, delete the compressed file.
#### Parameters
| Parameter | Argument | Description |
| ------------- | ------------- | ------------- |
| h | None | Print help message. |
| s | String | Link to download. |
| t | String | Path to download and extract. |
| d | String | Path to save a log file. |
#### How to run
```
$ fosslight_download -s "https://github.com/LGE-OSS/example" -t target_dir/
```
If you want to try with private repository, set your github token like below.
```
$ fosslight_download -s "https://my_github_token@github.com/Foo/private_repo -t target_dir/"
```
## 👏 How to report issue
Please report any ideas or bugs to improve by creating an issue in [fosslight_util repository][cl]. Then there will be quick bug fixes and upgrades. Ideas to improve are always welcome.
[cl]: https://github.com/fosslight/fosslight_util/issues
## 📄 License
FOSSLight Util is released under [Apache-2.0][l].
[l]: https://github.com/fosslight/fosslight_util/blob/main/LICENSE
Raw data
{
"_id": null,
"home_page": "https://github.com/fosslight/fosslight_util",
"name": "fosslight-util",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "LG Electronics",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/1e/4f/232e416aa980b5c180677589a1b5e9e6b1efbc440c25396b74d59c43a99f/fosslight_util-2.1.21.tar.gz",
"platform": null,
"description": "<!--\nCopyright (c) 2021 LG Electronics\nSPDX-License-Identifier: Apache-2.0\n -->\n # FOSSLight Util\n\n<img src=\"https://img.shields.io/pypi/l/fosslight_util\" alt=\"FOSSLight Util is released under the Apache-2.0.\" /> <img src=\"https://img.shields.io/pypi/v/fosslight_util\" alt=\"Current python package version.\" /> <img src=\"https://img.shields.io/pypi/pyversions/fosslight_util\" /> [](https://api.reuse.software/info/github.com/fosslight/fosslight_util)\n\nIt is a package that supports common utils used by FOSSLight Scanner.\n\n## Features \n1. It simplifies the logger setup.\n2. It provides a simple function to create a output file.\n3. It provides a spdx license list with json format.\n4. It defines common constant variables.\n5. It provides a thread that prints the spinner.\n6. Download source code.\n\n[or]: http://collab.lge.com/main/x/xDHlFg\n\n## Contents\n\n- [Prerequisite](#-prerequisite)\n- [How to install](#-how-to-install)\n- [How to run](#-how-to-run)\n- [How to report issue](#-how-to-report-issue)\n- [License](#-license)\n\n\n## \ud83d\udccb Prerequisite\n\nFOSSLight Util needs a Python 3.10+.\n\n## \ud83c\udf89 How to install\n\nIt can be installed using pip3. \n\n```\n$ pip3 install fosslight_util\n```\n\n## \ud83d\ude80 How to use\n\nThree modules can be called. Please refer to each file for detailed calling method.\n\n \n### 1. Setup logger (tests/test_log.py)\n```\nfrom fosslight_util.set_log import init_log\n\n# 1st param : log file path\n# 2nd param : create file (True/False)\n# 3rd param : stream log level\n# 4th param : file log level\n# =>log level(CRITICAL:50, ERROR:40, WARNING:30, INFO:20, DEBUG:10, NOTSET:0)\n# 5th param : package name of fosslight scanners (fosslight_source / fosslight_dependency / fosslight_reuse)\n# 6th param : path to analyze\n#\n# 1st return value : a logger\n# 2nd return value : log items to print\n\ndef test():\n logger, log_item = init_log(\"test_result/log_file1.txt\", True, 30, 20)\n logger.warning(\"TESTING - Print log\")\n```\n\n \n### 2. Write result files (tests/test_output_format.py)\n```\nfrom fosslight_util.output_format import write_output_file\n\n# 2nd param : output file format\n# => file format(excel: .xlsx, csv: .csv, opossum: .json)\ndef test():\n sheet_contents = {'SRC':[['run_scancode.py', 'fosslight_source',\n '3.0.6', 'Apache-2.0', 'https://github.com/LGE-OSS/fosslight_source', 'https://github.com/LGE-OSS/fosslight_source', 'Copyright (c) 2021 LG Electronics, Inc.', 'Exclude', 'Comment message'],\n ['dependency_unified.py', 'fosslight_dependency',\n '3.0.6', 'Apache-2.0', 'https://github.com/LGE-OSS/fosslight_dependency', 'https://github.com/LGE-OSS/fosslight_dependency', 'Copyright (c) 2020 LG Electronics, Inc.', '', '']],\n 'BIN':[['askalono.exe', 'askalono',\n '0.4.3', 'Apache-2.0', 'https://github.com/jpeddicord/askalono', '', 'Copyright (c) 2018 Amazon.com, Inc. or its affiliates.', '', '']]}\n success, msg = write_output_file('test_result/excel/FOSSLight-Report', '.xlsx', sheet_contents)\n```\n \n### 3. Get spdx licenses (tests/test_spdx_licenses.py)\n```\nfrom fosslight_util.spdx_licenses import get_spdx_licenses_json\n\n\ndef test():\n success, error_msg, licenses = get_spdx_licenses_json()\n```\n\n### 4. Load common constant (tests/_print_log_with_another_logger.py)\n```\nimport fosslight_util.constant as constant\n\n\nlogger = logging.getLogger(constant.LOGGER_NAME)\nlogger.warning(\"Get a logger after init_log is called once.\")\n```\n\n### 5. Call a spinner (tests/test_timer.py)\n```\nfrom fosslight_util.timer_thread import TimerThread\n\n\ntimer = TimerThread()\ntimer.setDaemon(True)\ntimer.start()\n```\n\n### 6. Download the source code (tests/test_download.py)\nIf you give a link, the source is downloaded to the target directory through git clone or wget.\n\n#### How it works\n1. Try git clone.\n1-1. If the link is ssh-url, convert to https-url.\n2. If git clone fails, download it with wget and extract the compressed file.\n3. After extracting the compressed file, delete the compressed file.\n\n#### Parameters \n| Parameter | Argument | Description |\n| ------------- | ------------- | ------------- |\n| h | None | Print help message. | \n| s | String | Link to download. | \n| t | String | Path to download and extract. |\n| d | String | Path to save a log file. | \n\n#### How to run\n```\n$ fosslight_download -s \"https://github.com/LGE-OSS/example\" -t target_dir/\n```\nIf you want to try with private repository, set your github token like below.\n```\n$ fosslight_download -s \"https://my_github_token@github.com/Foo/private_repo -t target_dir/\"\n```\n\n## \ud83d\udc4f How to report issue\n\nPlease report any ideas or bugs to improve by creating an issue in [fosslight_util repository][cl]. Then there will be quick bug fixes and upgrades. Ideas to improve are always welcome.\n\n[cl]: https://github.com/fosslight/fosslight_util/issues\n\n## \ud83d\udcc4 License\n\nFOSSLight Util is released under [Apache-2.0][l].\n\n[l]: https://github.com/fosslight/fosslight_util/blob/main/LICENSE\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "FOSSLight Util",
"version": "2.1.21",
"project_urls": {
"Download": "https://github.com/fosslight/fosslight_util",
"Homepage": "https://github.com/fosslight/fosslight_util"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "992f8a15afd81e11563fbdc05543b4f82792136f6256dd5329764fbc514bb1c7",
"md5": "0994117fd01565a3fa7b5e37fee6db9c",
"sha256": "10fc671c0b377fdf6039affe1f41406e4ea965810b27a0aedda7656f8a3e13f9"
},
"downloads": -1,
"filename": "fosslight_util-2.1.21-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0994117fd01565a3fa7b5e37fee6db9c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 944045,
"upload_time": "2025-07-22T06:46:08",
"upload_time_iso_8601": "2025-07-22T06:46:08.797675Z",
"url": "https://files.pythonhosted.org/packages/99/2f/8a15afd81e11563fbdc05543b4f82792136f6256dd5329764fbc514bb1c7/fosslight_util-2.1.21-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1e4f232e416aa980b5c180677589a1b5e9e6b1efbc440c25396b74d59c43a99f",
"md5": "b532606274ddc82b007e146c9c1150a2",
"sha256": "a5ace1e882e2cf2809c3c954f2273bfd4aa6559dc387908d83f559bfc4db0890"
},
"downloads": -1,
"filename": "fosslight_util-2.1.21.tar.gz",
"has_sig": false,
"md5_digest": "b532606274ddc82b007e146c9c1150a2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 930380,
"upload_time": "2025-07-22T06:46:10",
"upload_time_iso_8601": "2025-07-22T06:46:10.392479Z",
"url": "https://files.pythonhosted.org/packages/1e/4f/232e416aa980b5c180677589a1b5e9e6b1efbc440c25396b74d59c43a99f/fosslight_util-2.1.21.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-22 06:46:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fosslight",
"github_project": "fosslight_util",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "XlsxWriter",
"specs": []
},
{
"name": "pandas",
"specs": []
},
{
"name": "openpyxl",
"specs": []
},
{
"name": "progress",
"specs": []
},
{
"name": "PyYAML",
"specs": []
},
{
"name": "lastversion",
"specs": []
},
{
"name": "coloredlogs",
"specs": []
},
{
"name": "python3-wget",
"specs": []
},
{
"name": "beautifulsoup4",
"specs": []
},
{
"name": "jsonmerge",
"specs": []
},
{
"name": "spdx-tools",
"specs": [
[
"==",
"0.8.*"
]
]
},
{
"name": "setuptools",
"specs": [
[
">=",
"65.5.1"
]
]
},
{
"name": "numpy",
"specs": []
},
{
"name": "requests",
"specs": []
},
{
"name": "GitPython",
"specs": []
},
{
"name": "cyclonedx-python-lib",
"specs": [
[
"==",
"8.5.*"
]
]
}
],
"tox": true,
"lcname": "fosslight-util"
}