Skip to content

Commit

Permalink
Merge pull request #34 from fosslight/develop
Browse files Browse the repository at this point in the history
Add the function to write output with format
  • Loading branch information
dd-jy authored Oct 18, 2021
2 parents 02535f9 + 141ea31 commit b41700b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/fosslight_util/output_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Copyright (c) 2021 LG Electronics Inc.
# SPDX-License-Identifier: Apache-2.0
import os
from fosslight_util.write_excel import write_result_to_excel, write_excel_and_csv, write_result_to_csv
from fosslight_util.write_opossum import write_opossum

SUPPORT_FORMAT = {'excel': '.xlsx', 'csv': '.csv', 'opossum': '.json'}

Expand Down Expand Up @@ -47,3 +49,22 @@ def check_output_format(output='', format=''):
output_path = output

return success, msg, output_path, output_file, output_extension


def write_output_file(output_file_without_ext, file_extension, sheet_list, scanner=''):
success = True
msg = ''

if file_extension == '':
success, msg = write_excel_and_csv(output_file_without_ext, sheet_list)
elif file_extension == '.xlsx':
success, msg = write_result_to_excel(output_file_without_ext + file_extension, sheet_list)
elif file_extension == '.csv':
success, msg = write_result_to_csv(output_file_without_ext + file_extension, sheet_list)
elif file_extension == '.json':
success, msg = write_opossum(output_file_without_ext + file_extension, sheet_list, scanner)
else:
success = False
msg = 'Not supported file extension(' + file_extension + ')'

return success, msg

0 comments on commit b41700b

Please sign in to comment.