Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/storage/__init__.py
Show First 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | def content_ctags_get(self, ids, db=None, cur=None): | ||||
ids (iterable): sha1 checksums | ids (iterable): sha1 checksums | ||||
Yields: | Yields: | ||||
Dictionaries with keys: | Dictionaries with keys: | ||||
- **id** (bytes): content's identifier | - **id** (bytes): content's identifier | ||||
- **name** (str): symbol's name | - **name** (str): symbol's name | ||||
- **kind** (str): symbol's kind | - **kind** (str): symbol's kind | ||||
- **language** (str): language for that content | - **lang** (str): language for that content | ||||
- **tool** (dict): tool used to compute the ctags' info | - **tool** (dict): tool used to compute the ctags' info | ||||
""" | """ | ||||
for c in db.content_ctags_get_from_list(ids, cur): | for c in db.content_ctags_get_from_list(ids, cur): | ||||
yield converters.db_to_ctags(dict(zip(db.content_ctags_cols, c))) | yield converters.db_to_ctags(dict(zip(db.content_ctags_cols, c))) | ||||
@remote_api_endpoint('content/ctags/add') | @remote_api_endpoint('content/ctags/add') | ||||
@db_transaction() | @db_transaction() | ||||
def content_ctags_add(self, ctags, conflict_update=False, db=None, | def content_ctags_add(self, ctags, conflict_update=False, db=None, | ||||
cur=None): | cur=None): | ||||
"""Add ctags not present in storage | """Add ctags not present in storage | ||||
Args: | Args: | ||||
ctags (iterable): dictionaries with keys: | ctags (iterable): dictionaries with keys: | ||||
- **id** (bytes): sha1 | - **id** (bytes): sha1 | ||||
- **ctags** ([list): List of dictionary with keys: name, kind, | - **ctags** ([list): List of dictionary with keys: name, kind, | ||||
line, language | line, lang | ||||
""" | """ | ||||
def _convert_ctags(__ctags): | def _convert_ctags(__ctags): | ||||
"""Convert ctags dict to list of ctags. | """Convert ctags dict to list of ctags. | ||||
""" | """ | ||||
for ctags in __ctags: | for ctags in __ctags: | ||||
yield from converters.ctags_to_db(ctags) | yield from converters.ctags_to_db(ctags) | ||||
▲ Show 20 Lines • Show All 370 Lines • Show Last 20 Lines |