Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/storage/__init__.py
Show First 20 Lines • Show All 436 Lines • ▼ Show 20 Lines | def content_ctags_search(self, expression, | ||||
rows of ctags including id, name, lang, kind, line, etc... | rows of ctags including id, name, lang, kind, line, etc... | ||||
""" | """ | ||||
for obj in db.content_ctags_search(expression, last_sha1, limit, | for obj in db.content_ctags_search(expression, last_sha1, limit, | ||||
cur=cur): | cur=cur): | ||||
yield converters.db_to_ctags(dict(zip(db.content_ctags_cols, obj))) | yield converters.db_to_ctags(dict(zip(db.content_ctags_cols, obj))) | ||||
@remote_api_endpoint('content/fossology_license') | @remote_api_endpoint('content/fossology_license') | ||||
@db_transaction_generator() | @db_transaction() | ||||
vlorentz: Use `@db_transaction()` instead | |||||
def content_fossology_license_get(self, ids, db=None, cur=None): | def content_fossology_license_get(self, ids, db=None, cur=None): | ||||
"""Retrieve licenses per id. | """Retrieve licenses per id. | ||||
Args: | Args: | ||||
ids (iterable): sha1 checksums | ids (iterable): sha1 checksums | ||||
Yields: | Yields: | ||||
dict: ``{id: facts}`` where ``facts`` is a dict with the | dict: ``{id: facts}`` where ``facts`` is a list of | ||||
following keys: | dicts with the following keys: | ||||
- **licenses** ([str]): associated licenses for that content | - **licenses** ([str]): associated licenses for that content | ||||
- **tool** (dict): Tool used to compute the license | - **tool** (dict): Tool used to compute the license | ||||
""" | """ | ||||
d = defaultdict(list) | d = defaultdict(list) | ||||
for c in db.content_fossology_license_get_from_list(ids, cur): | for c in db.content_fossology_license_get_from_list(ids, cur): | ||||
license = dict(zip(db.content_fossology_license_cols, c)) | license = dict(zip(db.content_fossology_license_cols, c)) | ||||
id_ = license['id'] | id_ = license['id'] | ||||
d[id_].append(converters.db_to_fossology_license(license)) | d[id_].append(converters.db_to_fossology_license(license)) | ||||
for id_, facts in d.items(): | return d | ||||
yield {id_: facts} | |||||
@remote_api_endpoint('content/fossology_license/add') | @remote_api_endpoint('content/fossology_license/add') | ||||
@db_transaction() | @db_transaction() | ||||
def content_fossology_license_add(self, licenses, conflict_update=False, | def content_fossology_license_add(self, licenses, conflict_update=False, | ||||
db=None, cur=None): | db=None, cur=None): | ||||
"""Add licenses not present in storage. | """Add licenses not present in storage. | ||||
Args: | Args: | ||||
▲ Show 20 Lines • Show All 452 Lines • Show Last 20 Lines |
Use @db_transaction() instead