|
| 1 | +# SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com> |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | + |
| 5 | +from pydantic import BaseModel, ConfigDict, Field |
| 6 | + |
| 7 | +from ort.models.config.license_finding_curation import LicenseFindingCuration |
| 8 | +from ort.models.config.path_exclude import PathExclude |
| 9 | +from ort.models.config.vcsmatcher import VcsMatcher |
| 10 | +from ort.models.identifier import Identifier |
| 11 | +from ort.models.source_code_origin import SourceCodeOrigin |
| 12 | + |
| 13 | + |
| 14 | +class PackageConfiguration(BaseModel): |
| 15 | + """ |
| 16 | + A class used in the [OrtConfiguration] to configure [PathExclude]s and [LicenseFindingCuration]s for a specific |
| 17 | + [Package]'s [Identifier] (and [Provenance]). |
| 18 | + Note that [PathExclude]s and [LicenseFindingCuration]s for [Project]s are configured by a |
| 19 | + [RepositoryConfiguration]'s excludes and curations properties instead. |
| 20 | +
|
| 21 | + Attributes: |
| 22 | + id (Identifier): The [Identifier] which must match with the identifier of the package in |
| 23 | + order for this package curation to apply. The [version][Identifier.version] can be |
| 24 | + either a plain version string matched for equality, or an Ivy-style version matchers. |
| 25 | + * The other components of the [identifier][id] are matched by equality. |
| 26 | + source_artifact_url (str | None): The source artifact this configuration applies to. |
| 27 | + vcs (VcsMatcher | None): The vcs and revision this configuration applies to. |
| 28 | + source_code_origin (SourceCodeOrigin | None): The source code origin this configuration |
| 29 | + applies to. |
| 30 | + path_excludes (list[PathExclude]): Path excludes. |
| 31 | + license_finding_curations (list[LicenseFindingCuration]): License finding curations. |
| 32 | + """ |
| 33 | + |
| 34 | + model_config = ConfigDict( |
| 35 | + extra="forbid", |
| 36 | + ) |
| 37 | + |
| 38 | + id: Identifier = Field( |
| 39 | + description="The [Identifier] which must match with the identifier of the package in order for this package" |
| 40 | + "curation to apply. The [version][Identifier.version] can be either a plain version string matched for" |
| 41 | + "equality, or an Ivy-style version matchers." |
| 42 | + "* The other components of the [identifier][id] are matched by equality.", |
| 43 | + ) |
| 44 | + |
| 45 | + source_artifact_url: str | None = Field( |
| 46 | + default=None, |
| 47 | + description="The source artifact this configuration applies to.", |
| 48 | + ) |
| 49 | + |
| 50 | + vcs: VcsMatcher | None = Field( |
| 51 | + default=None, |
| 52 | + description="The vcs and revision this configuration applies to.", |
| 53 | + ) |
| 54 | + |
| 55 | + source_code_origin: SourceCodeOrigin | None = Field( |
| 56 | + default=None, |
| 57 | + description="The source code origin this configuration applies to.", |
| 58 | + ) |
| 59 | + |
| 60 | + path_excludes: list[PathExclude] = Field( |
| 61 | + default_factory=list, |
| 62 | + description="Path excludes.", |
| 63 | + ) |
| 64 | + |
| 65 | + license_finding_curations: list[LicenseFindingCuration] = Field( |
| 66 | + default_factory=list, |
| 67 | + description="License finding curations.", |
| 68 | + ) |
0 commit comments