-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodels.py
More file actions
42 lines (34 loc) · 903 Bytes
/
models.py
File metadata and controls
42 lines (34 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from datetime import datetime
from pydantic import BaseModel
class Link(BaseModel):
id: int
name: str
url: str
software_id: int
class Version(BaseModel):
id: int
major: int
minor: int | None
patch: int | None
build: str | None
software_id: int
pushed_at: datetime
@property
def as_string(self) -> str:
"""Format version as string (e.g., '3.12.1')"""
parts = [str(self.major)]
if self.minor is not None:
parts.append(str(self.minor))
if self.patch is not None:
parts.append(str(self.patch))
version = ".".join(parts)
if self.build:
version += f"+{self.build}"
return version
class Software(BaseModel):
id: int
name: str
slug: str
latest_version_id: int | None = None
latest_version: Version | None = None
links: list[Link] = []