Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/fosslight_util/oss_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, value):
self.download_location = ""
self._yocto_recipe = []
self._yocto_package = []
self.is_binary = False

def __del__(self):
pass
Expand Down
10 changes: 7 additions & 3 deletions src/fosslight_util/read_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

logger = logging.getLogger(LOGGER_NAME)
IDX_CANNOT_FOUND = -1
PREFIX_BIN = "bin"


def read_oss_report(excel_file, sheet_names=""):
_oss_report_items = []
_xl_sheets = []
xl_sheets = {}
all_sheet_to_read = []
not_matched_sheet = []
any_sheet_matched = False
Expand Down Expand Up @@ -44,7 +45,7 @@ def read_oss_report(excel_file, sheet_names=""):
sheet = xl_workbook.sheet_by_name(sheet_name)
if sheet:
logger.info(f"Load a matched sheet: {sheet_name}")
_xl_sheets.append(sheet)
xl_sheets[sheet_name] = sheet
any_sheet_matched = True
if not any_sheet_matched:
not_matched_sheet.append(sheet_to_read)
Expand All @@ -58,7 +59,7 @@ def read_oss_report(excel_file, sheet_names=""):
elif (not sheet_name_prefix_match) and not_matched_sheet:
logger.warning(f"Not matched sheet name: {not_matched_sheet}")

for xl_sheet in _xl_sheets:
for sheet_name, xl_sheet in xl_sheets.items():
_item_idx = {
"ID": IDX_CANNOT_FOUND,
"Source Name or Path": IDX_CANNOT_FOUND,
Expand Down Expand Up @@ -90,8 +91,11 @@ def read_oss_report(excel_file, sheet_names=""):
# Get all values, iterating through rows and columns
column_keys = json.loads(json.dumps(_item_idx))

is_bin = True if sheet_name.lower().startswith(PREFIX_BIN) else False

for row_idx in range(DATA_START_ROW_IDX, xl_sheet.nrows):
item = OssItem("")
item.is_binary = is_bin
valid_row = True
load_data_cnt = 0

Expand Down
5 changes: 4 additions & 1 deletion src/fosslight_util/write_scancodejson.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def write_scancodejson(output_dir, output_filename, oss_list):
else:
json_output['files'] = add_item_in_files(oi, item_path, json_output['files'])
with open(os.path.join(output_dir, output_filename), 'w') as f:
json.dump(json_output, f, sort_keys=False)
json.dump(json_output, f, sort_keys=False, indent=4)


def append_oss_item_in_filesitem(item, files_item):
Expand All @@ -42,6 +42,8 @@ def append_oss_item_in_filesitem(item, files_item):
oss_item['copyright'] = item.copyright
oss_item['download_location'] = item.download_location
oss_item['comment'] = item.comment
if item.is_binary:
files_item['is_binary'] = item.is_binary
files_item['oss'].append(oss_item)
return files_item

Expand All @@ -50,6 +52,7 @@ def add_item_in_files(item, item_path, files_list):
files_item = {}
files_item['path'] = item_path
files_item['name'] = os.path.basename(item_path)
files_item['is_binary'] = item.is_binary
files_item['base_name'], files_item['extension'] = os.path.splitext(os.path.basename(item_path))
files_item['oss'] = []
files_item = append_oss_item_in_filesitem(item, files_item)
Expand Down