Skip to content

Commit

Permalink
Bug fixes: start exporting filesAnalyzed for package into XML/JSON/YA…
Browse files Browse the repository at this point in the history
…ML. Fix parsers to support multiple packages per document. Fixing unit-tests
  • Loading branch information
yanyag committed Jul 5, 2021
1 parent c8f3a58 commit cc50888
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions spdx/parsers/jsonyamlxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,12 +1188,15 @@ def parse_pkg_down_location(self, pkg_down_location):
def parse_pkg_files_analyzed(self, pkg_files_analyzed):
"""
Parse Package files analyzed
- pkg_files_analyzed: Python str/unicode
- pkg_files_analyzed: Python boolean or str/unicode
"""
if isinstance(pkg_files_analyzed, six.string_types):
# Files Analyzed optional
if pkg_files_analyzed is None:
return
if isinstance(pkg_files_analyzed, six.string_types) or isinstance(pkg_files_analyzed, bool):
try:
return self.builder.set_pkg_files_analyzed(
self.document, pkg_files_analyzed
self.document, six.text_type(pkg_files_analyzed)
)
except CardinalityError:
self.more_than_one_error("PKG_FILES_ANALYZED")
Expand All @@ -1205,7 +1208,7 @@ def parse_pkg_verif_code_field(self, pkg_verif_code_field):
Parse Package verification code dict
- pkg_verif_code_field: Python dict('value':str/unicode, 'excludedFilesNames':list)
"""
if not self.document.packages[-1].files_analyzed:
if self.document.packages[-1].files_analyzed == False:
return
if isinstance(pkg_verif_code_field, dict):
self.parse_pkg_verif_exc_files(
Expand All @@ -1220,6 +1223,8 @@ def parse_pkg_verif_code(self, pkg_verif_code):
Parse Package verification code value
- pkg_verif_code: Python str/unicode
"""
if self.document.packages[-1].files_analyzed == False:
return
if isinstance(pkg_verif_code, six.string_types):
try:
return self.builder.set_pkg_verif_code(self.document, pkg_verif_code)
Expand Down Expand Up @@ -1442,7 +1447,7 @@ def parse_pkg_files(self, pkg_files):
Parse Package files
- pkg_files: Python list of dicts as in FileParser.parse_file
"""
if not self.document.packages[-1].files_analyzed:
if self.document.packages[-1].files_analyzed == False:
return
if isinstance(pkg_files, list):
for pkg_file in pkg_files:
Expand Down

0 comments on commit cc50888

Please sign in to comment.