コード例 #1
0
def item_from_graph(graph_path, ident):
    graph = ConjunctiveGraph()
    with open(graph_path) as graph_file:
        graph.parse(format='trig', data=graph_file.read())
    from rdflib_django import utils
    utils.get_conjunctive_graph().parse(data=graph.serialize(format='nquads'),
                                        format='nquads')
    item = Item(iri='http://dbpedia.org/resource/' + ident)
    item.save()
    return item
コード例 #2
0
ファイル: rdf_export.py プロジェクト: DarioGT/rdflib-django
    def handle(self, *args, **options):
        store_id = options.get('store')
        context_id = options.get('context')
        target = args[0] if args else sys.stdout

        if context_id:
            graph = utils.get_named_graph(URIRef(context_id), store_id=store_id)
        else:
            graph = utils.get_conjunctive_graph(store_id)

        #noinspection PyUnresolvedReferences
        graph.serialize(target, format=options.get('format'))
コード例 #3
0
def ingest_graph(graph):
    from rdflib_django import utils
    utils.get_conjunctive_graph().parse(data=graph.serialize(format='nquads'),
                                        format='nquads')