swh.indexer.metadata_dictionary.github module#

class swh.indexer.metadata_dictionary.github.GitHubMapping(log_suffix='')[source]#

Bases: BaseExtrinsicMapping, JsonMapping

name = 'github'#
mapping = {'archive_url': rdflib.term.URIRef('http://schema.org/downloadUrl'), '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'), 'full_name': rdflib.term.URIRef('http://schema.org/name'), 'html_url': rdflib.term.URIRef('http://schema.org/codeRepository'), 'id': rdflib.term.URIRef('http://schema.org/identifier'), 'issues_url': rdflib.term.URIRef('https://codemeta.github.io/terms/issueTracker'), 'language': rdflib.term.URIRef('http://schema.org/programmingLanguage'), 'languages_url': rdflib.term.URIRef('http://schema.org/programmingLanguage'), 'license': rdflib.term.URIRef('http://schema.org/license'), 'login': rdflib.term.URIRef('http://schema.org/author'), 'topics': rdflib.term.URIRef('http://schema.org/keywords'), 'updated_at': rdflib.term.URIRef('http://schema.org/dateModified')}#
uri_fields: List[str] = ['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] = ['description', 'full_name', 'language', 'topics']#

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")
>>> GitHubMapping().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")
>>> GitHubMapping().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": 42
    }
}
translate_stargazers_count(graph: Graph, root: BNode, v: Any) None[source]#
>>> graph = Graph()
>>> root = URIRef("http://example.org/test-software")
>>> GitHubMapping().translate_stargazers_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": 42
    }
}
translate_watchers_count(graph: Graph, root: BNode, v: Any) None[source]#
>>> graph = Graph()
>>> root = URIRef("http://example.org/test-software")
>>> GitHubMapping().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": 42
    }
}
normalize_license(d)[source]#
>>> GitHubMapping().normalize_license({'spdx_id': 'MIT'})
rdflib.term.URIRef('https://spdx.org/licenses/MIT')