Example #1
0
def _add_optional_distribution_props(distribution: Distribution,
                                     resource: Mapping) -> None:
    distribution.title = {
        "nb": resource["name"].replace("_", " ").capitalize()
    }
    distribution.description = {
        "nb": utils.remove_new_line(resource["description"])
    }
    distribution.download_URL = URI(resource["path"])
Example #2
0
def create_html_distribution(dp_metadata: dict):
    html_distribution = Distribution()
    html_distribution.title = {"nb": dp_metadata["title"]}
    html_distribution.formats = ["text/html"]
    html_distribution.description = {"nb": dp_metadata["description"]}
    html_distribution.identifier = URI(
        os.environ["DATASET_CONCEPT_IDENTIFIER"] + dp_metadata["id"])
    html_distribution.license = URI(
        "http://creativecommons.org/licenses/by/4.0/deed.no")
    html_distribution.access_URL = URI(
        os.environ["DATASET_CONCEPT_IDENTIFIER"] + dp_metadata["id"])
    return html_distribution
Example #3
0
def test_to_graph_should_return_description() -> None:
    """It returns a description graph isomorphic to spec."""
    distribution = Distribution()
    distribution.identifier = "http://example.com/distributions/1"
    distribution.description = {"nb": "Beskrivelse", "en": "Description"}

    src = """
    @prefix dct: <http://purl.org/dc/terms/> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix dcat: <http://www.w3.org/ns/dcat#> .

    <http://example.com/distributions/1> a dcat:Distribution ;
        dct:description   "Description"@en, "Beskrivelse"@nb ;
        .
    """
    g1 = Graph().parse(data=distribution.to_rdf(), format="turtle")
    g2 = Graph().parse(data=src, format="turtle")

    _isomorphic = isomorphic(g1, g2)
    if not _isomorphic:
        _dump_diff(g1, g2)
        pass
    assert _isomorphic