swh.indexer.ctags module

swh.indexer.ctags.compute_language(content, log=None)[source]
swh.indexer.ctags.run_ctags(path, lang=None, ctags_command='ctags') Iterator[Dict[str, Any]][source]

Run ctags on file path with optional language.

Parameters
  • path – path to the file

  • lang – language for that path (optional)

Yields

dict – ctags’ output

class swh.indexer.ctags.CtagsIndexer(*args, **kwargs)[source]

Bases: swh.indexer.indexer.ContentIndexer[swh.indexer.storage.model.ContentCtagsRow]

Prepare and check that the indexer is ready to run.

filter(ids)[source]

Filter out known sha1s and return only missing ones.

index(id: bytes, data: Optional[bytes] = None, **kwargs) List[swh.indexer.storage.model.ContentCtagsRow][source]

Index sha1s’ content and store result.

Parameters
  • id (bytes) – content’s identifier

  • data (bytes) – raw content in bytes

Returns

a dict representing a content_mimetype with keys:

  • id (bytes): content’s identifier (sha1)

  • ctags ([dict]): ctags list of symbols

Return type

dict

persist_index_computations(results: List[swh.indexer.storage.model.ContentCtagsRow]) Dict[str, int][source]

Persist the results in storage.

Parameters

results – list of ctags returned by index()

results: List[swh.indexer.indexer.TResult]
scheduler: Any
storage: swh.storage.interface.StorageInterface
objstorage: Any
idx_storage: swh.indexer.storage.interface.IndexerStorageInterface