From 9423655744f50789ba3a2918d5649fa39d79d9ad Mon Sep 17 00:00:00 2001 From: SeongjunJo Date: Fri, 10 May 2024 14:19:57 +0900 Subject: [PATCH] Add log and cover item for path excluded from scan Signed-off-by: SeongjunJo --- src/fosslight_util/cover.py | 5 ++++- src/fosslight_util/set_log.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/fosslight_util/cover.py b/src/fosslight_util/cover.py index a3f60b5..cca9d5a 100644 --- a/src/fosslight_util/cover.py +++ b/src/fosslight_util/cover.py @@ -14,9 +14,10 @@ class CoverItem: start_time_key = "Start time" python_ver_key = "Python version" analyzed_path_key = "Analyzed path" + excluded_path_key = "Excluded path" comment_key = "Comment" - def __init__(self, tool_name="", start_time="", input_path="", comment=""): + def __init__(self, tool_name="", start_time="", input_path="", comment="", exclude_path=[]): self.tool_name = tool_name if start_time: date, time = start_time.split('_') @@ -24,6 +25,7 @@ def __init__(self, tool_name="", start_time="", input_path="", comment=""): else: self.start_time = "" self.input_path = os.path.abspath(input_path) + self.exclude_path = ", ".join(exclude_path) self.comment = comment self.tool_version = print_package_version(self.tool_name, "", False) @@ -39,6 +41,7 @@ def get_print_json(self): json_item[self.start_time_key] = self.start_time json_item[self.python_ver_key] = self.python_version json_item[self.analyzed_path_key] = self.input_path + json_item[self.excluded_path_key] = self.exclude_path json_item[self.comment_key] = self.comment return json_item diff --git a/src/fosslight_util/set_log.py b/src/fosslight_util/set_log.py index 835d17a..d61e52a 100755 --- a/src/fosslight_util/set_log.py +++ b/src/fosslight_util/set_log.py @@ -42,7 +42,7 @@ def process(self, msg, kwargs): def init_log(log_file, create_file=True, stream_log_level=logging.INFO, - file_log_level=logging.DEBUG, main_package_name="", path_to_analyze=""): + file_log_level=logging.DEBUG, main_package_name="", path_to_analyze="", path_to_exclude=[]): logger = logging.getLogger(constant.LOGGER_NAME) @@ -83,5 +83,7 @@ def init_log(log_file, create_file=True, stream_log_level=logging.INFO, _result_log["Tool Info"] = pkg_info if path_to_analyze != "": _result_log["Path to analyze"] = path_to_analyze + if path_to_exclude != []: + _result_log["Path to exclude"] = ", ".join(path_to_exclude) return logger, _result_log