Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/pypi/loader.py
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | def _known_artifacts(self, last_snapshot): | ||||
Returns: | Returns: | ||||
list of (filename, sha256) tuples. | list of (filename, sha256) tuples. | ||||
""" | """ | ||||
if not last_snapshot or 'branches' not in last_snapshot: | if not last_snapshot or 'branches' not in last_snapshot: | ||||
return {} | return {} | ||||
revs = [rev['target'] for rev in last_snapshot['branches'].values()] | # retrieve only revisions (e.g the alias we do not want here) | ||||
revs = [rev['target'] | |||||
for rev in last_snapshot['branches'].values() | |||||
if rev['target_type'] == 'revision'] | |||||
known_revisions = self.storage.revision_get(revs) | known_revisions = self.storage.revision_get(revs) | ||||
ret = {} | ret = {} | ||||
for revision in known_revisions: | for revision in known_revisions: | ||||
if not revision: # revision_get can return None | |||||
continue | |||||
if 'original_artifact' in revision['metadata']: | if 'original_artifact' in revision['metadata']: | ||||
artifact = revision['metadata']['original_artifact'] | artifact = revision['metadata']['original_artifact'] | ||||
ret[artifact['filename'], artifact['sha256']] = revision['id'] | ret[artifact['filename'], artifact['sha256']] = revision['id'] | ||||
return ret | return ret | ||||
def _last_snapshot(self): | def _last_snapshot(self): | ||||
"""Retrieve the last snapshot | """Retrieve the last snapshot | ||||
▲ Show 20 Lines • Show All 187 Lines • Show Last 20 Lines |