fosslight-util 2.2.1__tar.gz → 2.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fosslight_util-2.2.1/src/fosslight_util.egg-info → fosslight_util-2.2.2}/PKG-INFO +1 -1
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/pyproject.toml +1 -1
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/cover.py +29 -8
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/oss_item.py +6 -0
- fosslight_util-2.2.2/src/fosslight_util/time.py +60 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2/src/fosslight_util.egg-info}/PKG-INFO +1 -1
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util.egg-info/SOURCES.txt +1 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/LICENSE +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/MANIFEST.in +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/README.md +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/setup.cfg +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/__init__.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/_get_downloadable_url.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/compare_yaml.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/constant.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/correct.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/download.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/exclude.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/get_pom_license.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/help.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/output_format.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/parsing_yaml.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/read_excel.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/resources/frequentLicenselist.json +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/resources/frequent_license_nick_list.json +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/resources/licenses.json +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/set_log.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/spdx_licenses.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/timer_thread.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/write_cyclonedx.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/write_excel.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/write_opossum.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/write_scancodejson.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/write_spdx.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/write_txt.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/write_yaml.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util.egg-info/dependency_links.txt +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util.egg-info/entry_points.txt +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util.egg-info/requires.txt +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util.egg-info/top_level.txt +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/tests/test_cyclonedx.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/tests/test_decide_checkout.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/tests/test_download.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/tests/test_download_version_hint.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/tests/test_opossum.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/tests/test_spdx_licenses.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/tests/test_text.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/tests/test_write_excel_hidden_sheet.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/tests/test_write_output.py +0 -0
- {fosslight_util-2.2.1 → fosslight_util-2.2.2}/tests/test_write_yaml.py +0 -0
|
@@ -4,13 +4,22 @@
|
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
|
|
6
6
|
import os
|
|
7
|
+
import re
|
|
7
8
|
import sys
|
|
9
|
+
import yaml
|
|
8
10
|
from fosslight_util.help import print_package_version
|
|
11
|
+
from fosslight_util.time import format_display_time, format_running_time
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def dump_result_log(result_log):
|
|
15
|
+
log_text = yaml.safe_dump(result_log, allow_unicode=True, sort_keys=True)
|
|
16
|
+
log_text = re.sub(r"Running time: ['\"](.+?)['\"]\n", r"Running time: \1\n", log_text)
|
|
17
|
+
return log_text.strip()
|
|
9
18
|
|
|
10
19
|
|
|
11
20
|
class CoverItem:
|
|
12
21
|
tool_name_key = "Tool information"
|
|
13
|
-
start_time_key = "
|
|
22
|
+
start_time_key = "Running time"
|
|
14
23
|
python_ver_key = "Python version"
|
|
15
24
|
analyzed_path_key = "Analyzed path"
|
|
16
25
|
excluded_path_key = "Excluded path"
|
|
@@ -23,7 +32,8 @@ class CoverItem:
|
|
|
23
32
|
"fosslight_binary"
|
|
24
33
|
]
|
|
25
34
|
|
|
26
|
-
def __init__(self, tool_name="", start_time="", input_path="", comment="", exclude_path=[], simple_mode=True
|
|
35
|
+
def __init__(self, tool_name="", start_time="", input_path="", comment="", exclude_path=[], simple_mode=True,
|
|
36
|
+
finish_time=""):
|
|
27
37
|
if simple_mode:
|
|
28
38
|
self.tool_name = f'{tool_name} v{print_package_version(tool_name, "", False)}'
|
|
29
39
|
else:
|
|
@@ -34,11 +44,9 @@ class CoverItem:
|
|
|
34
44
|
])
|
|
35
45
|
self.tool_name = f'{first_pkg} ({remaining_pkgs})'
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
else:
|
|
41
|
-
self.start_time = ""
|
|
47
|
+
self.start_time = start_time
|
|
48
|
+
self.finish_time = finish_time
|
|
49
|
+
self.running_time = self._format_running_time()
|
|
42
50
|
self.input_path = os.path.abspath(input_path)
|
|
43
51
|
self.exclude_path = ", ".join(exclude_path)
|
|
44
52
|
self.comment = comment
|
|
@@ -57,6 +65,19 @@ class CoverItem:
|
|
|
57
65
|
def __lt__(self, other):
|
|
58
66
|
return self.get_sort_order() < other.get_sort_order()
|
|
59
67
|
|
|
68
|
+
def set_finish_time(self, finish_time):
|
|
69
|
+
self.finish_time = finish_time
|
|
70
|
+
self.running_time = self._format_running_time()
|
|
71
|
+
|
|
72
|
+
def _format_running_time(self):
|
|
73
|
+
if not self.start_time:
|
|
74
|
+
return ""
|
|
75
|
+
|
|
76
|
+
if not self.finish_time:
|
|
77
|
+
return format_display_time(self.start_time)
|
|
78
|
+
|
|
79
|
+
return format_running_time(self.start_time, self.finish_time)
|
|
80
|
+
|
|
60
81
|
def create_merged_comment(self, cover_items):
|
|
61
82
|
if not cover_items:
|
|
62
83
|
return ""
|
|
@@ -69,7 +90,7 @@ class CoverItem:
|
|
|
69
90
|
def get_print_json(self):
|
|
70
91
|
json_item = {}
|
|
71
92
|
json_item[self.tool_name_key] = self.tool_name
|
|
72
|
-
json_item[self.start_time_key] = self.
|
|
93
|
+
json_item[self.start_time_key] = self.running_time
|
|
73
94
|
json_item[self.python_ver_key] = self.python_version
|
|
74
95
|
json_item[self.analyzed_path_key] = self.input_path
|
|
75
96
|
json_item[self.excluded_path_key] = self.exclude_path
|
|
@@ -8,6 +8,7 @@ import os
|
|
|
8
8
|
import hashlib
|
|
9
9
|
from fosslight_util.constant import LOGGER_NAME, FOSSLIGHT_SCANNER, COMMENT_DELIMITER
|
|
10
10
|
from fosslight_util.cover import CoverItem
|
|
11
|
+
from fosslight_util.time import current_timestamp_utc
|
|
11
12
|
from typing import List, Dict
|
|
12
13
|
|
|
13
14
|
_logger = logging.getLogger(LOGGER_NAME)
|
|
@@ -211,6 +212,11 @@ class ScannerItem:
|
|
|
211
212
|
else:
|
|
212
213
|
self.cover.comment = value
|
|
213
214
|
|
|
215
|
+
def set_cover_finish_time(self, finish_time=""):
|
|
216
|
+
if not finish_time:
|
|
217
|
+
finish_time = current_timestamp_utc()
|
|
218
|
+
self.cover.set_finish_time(finish_time)
|
|
219
|
+
|
|
214
220
|
def get_cover_comment(self):
|
|
215
221
|
return [item.strip() for item in self.cover.comment.split(COMMENT_DELIMITER)]
|
|
216
222
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# Copyright (c) 2024 LG Electronics Inc.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
from datetime import datetime, timezone, timedelta
|
|
7
|
+
|
|
8
|
+
_TIMESTAMP_FMT = '%Y%m%d_%H%M%S'
|
|
9
|
+
_DISPLAY_TZ = timezone(timedelta(hours=9)) # KST (UTC+9)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def current_timestamp_utc() -> str:
|
|
13
|
+
"""Return current time as UTC wall-clock string for internal storage."""
|
|
14
|
+
return datetime.now(timezone.utc).strftime(_TIMESTAMP_FMT)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def timestamp_for_filename(utc_timestamp: str) -> str:
|
|
18
|
+
"""Convert UTC storage timestamp to KST for file and directory names."""
|
|
19
|
+
if not utc_timestamp:
|
|
20
|
+
return current_timestamp_for_filename()
|
|
21
|
+
return _parse_utc_timestamp(utc_timestamp).astimezone(_DISPLAY_TZ).strftime(_TIMESTAMP_FMT)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def current_timestamp_for_filename() -> str:
|
|
25
|
+
"""Return current time as KST wall-clock string for file and directory names."""
|
|
26
|
+
return timestamp_for_filename(current_timestamp_utc())
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _parse_utc_timestamp(value: str) -> datetime:
|
|
30
|
+
return datetime.strptime(value, _TIMESTAMP_FMT).replace(tzinfo=timezone.utc)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def format_display_time(value: str) -> str:
|
|
34
|
+
return _parse_utc_timestamp(value).astimezone(_DISPLAY_TZ).strftime('%Y%m%d_%H:%M:%S')
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _format_duration_compact(total_seconds: int) -> str:
|
|
38
|
+
total_seconds = max(0, total_seconds)
|
|
39
|
+
hours, remaining_seconds = divmod(total_seconds, 3600)
|
|
40
|
+
minutes, seconds = divmod(remaining_seconds, 60)
|
|
41
|
+
|
|
42
|
+
duration_items = []
|
|
43
|
+
if hours > 0:
|
|
44
|
+
duration_items.append(f'{hours}h')
|
|
45
|
+
if minutes > 0:
|
|
46
|
+
duration_items.append(f'{minutes}m')
|
|
47
|
+
duration_items.append(f'{seconds}s')
|
|
48
|
+
return f'({" ".join(duration_items)})'
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def format_running_time(start_time: str, finish_time: str) -> str:
|
|
52
|
+
start_utc = _parse_utc_timestamp(start_time)
|
|
53
|
+
finish_utc = _parse_utc_timestamp(finish_time)
|
|
54
|
+
total_seconds = int((finish_utc - start_utc).total_seconds())
|
|
55
|
+
|
|
56
|
+
start_display = start_utc.astimezone(_DISPLAY_TZ).strftime('%Y%m%d_%H:%M:%S')
|
|
57
|
+
finish_display = finish_utc.astimezone(_DISPLAY_TZ).strftime('%Y%m%d_%H:%M:%S')
|
|
58
|
+
duration = _format_duration_compact(total_seconds)
|
|
59
|
+
|
|
60
|
+
return f'{start_display} ~ {finish_display} {duration}'
|
|
@@ -18,6 +18,7 @@ src/fosslight_util/parsing_yaml.py
|
|
|
18
18
|
src/fosslight_util/read_excel.py
|
|
19
19
|
src/fosslight_util/set_log.py
|
|
20
20
|
src/fosslight_util/spdx_licenses.py
|
|
21
|
+
src/fosslight_util/time.py
|
|
21
22
|
src/fosslight_util/timer_thread.py
|
|
22
23
|
src/fosslight_util/write_cyclonedx.py
|
|
23
24
|
src/fosslight_util/write_excel.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util/resources/frequentLicenselist.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_util-2.2.1 → fosslight_util-2.2.2}/src/fosslight_util.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|