swh.indexer.fossology_license module


Determine license from file at path.


path – filepath to determine the license


A dict with the following keys:

  • licenses ([str]): associated detected licenses to path

  • path (bytes): content filepath

Return type


class swh.indexer.fossology_license.MixinFossologyLicenseIndexer[source]

Bases: object

Mixin fossology license indexer.

See FossologyLicenseIndexer and FossologyLicensePartitionIndexer

ADDITIONAL_CONFIG = {'tools': ('dict', {'name': 'nomos', 'version': '3.1.0rc2-31-ga2cbb8c', 'configuration': {'command_line': 'nomossa <filepath>'}}), 'workdir': ('str', '/tmp/swh/indexer.fossology.license'), 'write_batch_size': ('int', 1000)}
CONFIG_BASE_FILENAME = 'indexer/fossology_license'
tool: Any
idx_storage: Any
index(id: Union[bytes, Dict, swh.model.model.Revision], data: Optional[bytes] = None, **kwargs) → Dict[str, Any][source]

Index sha1s’ content and store result.

  • id (bytes) – content’s identifier

  • raw_content (bytes) – associated raw content to content id


A dict, representing a content_license, with keys:

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

  • license (bytes): license in bytes

  • path (bytes): path

  • indexer_configuration_id (int): tool used to compute the output

Return type


persist_index_computations(results: List[Dict], policy_update: str) → Dict[str, int][source]

Persist the results in storage.

  • results

    list of content_license dict with the following keys:

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

    • license (bytes): license in bytes

    • path (bytes): path

  • policy_update – either ‘update-dups’ or ‘ignore-dups’ to respectively update duplicates or ignore them

class swh.indexer.fossology_license.FossologyLicenseIndexer(config=None, **kw)[source]

Bases: swh.indexer.fossology_license.MixinFossologyLicenseIndexer, swh.indexer.indexer.ContentIndexer

Indexer in charge of:

  • filtering out content already indexed

  • reading content from objstorage per the content’s id (sha1)

  • computing {license, encoding} from that content

  • store result in storage


Filter out known sha1s and return only missing ones.

idx_storage: Any
class swh.indexer.fossology_license.FossologyLicensePartitionIndexer(config=None, **kw)[source]

Bases: swh.indexer.fossology_license.MixinFossologyLicenseIndexer, swh.indexer.indexer.ContentPartitionIndexer

FossologyLicense Range Indexer working on range/partition of content identifiers.

  • filters out the non textual content

  • (optionally) filters out content already indexed (cf indexed_contents_in_partition())

  • reads content from objstorage per the content’s id (sha1)

  • computes {mimetype, encoding} from that content

  • stores result in storage

indexed_contents_in_partition(partition_id: int, nb_partitions: int, page_token: Optional[str] = None)swh.core.api.classes.PagedResult[bytes, str][source]

Retrieve indexed content id within the partition id

  • partition_id – Index of the partition to fetch

  • nb_partitions – Total number of partitions to split into

  • page_token – opaque token used for pagination


PagedResult of Sha1. If next_page_token is None, there is no more data to fetch

idx_storage: Any