Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/loader.py
Show First 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | def load(self) -> Dict: | ||||
directory = Directory.from_disk( | directory = Directory.from_disk( | ||||
path=uncompressed_path.encode('utf-8'), | path=uncompressed_path.encode('utf-8'), | ||||
data=True) # noqa | data=True) # noqa | ||||
# FIXME: Try not to load the full raw content in | # FIXME: Try not to load the full raw content in | ||||
# memory | # memory | ||||
objects = directory.collect() | objects = directory.collect() | ||||
contents = objects['content'].values() | contents = list( | ||||
objects.get('content', {}).values()) | |||||
logger.debug('Number of contents: %s', | logger.debug('Number of contents: %s', | ||||
len(contents)) | len(contents)) | ||||
self.storage.content_add( | self.storage.content_add( | ||||
[content_for_storage(x) for x in contents]) | [content_for_storage(x) for x in contents]) | ||||
status_load = 'eventful' | status_load = 'eventful' | ||||
directories = list(objects['directory'].values()) | |||||
directories = list( | |||||
objects.get('directory', {}).values()) | |||||
logger.debug('Number of directories: %s', | logger.debug('Number of directories: %s', | ||||
len(directories)) | len(directories)) | ||||
self.storage.directory_add(directories) | self.storage.directory_add(directories) | ||||
anlambert: Nitpick, I would rather write:
```lang=python
contents = objects.get('content', {}).values()… | |||||
Done Inline Actionsnicer ;) ardumont: nicer ;) | |||||
# FIXME: This should be release. cf. D409 | # FIXME: This should be release. cf. D409 | ||||
revision = self.build_revision( | revision = self.build_revision( | ||||
p_info['raw'], uncompressed_path) | p_info['raw'], uncompressed_path) | ||||
revision.update({ | revision.update({ | ||||
'synthetic': True, | 'synthetic': True, | ||||
'directory': directory.hash, | 'directory': directory.hash, | ||||
}) | }) | ||||
revision['metadata'].update({ | revision['metadata'].update({ | ||||
'original_artifact': [ | 'original_artifact': [ | ||||
Not Done Inline Actionssame here anlambert: same here | |||||
hashes for _, hashes in dl_artifacts | hashes for _, hashes in dl_artifacts | ||||
], | ], | ||||
}) | }) | ||||
revision['id'] = revision_id = identifier_to_bytes( | revision['id'] = revision_id = identifier_to_bytes( | ||||
revision_identifier(revision)) | revision_identifier(revision)) | ||||
logger.debug('Revision: %s', revision) | logger.debug('Revision: %s', revision) | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |
Nitpick, I would rather write: