Changeset View
Changeset View
Standalone View
Standalone View
swh/model/model.py
Show First 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | def from_dict(cls, d): | ||||
date = d.pop('date') | date = d.pop('date') | ||||
return cls( | return cls( | ||||
date=(date | date=(date | ||||
if isinstance(date, datetime.datetime) | if isinstance(date, datetime.datetime) | ||||
else dateutil.parser.parse(date)), | else dateutil.parser.parse(date)), | ||||
**d) | **d) | ||||
@attr.s(frozen=True) | |||||
class OriginVisitUpdate(BaseModel): | |||||
"""Represents a visit update of an origin at a given point in time. | |||||
""" | |||||
origin = attr.ib(type=str) | |||||
visit = attr.ib(type=int) | |||||
date = attr.ib(type=datetime.datetime) | |||||
status = attr.ib( | |||||
type=str, | |||||
validator=attr.validators.in_(['ongoing', 'full', 'partial'])) | |||||
snapshot = attr.ib(type=Optional[Sha1Git]) | |||||
metadata = attr.ib(type=Optional[Dict[str, object]], | |||||
default=None) | |||||
class TargetType(Enum): | class TargetType(Enum): | ||||
"""The type of content pointed to by a snapshot branch. Usually a | """The type of content pointed to by a snapshot branch. Usually a | ||||
revision or an alias.""" | revision or an alias.""" | ||||
CONTENT = 'content' | CONTENT = 'content' | ||||
DIRECTORY = 'directory' | DIRECTORY = 'directory' | ||||
REVISION = 'revision' | REVISION = 'revision' | ||||
RELEASE = 'release' | RELEASE = 'release' | ||||
SNAPSHOT = 'snapshot' | SNAPSHOT = 'snapshot' | ||||
▲ Show 20 Lines • Show All 337 Lines • Show Last 20 Lines |