Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/loader.py
Show First 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | def uncompress(self, dl_artifacts: List[Tuple[str, Mapping[str, Any]]], | ||||
information (debian). | information (debian). | ||||
""" | """ | ||||
uncompressed_path = os.path.join(dest, 'src') | uncompressed_path = os.path.join(dest, 'src') | ||||
for a_path, _ in dl_artifacts: | for a_path, _ in dl_artifacts: | ||||
uncompress(a_path, dest=uncompressed_path) | uncompress(a_path, dest=uncompressed_path) | ||||
return uncompressed_path | return uncompressed_path | ||||
def extra_branches(self) -> Dict[bytes, Mapping[str, Any]]: | |||||
"""Return an extra dict of branches that are used to update the set of | |||||
branches. | |||||
""" | |||||
return {} | |||||
def load(self) -> Dict: | def load(self) -> Dict: | ||||
"""Load for a specific origin the associated contents. | """Load for a specific origin the associated contents. | ||||
for each package version of the origin | for each package version of the origin | ||||
1. Fetch the files for one package version By default, this can be | 1. Fetch the files for one package version By default, this can be | ||||
implemented as a simple HTTP request. Loaders with more specific | implemented as a simple HTTP request. Loaders with more specific | ||||
requirements can override this, e.g.: the PyPI loader checks the | requirements can override this, e.g.: the PyPI loader checks the | ||||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | def load(self) -> Dict: | ||||
'target': branch_name.encode('utf-8'), | 'target': branch_name.encode('utf-8'), | ||||
} | } | ||||
for branch_name, target in branch_name_revisions: | for branch_name, target in branch_name_revisions: | ||||
branches[branch_name.encode('utf-8')] = { | branches[branch_name.encode('utf-8')] = { | ||||
'target_type': 'revision', | 'target_type': 'revision', | ||||
'target': target, | 'target': target, | ||||
} | } | ||||
ardumont: Please, give better name to k and v. | |||||
Done Inline ActionsHm, mypy doesn't allow to change the type of a varaible in a scope. So, I add to rename k to name (and not to branch_name which is already used). lewo: Hm, mypy doesn't allow to change the type of a varaible in a scope. So, I add to rename `k` to… | |||||
Not Done Inline Actionsyes, that's quite fine ;) ardumont: yes, that's quite fine ;) | |||||
for name, target in self.extra_branches().items(): | |||||
if name in branches: | |||||
logger.error("Extra branch '%s' has been ignored", | |||||
name) | |||||
else: | |||||
branches[name] = target | |||||
snapshot_data = { | snapshot_data = { | ||||
'branches': branches | 'branches': branches | ||||
} | } | ||||
logger.debug('snapshot: %s', snapshot_data) | logger.debug('snapshot: %s', snapshot_data) | ||||
snapshot = Snapshot.from_dict(snapshot_data) | snapshot = Snapshot.from_dict(snapshot_data) | ||||
logger.debug('snapshot: %s', snapshot) | logger.debug('snapshot: %s', snapshot) | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |
Please, give better name to k and v.