Skip to content

Commit

Permalink
Remove convert_yml_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bjk7119 committed Aug 10, 2022
1 parent f95cb2c commit 4b98f0d
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions src/fosslight_oss_pkg/_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import sys
import logging
import platform
from datetime import datetime
from pathlib import Path
from yaml import safe_dump
Expand All @@ -20,19 +19,11 @@
logger = logging.getLogger(LOGGER_NAME)


def check_extension_and_format(file, format):
if (file.endswith((".yaml", ".yml")) and format == "yaml"):
logger.error(f"File extension is not matched with input format({format})")
sys.exit(1)


def convert_report(base_path, output_name, format, need_log_file=True):
oss_yaml_files = []
file_option_on = False
convert_yml_mode = False
output_report = ""
now = datetime.now().strftime('%Y%m%d_%H-%M-%S')
is_window = platform.system() == "Windows"

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

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

if os.path.isdir(base_path):
oss_yaml_files = find_sbom_yaml_files(base_path)
if oss_yaml_files:
convert_yml_mode = True
else:
if base_path != "":
files_to_convert = base_path.split(",")
for file in files_to_convert:
check_extension_and_format(file, format)
if file.endswith((".yaml", ".yml")):
convert_yml_mode = True
file_option_on = True
oss_yaml_files.append(file)
else:
logger.error("Not support file name or extension")
sys.exit(1)

if not convert_yml_mode:
if is_window:
convert_yml_mode = True
else:
logger.info("fosslight_prechecker: can't convert anything")
logger.info("Try 'fosslight_prechecker -h for more information")

if convert_yml_mode:
if oss_yaml_files:
convert_yml_to_excel(oss_yaml_files, output_report, file_option_on, base_path)
else:
logger.info("fosslight_prechecker: can't convert anything")
logger.info("Try 'fosslight_prechecker -h for more information")

try:
_str_final_result_log = safe_dump(_result_log, allow_unicode=True, sort_keys=True)
Expand Down

0 comments on commit 4b98f0d

Please sign in to comment.