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 = objects.get('content') | ||||
if _contents: | |||||
contents = _contents.values() | |||||
anlambert: Nitpick, I would rather write:
```lang=python
contents = objects.get('content', {}).values()… | |||||
ardumontAuthorUnsubmitted Done Inline Actionsnicer ;) ardumont: nicer ;) | |||||
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 = objects.get('directory') | |||||
if _directories: | |||||
directories = list(_directories.values()) | |||||
anlambertUnsubmitted Not Done Inline Actionssame here anlambert: same here | |||||
logger.debug('Number of directories: %s', | logger.debug('Number of directories: %s', | ||||
len(directories)) | len(directories)) | ||||
status_load = 'eventful' | |||||
self.storage.directory_add(directories) | self.storage.directory_add(directories) | ||||
# 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, | ||||
}) | }) | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |
Nitpick, I would rather write: