Skip to content

Commit 431446d

Browse files
authored
Merge branch 'main' into issue-774-unhashable-type
2 parents 4432e66 + 1e3031c commit 431446d

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/spdx_tools/spdx/parser/tagvalue/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ def p_snippet_range(self, p):
488488

489489
# parsing methods for annotation
490490

491-
@grammar_rule("annotator : ANNOTATOR PERSON_VALUE\n| TOOL_VALUE\n| ORGANIZATION_VALUE")
491+
@grammar_rule("annotator : ANNOTATOR PERSON_VALUE\n| ANNOTATOR TOOL_VALUE\n| ANNOTATOR ORGANIZATION_VALUE")
492492
def p_annotator(self, p):
493493
self.initialize_new_current_element(Annotation)
494494
set_value(p, self.current_element, method_to_apply=ActorParser.parse_actor)

src/spdx_tools/spdx3/model/software/software_purpose.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ class SoftwarePurpose(Enum):
2424
OPERATING_SYSTEM = auto()
2525
OTHER = auto()
2626
PATCH = auto()
27+
REQUIREMENT = auto()
2728
SOURCE = auto()
2829
TEST = auto()

tests/spdx/parser/tagvalue/test_annotation_parser.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,28 @@ def test_parse_annotation():
3434
assert annotation.spdx_id == DOCUMENT_SPDX_ID
3535

3636

37+
def test_parse_annotation_with_organization_as_annotator():
38+
parser = Parser()
39+
annotation_str = "\n".join(
40+
[
41+
"Annotator: Organization: some-organization",
42+
"AnnotationDate: 2010-01-29T18:30:22Z",
43+
"AnnotationComment: <text>Document level annotation</text>",
44+
"AnnotationType: OTHER",
45+
f"SPDXREF: {DOCUMENT_SPDX_ID}",
46+
]
47+
)
48+
document = parser.parse("\n".join([DOCUMENT_STR, annotation_str]))
49+
assert document is not None
50+
assert len(document.annotations) == 1
51+
annotation = document.annotations[0]
52+
assert annotation.annotator.name == "some-organization"
53+
assert annotation.annotation_date == datetime(2010, 1, 29, 18, 30, 22)
54+
assert annotation.annotation_comment == "Document level annotation"
55+
assert annotation.annotation_type == AnnotationType.OTHER
56+
assert annotation.spdx_id == DOCUMENT_SPDX_ID
57+
58+
3759
@pytest.mark.parametrize(
3860
"annotation_str, expected_message",
3961
[

0 commit comments

Comments
 (0)