Skip to content

Commit

Permalink
Fix SPDX expression split bug
Browse files Browse the repository at this point in the history
Signed-off-by: Wonjae Park <j.wonjae.park@gmail.com>
  • Loading branch information
JustinWonjaePark committed Jul 4, 2024
1 parent 5fd88ab commit 9f0039f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/fosslight_source/_parsing_scancode_file_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
KEYWORD_DOWNLOAD_LOC = r'DownloadLocation\s*[\S]+'
KEYWORD_SCANCODE_UNKNOWN = "unknown-spdx"
SPDX_REPLACE_WORDS = ["(", ")"]
KEY_AND = "and"
KEY_OR = "or"
KEY_AND = r"(?<![a-zA-Z])and(?![a-zA-Z])"
KEY_OR = r"(?<![a-zA-Z])or(?![a-zA-Z])"


def get_error_from_header(header_item):
Expand Down Expand Up @@ -182,8 +182,8 @@ def split_spdx_expression(spdx_string):
license = []
for replace in SPDX_REPLACE_WORDS:
spdx_string = spdx_string.replace(replace, "")
spdx_string = spdx_string.replace(KEY_OR, KEY_AND)
license = spdx_string.split(KEY_AND)
spdx_string = re.sub(KEY_OR, KEY_AND, spdx_string)
license = spdx_string.split(KEY_AND.strip())
return license


Expand Down

0 comments on commit 9f0039f

Please sign in to comment.