Coverage for rust2rpm/project/meta.py: 100%
31 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-25 18:52 +0100
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-25 18:52 +0100
1"""Module containing base project classes."""
3from abc import ABCMeta, abstractmethod
4from dataclasses import dataclass
6from cargo2rpm.metadata import Metadata
9class InvalidVersionError(ValueError):
10 """Raised for version arguments that either don't parse as valid SemVer or don't resolve to an existing version."""
13@dataclass(frozen=True)
14class PatchFile:
15 """Representation of an automatically generated or manually applied Patch for Cargo.toml."""
17 name: str
18 """File name of the patch."""
20 contents: list[str]
21 """Contents of the patch as a list of lines."""
24@dataclass(frozen=True)
25class Project(metaclass=ABCMeta):
26 """Base class for loaded cargo projects."""
28 name: str
29 """Name of the project."""
31 version: str
32 """Version of the project."""
34 metadata: Metadata
35 """Metadata associated with the project (from `cargo metadata`)."""
37 license_files: list[str]
38 """List of license files found by crawling the project sources."""
40 doc_files: list[str]
41 """List of documentation files found by crawling the project sources."""
43 auto_patch: PatchFile | None
44 """Automatically generated patch for Cargo.toml (if present)."""
46 manual_patch: PatchFile | None
47 """Manually applied patch for Cargo.toml (if present)."""
49 vendor_tarball: str | None
50 """File name of the tarball that contains vendored dependencies (if present)."""
52 @property
53 @abstractmethod
54 def rpm_name(self) -> str:
55 """RPM source package name based on project metadata."""