swh.indexer.metadata_dictionary.gitea module#

class swh.indexer.metadata_dictionary.gitea.GiteaMapping(log_suffix='')[source]#

Bases: BaseExtrinsicMapping, JsonMapping

name = 'gitea'#
mapping = {'clone_url': rdflib.term.URIRef('http://schema.org/codeRepository'), 'created_at': rdflib.term.URIRef('http://schema.org/dateCreated'), 'description': rdflib.term.URIRef('http://schema.org/description'), 'language': rdflib.term.URIRef('http://schema.org/programmingLanguage'), 'languages': rdflib.term.URIRef('http://schema.org/programmingLanguage'), 'name': rdflib.term.URIRef('http://schema.org/name'), 'owner': rdflib.term.URIRef('http://schema.org/author'), 'updated_at': rdflib.term.URIRef('http://schema.org/dateModified'), 'website': rdflib.term.URIRef('http://schema.org/url')}#
uri_fields: List[str] = ['website', 'clone_url']#

List of fields that are simple URIs, and don’t need any normalization.

date_fields: List[str] = ['created_at', 'updated_at']#

//schema.org/Date

Type:

List of fields that are strings that should be typed as http

string_fields: List[str] = ['name', 'full_name', 'language', 'description']#

List of fields that are simple strings, and don’t need any normalization.

classmethod extrinsic_metadata_formats() Tuple[str, ...][source]#

Returns the list of extrinsic metadata formats which can be translated by this mapping

extra_translation(graph, root, content_dict)[source]#

Called at the end of the translation process, and may add arbitrary triples to graph based on the input dictionary (passed as d).

get_root_uri(content_dict: dict) URIRef[source]#

Returns an URI for the SoftwareSourceCode or Repository being described.

The default implementation uses a temporary URI that is stripped before normalization by _translate_dict().

translate_parent(graph: Graph, root: BNode, v: Any) None[source]#
>>> graph = Graph()
>>> root = URIRef("http://example.org/test-fork")
>>> GiteaMapping().translate_parent(
...     graph, root, {"html_url": "http://example.org/test-software"})
>>> prettyprint_graph(graph, root)
{
    "@id": "http://example.org/test-fork",
    "https://forgefed.org/ns#forkedFrom": {
        "@id": "http://example.org/test-software"
    }
}
translate_forks_count(graph: Graph, root: BNode, v: Any) None[source]#
>>> graph = Graph()
>>> root = URIRef("http://example.org/test-software")
>>> GiteaMapping().translate_forks_count(graph, root, 42)
>>> prettyprint_graph(graph, root)
{
    "@id": ...,
    "https://forgefed.org/ns#forks": {
        "@type": "https://www.w3.org/ns/activitystreams#OrderedCollection",
        "https://www.w3.org/ns/activitystreams#totalItems": {
            "@type": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger",
            "@value": "42"
        }
    }
}
translate_stars_count(graph: Graph, root: BNode, v: Any) None[source]#
>>> graph = Graph()
>>> root = URIRef("http://example.org/test-software")
>>> GiteaMapping().translate_stars_count(graph, root, 42)
>>> prettyprint_graph(graph, root)
{
    "@id": ...,
    "https://www.w3.org/ns/activitystreams#likes": {
        "@type": "https://www.w3.org/ns/activitystreams#Collection",
        "https://www.w3.org/ns/activitystreams#totalItems": {
            "@type": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger",
            "@value": "42"
        }
    }
}
translate_watchers_count(graph: Graph, root: BNode, v: Any) None[source]#
>>> graph = Graph()
>>> root = URIRef("http://example.org/test-software")
>>> GiteaMapping().translate_watchers_count(graph, root, 42)
>>> prettyprint_graph(graph, root)
{
    "@id": ...,
    "https://www.w3.org/ns/activitystreams#followers": {
        "@type": "https://www.w3.org/ns/activitystreams#Collection",
        "https://www.w3.org/ns/activitystreams#totalItems": {
            "@type": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger",
            "@value": "42"
        }
    }
}