Skip to content

Commit

Permalink
Added a missing package class.
Browse files Browse the repository at this point in the history
The PackageHomePage class was missing from the available package information
classed.

Some typos and warnings fixed too.

The @AbstractMethod have been added to the coverage configuration since
they may not be tested.
  • Loading branch information
grouigrokon committed Nov 16, 2023
1 parent 7cbfcb2 commit 59b1a6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/e3/spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def __init__(self, value: str) -> None:
# The format of the SPDXID should be "SPDXRef-"[idstring]
# where [idstring] is a unique string containing letters, numbers, .,
# and/or -.
self.value = re.sub(SPDXID_R, "", value)
super().__init__(re.sub(SPDXID_R, "", value))

def __str__(self) -> str:
return f"SPDXRef-{self.value}"
Expand Down Expand Up @@ -400,6 +400,16 @@ class PackageLicenseConcluded(SPDXEntryMaybeStr):
json_entry_key = "licenseConcluded"


class PackageHomePage(SPDXEntryMaybeStr):
"""Identifies the download location of the package.
See 7.11 `Package home page field
<https://spdx.github.io/spdx-spec/v2.3/package-information/#711-package-home-page-field>`_
"""

json_entry_key = "homePage"


class PackageLicenseComments(SPDXEntryMaybeStrMultilines):
"""Cecord background information or analysis for the Concluded License.
Expand Down Expand Up @@ -538,7 +548,7 @@ class RelationshipType(Enum):
DEV_DEPENDENCY_OF = auto()
# Is to be used when SPDXRef-A is an optional dependency of SPDXRef-B
OPTIONAL_DEPENDENCY_OF = auto()
# Is to be used when SPDXRef-A is a to be provided dependency of SPDXRef-B
# Is to be used when SPDXRef-A is to be a provided dependency of SPDXRef-B
PROVIDED_DEPENDENCY_OF = auto()
# Is to be used when SPDXRef-A is a test dependency of SPDXRef-B
TEST_DEPENDENCY_OF = auto()
Expand Down Expand Up @@ -635,11 +645,11 @@ def __init__(
) -> None:
"""Initialize a Relationship object.
:param left: the left side of the relationship, should be the SPDXID
of an element
:param spdx_element_id: the left side of the relationship, should be the
SPDXID of an element
:param relationship_type: the type of the relationship
:param right: the right side of the relationship, should be the SPDXID
of an element
:param related_spdx_element: the right side of the relationship, should
be the SPDXID of an element
"""
self.spdx_element_id = spdx_element_id
self.relationship_type = relationship_type
Expand Down Expand Up @@ -695,7 +705,7 @@ def __post_init__(self) -> None:

@dataclass
class CreationInformation(SPDXSection):
"""Document where and by who the SPDX document has been created."""
"""Document where and by whom the SPDX document has been created."""

creators: list[Creator]
created_now: Created = field(init=False)
Expand All @@ -717,8 +727,9 @@ def __init__(
) -> None:
"""Initialize the SPDX Document.
:param doc_info: A DocumentInformation instance
:param creation_info: A CreationInformation instance
:param document_name: The name of this document.
:param creators: A list of Entity objects, considered as the creators
of this document.
"""
self.doc_info = DocumentInformation(document_name=DocumentName(document_name))
self.creation_info = CreationInformation(
Expand Down Expand Up @@ -753,9 +764,9 @@ def add_package(
) -> SPDXID:
"""Add a new Package and describe its relationship to other elements.
:param name: the full name of the package
:param name: the full name of this package
:param version: the package version
:param file_name: the actual file name of the package
:param file_name: the actual file name of this package
:param checksum: the package checksum (see SHA1, SHA256 classes)
:param license_concluded: the license concluded as govering the package
:param license_comments: comments for the license_concluded field
Expand All @@ -770,11 +781,6 @@ def add_package(
SPDX document
:param copyright_text: identify the copyright holders of the package,
as well as any dates present
:param relationship_spdx_element_id: the element SPDXID with which the
package has a relationship, note that the relationship will be written as
<related_elemnent> <relationship_type> <the new package>
:param relationship_type: describe the relation of this package to
the related element
:param is_main_package: whether the package is the main package, in
which case a relationship will automatically be added to record
that the document DESCRIBES this package. If false, it is assumed
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/base.rc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ omit =
exclude_lines =
all: no cover
if TYPE_CHECKING:
@abstractmethod
# os-specific
defensive code
assert_never()
Expand Down

0 comments on commit 59b1a6a

Please sign in to comment.