def _build_and_parse_format_mediatype_graph(self, format_item=None, mediatype_item=None): g = Graph() dataset = URIRef("http://example.org/datasets/1") g.add((dataset, RDF.type, self.DCAT.Dataset)) distribution = URIRef("http://example.org/datasets/1/ds/1") g.add((dataset, self.DCAT.distribution, distribution)) g.add((distribution, RDF.type, self.DCAT.Distribution)) if format_item: g.add((distribution, self.DCT['format'], format_item)) if mediatype_item: g.add((distribution, self.DCAT.mediaType, mediatype_item)) if format_item is None and mediatype_item is None: raise AssertionError( 'At least one of format or mediaType is required!') p = RDFParser(profiles=['euro_dcat_ap', 'dcatap_de']) p.g = g dataset = [d for d in p.datasets()][0] return dataset.get('resources')
def _build_and_parse_format_mediatype_graph(self, format_item=None, mediatype_item=None): """ Creates a minimal graph with a distribution having the specified dct:format and dcat:mediaType nodes. At least one of those nodes has to be given. After creating the graph, it is parsed using the euro_dcat_ap profile. :param format_item: Literal or URIRef object for dct:format. None if the node should be omitted. :param mediatype_item: Literal or URIRef object for dcat:mediaType. None if the node should be omitted. :returns: The parsed resource dict """ g = Graph() dataset = URIRef("http://example.org/datasets/1") g.add((dataset, RDF.type, DCAT.Dataset)) distribution = URIRef("http://example.org/datasets/1/ds/1") g.add((dataset, DCAT.distribution, distribution)) g.add((distribution, RDF.type, DCAT.Distribution)) if format_item: g.add((distribution, DCT['format'], format_item)) if mediatype_item: g.add((distribution, DCAT.mediaType, mediatype_item)) if format_item is None and mediatype_item is None: raise AssertionError( 'At least one of format or mediaType is required!') p = RDFParser(profiles=['euro_dcat_ap']) p.g = g dataset = [d for d in p.datasets()][0] return dataset.get('resources')
def _build_and_parse_format_mediatype_graph(self, format_item=None, mediatype_item=None): """ Creates a minimal graph with a distribution having the specified dct:format and dcat:mediaType nodes. At least one of those nodes has to be given. After creating the graph, it is parsed using the euro_dcat_ap profile. :param format_item: Literal or URIRef object for dct:format. None if the node should be omitted. :param mediatype_item: Literal or URIRef object for dcat:mediaType. None if the node should be omitted. :returns: The parsed resource dict """ g = Graph() dataset = URIRef("http://example.org/datasets/1") g.add((dataset, RDF.type, DCAT.Dataset)) distribution = URIRef("http://example.org/datasets/1/ds/1") g.add((dataset, DCAT.distribution, distribution)) g.add((distribution, RDF.type, DCAT.Distribution)) if format_item: g.add((distribution, DCT['format'], format_item)) if mediatype_item: g.add((distribution, DCAT.mediaType, mediatype_item)) if format_item is None and mediatype_item is None: raise AssertionError('At least one of format or mediaType is required!') p = RDFParser(profiles=['euro_dcat_ap']) p.g = g dataset = [d for d in p.datasets()][0] return dataset.get('resources')