Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/loader.py
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | class BasePackageInfo: | ||||
filename = attr.ib(type=Optional[str]) | filename = attr.ib(type=Optional[str]) | ||||
# The following attribute has kw_only=True in order to allow subclasses | # The following attribute has kw_only=True in order to allow subclasses | ||||
# to add attributes. Without kw_only, attributes without default values cannot | # to add attributes. Without kw_only, attributes without default values cannot | ||||
# go after attributes with default values. | # go after attributes with default values. | ||||
# See <https://github.com/python-attrs/attrs/issues/38> | # See <https://github.com/python-attrs/attrs/issues/38> | ||||
revision_extrinsic_metadata = attr.ib( | revision_extrinsic_metadata = attr.ib( | ||||
type=List[Tuple[datetime.datetime, str, bytes]], default=[], kw_only=True, | type=List[Tuple[Optional[datetime.datetime], str, bytes]], | ||||
default=[], | |||||
kw_only=True, | |||||
) | ) | ||||
"""Tuple elements are respectively the 'discovery_date', 'format', | """Tuple elements are respectively the 'discovery_date' (which defaults to the | ||||
and 'metadata' fields of RawExtrinsicMetadata""" | visit date), 'format', and 'metadata' fields of RawExtrinsicMetadata""" | ||||
# TODO: add support for metadata for origins, directories, and contents | # TODO: add support for metadata for origins, directories, and contents | ||||
@property | @property | ||||
def ID_KEYS(self): | def ID_KEYS(self): | ||||
raise NotImplementedError(f"{self.__class__.__name__} is missing ID_KEYS") | raise NotImplementedError(f"{self.__class__.__name__} is missing ID_KEYS") | ||||
def artifact_identity(self): | def artifact_identity(self): | ||||
▲ Show 20 Lines • Show All 501 Lines • ▼ Show 20 Lines | ) -> List[RawExtrinsicMetadata]: | ||||
metadata_objects = [] | metadata_objects = [] | ||||
for (discovery_date, format, metadata) in p_info.revision_extrinsic_metadata: | for (discovery_date, format, metadata) in p_info.revision_extrinsic_metadata: | ||||
metadata_objects.append( | metadata_objects.append( | ||||
RawExtrinsicMetadata( | RawExtrinsicMetadata( | ||||
type=MetadataTargetType.REVISION, | type=MetadataTargetType.REVISION, | ||||
id=SWHID(object_type="revision", object_id=revision_id), | id=SWHID(object_type="revision", object_id=revision_id), | ||||
discovery_date=discovery_date, | discovery_date=discovery_date or self.visit_date, | ||||
authority=authority, | authority=authority, | ||||
fetcher=fetcher, | fetcher=fetcher, | ||||
format=format, | format=format, | ||||
metadata=metadata, | metadata=metadata, | ||||
origin=self.url, | origin=self.url, | ||||
) | ) | ||||
) | ) | ||||
Show All 29 Lines |