Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/storage/in_memory.py
Show First 20 Lines • Show All 339 Lines • ▼ Show 20 Lines | def content_ctags_search(self, expression, limit=10, last_sha1=None): | ||||
id_ = item_dict.pop("id") | id_ = item_dict.pop("id") | ||||
tool = item_dict.pop("tool") | tool = item_dict.pop("tool") | ||||
ctags.append(item_dict) | ctags.append(item_dict) | ||||
if ctags: | if ctags: | ||||
for ctag in ctags: | for ctag in ctags: | ||||
yield {"id": id_, "tool": tool, **ctag} | yield {"id": id_, "tool": tool, **ctag} | ||||
def content_fossology_license_get(self, ids): | def content_fossology_license_get( | ||||
# Rewrites the output of SubStorage.get from the old format to | self, ids: Iterable[Sha1] | ||||
# the new one. SubStorage.get should be updated once all other | ) -> Iterable[ContentLicenseRow]: | ||||
# *_get methods use the new format. | return self._licenses.get(ids) | ||||
# See: https://forge.softwareheritage.org/T1433 | |||||
for id_ in ids: | |||||
items = {} | |||||
for obj in self._licenses.get([id_]): | |||||
items.setdefault(obj.tool["id"], (obj.tool, []))[1].append(obj.license) | |||||
if items: | |||||
yield { | |||||
id_: [ | |||||
{"tool": tool, "licenses": licenses} | |||||
for (tool, licenses) in items.values() | |||||
] | |||||
} | |||||
def content_fossology_license_add( | def content_fossology_license_add( | ||||
self, licenses: List[Dict], conflict_update: bool = False | self, licenses: List[ContentLicenseRow], conflict_update: bool = False | ||||
) -> Dict[str, int]: | ) -> Dict[str, int]: | ||||
check_id_types(licenses) | added = self._licenses.add(licenses, conflict_update) | ||||
added = self._licenses.add( | |||||
map( | |||||
ContentLicenseRow.from_dict, | |||||
itertools.chain.from_iterable( | |||||
map(converters.fossology_license_to_db, licenses) | |||||
), | |||||
), | |||||
conflict_update, | |||||
) | |||||
return {"content_fossology_license:add": added} | return {"content_fossology_license:add": added} | ||||
def content_fossology_license_get_partition( | def content_fossology_license_get_partition( | ||||
self, | self, | ||||
indexer_configuration_id: int, | indexer_configuration_id: int, | ||||
partition_id: int, | partition_id: int, | ||||
nb_partitions: int, | nb_partitions: int, | ||||
page_token: Optional[str] = None, | page_token: Optional[str] = None, | ||||
▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines |