python-ort 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ from pydantic import AnyUrl, BaseModel, ConfigDict, Field
7
7
 
8
8
  from .hash import Hash
9
9
  from .source_code_origin import SourceCodeOrigin
10
- from .vcsinfo import VcsInfo
10
+ from .vcsinfo_curation_data import VcsInfoCurationData
11
11
 
12
12
 
13
13
  class CurationArtifact(BaseModel):
@@ -28,7 +28,7 @@ class PackageCurationData(BaseModel):
28
28
  homepage_url: str | None = None
29
29
  binary_artifact: CurationArtifact | None = None
30
30
  source_artifact: CurationArtifact | None = None
31
- vcs: VcsInfo | None = None
31
+ vcs: VcsInfoCurationData | None = None
32
32
  is_metadata_only: bool | None = None
33
33
  is_modified: bool | None = None
34
34
  declared_license_mapping: dict[str, Any] = Field(default_factory=dict)
@@ -0,0 +1,37 @@
1
+ # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ from pydantic import AnyUrl, BaseModel, Field
5
+
6
+ from .vcstype import VcsType
7
+
8
+
9
+ class VcsInfoCurationData(BaseModel):
10
+ """
11
+ Bundles general Version Control System information.
12
+
13
+ Attributes:
14
+ type(VcsType): The type of the VCS, for example Git, GitRepo, Mercurial, etc.
15
+ url(AnyUrl): The URL to the VCS repository.
16
+ revision(str): The VCS-specific revision (tag, branch, SHA1) that the version of the package maps to.
17
+ path(str): The path inside the VCS to take into account.
18
+ If the VCS supports checking out only a subdirectory, only this path is checked out.
19
+ """
20
+
21
+ type: VcsType | None = Field(
22
+ default=None,
23
+ description="The type of the VCS, for example Git, GitRepo, Mercurial, etc.",
24
+ )
25
+ url: AnyUrl | None = Field(
26
+ default=None,
27
+ description="The URL to the VCS repository.",
28
+ )
29
+ revision: str | None = Field(
30
+ default=None,
31
+ description="The VCS-specific revision (tag, branch, SHA1) that the version of the package maps to.",
32
+ )
33
+ path: str | None = Field(
34
+ default=None,
35
+ description="The path inside the VCS to take into account."
36
+ "If the VCS supports checking out only a subdirectory, only this path is checked out.",
37
+ )
ort/models/vcstype.py CHANGED
@@ -3,6 +3,14 @@
3
3
 
4
4
  from pydantic import BaseModel, Field, model_validator
5
5
 
6
+ # Define known VCS types as constants
7
+ GIT = ["Git", "GitHub", "GitLab"]
8
+ GIT_REPO = ["GitRepo", "git-repo", "repo"]
9
+ MERCURIAL = ["Mercurial", "hg"]
10
+ SUBVERSION = ["Subversion", "svn"]
11
+
12
+ KNOWN_TYPES = GIT + GIT_REPO + MERCURIAL + SUBVERSION
13
+
6
14
 
7
15
  class VcsType(BaseModel):
8
16
  """
@@ -12,35 +20,26 @@ class VcsType(BaseModel):
12
20
  alias for the string representation.
13
21
 
14
22
  Attributes:
15
- aliases(list[str]): Primary name and aliases
23
+ name(str): Primary name and aliases
16
24
  """
17
25
 
18
- aliases: list[str] = Field(default_factory=list, description="Primary name and aliases")
19
-
20
- @model_validator(mode="after")
21
- def ensure_non_empty(self):
22
- """Ensure the aliases list is never empty."""
23
- if not self.aliases:
24
- self.aliases = [""]
25
- return self
26
-
27
- def __str__(self):
28
- return self.aliases[0] if self.aliases else ""
26
+ name: str = Field(default_factory=str)
29
27
 
28
+ @model_validator(mode="before")
30
29
  @classmethod
