Skip to content

Commit 482d39c

Browse files
testing fl util dev_exclude_error
Signed-off-by: Wonjae Park <[email protected]>
1 parent 9d38ef5 commit 482d39c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/fosslight_source/cli.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import fosslight_util.constant as constant
1313
from fosslight_util.set_log import init_log
1414
from fosslight_util.timer_thread import TimerThread
15+
from fosslight_util.scanned_result import excluding_files
1516
from ._help import print_version, print_help_msg_source_scanner
1617
from ._license_matched import get_license_list_to_print
1718
from fosslight_util.output_format import check_output_formats_v2, write_output_file
@@ -84,6 +85,7 @@ def main() -> None:
8485
path_to_scan = ''.join(args.path)
8586
if args.exclude:
8687
path_to_exclude = args.exclude
88+
print("path_to_exclude in main : ", path_to_exclude)
8789
if args.json:
8890
write_json_file = True
8991
output_file_name = ''.join(args.output)
@@ -111,6 +113,7 @@ def main() -> None:
111113
result = run_scanners(path_to_scan, output_file_name, write_json_file, core, True,
112114
print_matched_text, formats, time_out, correct_mode, correct_filepath,
113115
selected_scanner, path_to_exclude)
116+
sys.exit(0)
114117

115118
_result_log["Scan Result"] = result[1]
116119

@@ -329,6 +332,34 @@ def run_scanners(
329332

330333
logger, result_log = init_log(os.path.join(output_path, f"fosslight_log_src_{start_time}.txt"),
331334
True, logging.INFO, logging.DEBUG, PKG_NAME, path_to_scan, path_to_exclude)
335+
# print("path_to_exclude : ", type(path_to_exclude), "||", path_to_exclude)
336+
# print("path_to_scan : ", type(path_to_scan), " || ", path_to_scan)
337+
338+
# excluded_file_list = excluding_files(path_to_exclude, path_to_scan)
339+
# no = 0
340+
# print("excluding_file_list : ", type(excluded_file_list))
341+
# print(excluded_file_list)
342+
# for excluded_file in excluded_file_list:
343+
# no = no + 1
344+
# print(no, ". ", excluded_file)
345+
346+
# if __name__ == "__main__":
347+
test_cases = [
348+
(["file1.js", "file2.py"], "./exclude_test"),
349+
(["sample/*"], "./exclude_test"),
350+
(["sample/subfolder/*"], "./exclude_test"),
351+
(["*.py"], "./exclude_test"),
352+
(["subfolder"], "./exclude_test"),
353+
]
354+
355+
for i, (patterns, path_to_scan) in enumerate(test_cases, 1):
356+
print(f"\n=== 케이스 {i} ===", patterns)
357+
excluding = excluding_files(patterns, path_to_scan)
358+
for r, re in enumerate(excluding, 1):
359+
print(f"{r}. {re}")
360+
# print("\n".join(result))
361+
362+
return 0
332363

333364
if '.xlsx' not in output_extensions and print_matched_text:
334365
logger.warning("-m option is only available for excel.")

0 commit comments

Comments
 (0)