Skip to content

Commit ab0ef80

Browse files
committed
Add options when parsing yaml
- Set list to null in case of error - Add an option to not log output
1 parent bce9004 commit ab0ef80

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/fosslight_util/parsing_yaml.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
EXAMPLE_OSS_PKG_INFO_LINK = "https://github.com/fosslight/fosslight_prechecker/blob/main/tests/convert/sbom-info.yaml"
1717

1818

19-
def parsing_yml(yaml_file, base_path):
19+
def parsing_yml(yaml_file, base_path, print_log=True):
2020
oss_list = []
2121
license_list = []
2222
idx = 1
@@ -51,9 +51,13 @@ def parsing_yml(yaml_file, base_path):
5151
license_list.extend(item.license)
5252
idx += 1
5353
except AttributeError as ex:
54-
_logger.error(f"Not supported yaml file format {ex}")
54+
if print_log:
55+
_logger.error(f"Not supported yaml file format {ex}")
56+
oss_list = []
5557
except yaml.YAMLError:
56-
_logger.warning(f"Can't parse yaml - skip to parse yaml file: {yaml_file}")
58+
if print_log:
59+
_logger.warning(f"Can't parse yaml - skip to parse yaml file: {yaml_file}")
60+
oss_list = []
5761
return oss_list, set(license_list)
5862

5963

0 commit comments

Comments
 (0)