31
- def for_name(cls, name: str) -> "VcsType":
32
- """Lookup known type by name, or create a new instance."""
33
- for t in KNOWN_TYPES:
34
- if any(alias.lower() == name.lower() for alias in t.aliases):
35
- return t
36
- return cls(aliases=[name])
37
-
38
-
39
- # Define known VCS types as constants
40
- GIT = VcsType(aliases=["Git", "GitHub", "GitLab"])
41
- GIT_REPO = VcsType(aliases=["GitRepo", "git-repo", "repo"])
42
- MERCURIAL = VcsType(aliases=["Mercurial", "hg"])
43
- SUBVERSION = VcsType(aliases=["Subversion", "svn"])
44
- UNKNOWN = VcsType(aliases=[""])
45
-
46
- KNOWN_TYPES = [GIT, GIT_REPO, MERCURIAL, SUBVERSION]
30
+ def _forName(cls, value):
31
+ # Allow direct string input (e.g., "Git" or "gitlab")
32
+ if isinstance(value, str):
33
+ if any(item.lower() == value.lower() for item in KNOWN_TYPES):
34
+ return {"name": value}
35
+ else:
36
+ # Not a known type → default to empty string
37
+ return {"name": ""}
38
+ # Allow dict input or existing model
39
+ elif isinstance(value, dict):
40
+ name = value.get("name", "")
41
+ if any(item.lower() == name.lower() for item in KNOWN_TYPES):
42
+ return value
43
+ else:
44
+ return {"name": ""}
45
+ return {"name": ""}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-ort
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: A Python Ort model serialization library
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -8,14 +8,15 @@ ort/models/hash.py,sha256=UnWw5yuXp2HUwX8xcCOI-rxpmjEhYSDWlJrB_ULcVMw,661
8
8
  ort/models/hash_algorithm.py,sha256=7P-Y0-PmaQ28kqgJSOvo8VeQwL3RvYW2LvDZfGIEbZQ,1510
9
9
  ort/models/ort_configuration.py,sha256=eleVGknw7grLOTaPOZbI2_HrD9KoEhRFEGyqg25mVws,10975
10
10
  ort/models/package_curation.py,sha256=_F1GF7D_lgeCQs9j3Ft5ImSPO9RdBjepdEBo2JxuNPY,356
11
- ort/models/package_curation_data.py,sha256=DBux1UT5dY6q2j3yXPBEDxFAmQscqJnBIx9H3HtOZ5M,1106
11
+ ort/models/package_curation_data.py,sha256=71Exs5COPSFlS-OGQLhtpf6OjJ4P99TGiC9kFlu-FJE,1144
12
12
  ort/models/package_managers.py,sha256=qyShJ-IOQZFWOPmvylj413vVNMjBZ0xPlXtHU8V68Uk,1364
13
13
  ort/models/repository_configuration.py,sha256=d1kyn_nIrnrrNqWbTK-v1RafuJjE6xP710r8GTicYKE,10702
14
14
  ort/models/resolutions.py,sha256=3OuCC9yYMu5Ovt2UD04ms9zJuWBXtBDjof-8fRzErlw,3423
15
15
  ort/models/source_code_origin.py,sha256=gyEQaR4AjrWDDpDwEO8RHAHyFmnZK3plZzbvWf5o9do,208
16
16
  ort/models/vcsinfo.py,sha256=Hrf-S_ZKCKtZF-ImY7ytqzd3onJA7YbEHaE2sPDi_B8,1293
17
- ort/models/vcstype.py,sha256=RffAlJ9Ow_sOe8mJklwTKIpH9dn1NGH1Z_fvPhjkP9I,1625
18
- python_ort-0.3.0.dist-info/licenses/LICENSE,sha256=koFhbHMglt1BNVuMKdBBlrQcgQsWLgo4pZW6cCtyGvA,1081
19
- python_ort-0.3.0.dist-info/WHEEL,sha256=5w2T7AS2mz1-rW9CNagNYWRCaB0iQqBMYLwKdlgiR4Q,78
20
- python_ort-0.3.0.dist-info/METADATA,sha256=NGUiVxIosmp-zS4n82MRA1OsZPtvC1wdhQnM7O5E5NE,851
21
- python_ort-0.3.0.dist-info/RECORD,,
17
+ ort/models/vcsinfo_curation_data.py,sha256=HC3ObAGv9-Ff1i0gf3CzzkuA1CQGtshdpSA6zrNGv70,1384
18
+ ort/models/vcstype.py,sha256=o85RmCiSz9d9AT2PV-J0JK-NkAme1sSttxLMa3ztGuw,1609
19
+ python_ort-0.3.1.dist-info/licenses/LICENSE,sha256=koFhbHMglt1BNVuMKdBBlrQcgQsWLgo4pZW6cCtyGvA,1081
20
+ python_ort-0.3.1.dist-info/WHEEL,sha256=5w2T7AS2mz1-rW9CNagNYWRCaB0iQqBMYLwKdlgiR4Q,78
21
+ python_ort-0.3.1.dist-info/METADATA,sha256=7xnmoJZVts4K0qJdpA2DLpKiBxf6xZEHCx1K_AdYF4I,851
22
+ python_ort-0.3.1.dist-info/RECORD,,