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
3 changes: 3 additions & 0 deletions .github/workflows/check_codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
exclude: # see https://github.com/actions/runner-images/issues/9770#issuecomment-2085623315
- python-version: "3.7"
os: macos-latest
include:
- python-version: "3.7"
os: macos-13

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/install_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
exclude: # see https://github.com/actions/runner-images/issues/9770#issuecomment-2085623315
- python-version: "3.7"
os: macos-latest
include:
- python-version: "3.7"
os: macos-13

steps:
- uses: actions/checkout@v3
Expand Down
7 changes: 5 additions & 2 deletions src/spdx_tools/spdx/parser/tagvalue/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,14 @@ def p_generic_value(self, p):
def p_unknown_tag(self, p):
self.logger.append(f"Unknown tag provided in line {p.lineno(1)}")

@grammar_rule("text_or_line : TEXT")
@grammar_rule("text_or_line : TEXT\n line_or_no_assertion_or_none : TEXT")
def p_text(self, p):
p[0] = str_from_text(p[1])

@grammar_rule("text_or_line : LINE\n line_or_no_assertion : LINE\nline_or_no_assertion_or_none : text_or_line")
@grammar_rule(
"text_or_line : LINE\n line_or_no_assertion : LINE\nline_or_no_assertion_or_none : LINE\n"
"text_or_line : NO_ASSERTION\n text_or_line : NONE"
)
def p_line(self, p):
p[0] = p[1]

Expand Down
28 changes: 27 additions & 1 deletion tests/spdx/parser/tagvalue/test_tag_value_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest

from spdx_tools.spdx.constants import DOCUMENT_SPDX_ID
from spdx_tools.spdx.model import Relationship, RelationshipType
from spdx_tools.spdx.model import Relationship, RelationshipType, SpdxNoAssertion, SpdxNone
from spdx_tools.spdx.parser.error import SPDXParsingError
from spdx_tools.spdx.parser.tagvalue.parser import Parser
from tests.spdx.parser.tagvalue.test_creation_info_parser import DOCUMENT_STR
Expand Down Expand Up @@ -136,3 +136,29 @@ def test_faulty_license_expression():
"and numbers, underscore, dot, colon or hyphen signs and spaces: "
"'LicenseRef-foo/foo'\"]",
]


def test_parse_none_or_no_assertion_as_text():
parser = Parser()
document_str = "\n".join(
[
DOCUMENT_STR,
"PackageName: Test",
"SPDXID: SPDXRef-Package",
"PackageDownloadLocation: http://example.com/test",
"FilesAnalyzed: true",
"PackageSummary: NONE",
"PackageSourceInfo: NOASSERTION",
"PackageLicenseConcluded: NONE",
"PackageLicenseDeclared: NOASSERTION",
]
)
document = parser.parse(document_str)
assert document is not None
package = document.packages[0]
assert package.name == "Test"
assert package.spdx_id == "SPDXRef-Package"
assert package.source_info == "NOASSERTION"
assert package.summary == "NONE"
assert package.license_concluded == SpdxNone()
assert package.license_declared == SpdxNoAssertion()