Skip to content

Commit 4d46bbb

Browse files
committed
Remove convert_yml_mode
1 parent f95cb2c commit 4d46bbb

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

src/fosslight_oss_pkg/_convert.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import os
66
import sys
77
import logging
8-
import platform
98
from datetime import datetime
109
from pathlib import Path
1110
from yaml import safe_dump
@@ -20,19 +19,11 @@
2019
logger = logging.getLogger(LOGGER_NAME)
2120

2221

23-
def check_extension_and_format(file, format):
24-
if (file.endswith((".yaml", ".yml")) and format == "yaml"):
25-
logger.error(f"File extension is not matched with input format({format})")
26-
sys.exit(1)
27-
28-
2922
def convert_report(base_path, output_name, format, need_log_file=True):
3023
oss_yaml_files = []
3124
file_option_on = False
32-
convert_yml_mode = False
3325
output_report = ""
3426
now = datetime.now().strftime('%Y%m%d_%H-%M-%S')
35-
is_window = platform.system() == "Windows"
3627

3728
success, msg, output_path, output_name, output_extension = check_output_format(output_name, format, CUSTOMIZED_FORMAT_FOR_PRECHECKER)
3829

@@ -56,30 +47,22 @@ def convert_report(base_path, output_name, format, need_log_file=True):
5647

5748
if os.path.isdir(base_path):
5849
oss_yaml_files = find_sbom_yaml_files(base_path)
59-
if oss_yaml_files:
60-
convert_yml_mode = True
6150
else:
6251
if base_path != "":
6352
files_to_convert = base_path.split(",")
53+
file_option_on = True
6454
for file in files_to_convert:
65-
check_extension_and_format(file, format)
6655
if file.endswith((".yaml", ".yml")):
67-
convert_yml_mode = True
68-
file_option_on = True
6956
oss_yaml_files.append(file)
7057
else:
7158
logger.error("Not support file name or extension")
7259
sys.exit(1)
7360

74-
if not convert_yml_mode:
75-
if is_window:
76-
convert_yml_mode = True
77-
else:
78-
logger.info("fosslight_prechecker: can't convert anything")
79-
logger.info("Try 'fosslight_prechecker -h for more information")
80-
81-
if convert_yml_mode:
61+
if oss_yaml_files:
8262
convert_yml_to_excel(oss_yaml_files, output_report, file_option_on, base_path)
63+
else:
64+
logger.info("fosslight_prechecker: can't convert anything")
65+
logger.info("Try 'fosslight_prechecker -h for more information")
8366

8467
try:
8568
_str_final_result_log = safe_dump(_result_log, allow_unicode=True, sort_keys=True)

0 commit comments

Comments
 (0)