Skip to content

Commit

Permalink
set contexts, we won't keep this commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sblack-usu committed Oct 24, 2023
1 parent ce601a9 commit 4e59956
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions hsmodels/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from pydantic import AnyUrl, BaseModel
from rdflib import Graph, Literal, URIRef

from hsmodels.namespaces import DC, HSTERMS, ORE, RDF, RDFS1
from hsmodels.namespaces import DC, HSTERMS, ORE, RDF, RDFS1, HSRESOURCE, DCTERMS, SCHEMA, XML, RDFS, CITOTERMS, XSD, \
SH, FOAF, DASH, HSUSER
from hsmodels.schemas.aggregations import (
FileSetMetadata,
GeographicFeatureMetadata,
Expand Down Expand Up @@ -82,10 +83,27 @@ def parse_file(schema, file, file_format='xml', subject=None):


def rdf_graph(schema):
g = Graph()
g.bind('hsresource', HSRESOURCE)
g.bind('dcterms', DCTERMS)
g.bind('rdfs1', RDFS1)
g.bind('schema', SCHEMA)
g.bind('hsterms', HSTERMS)
g.bind('xml', XML)
g.bind('rdfs', RDFS)
g.bind('dc', DC)
g.bind('citoterms', CITOTERMS)
g.bind('xsd', XSD)
g.bind('sh', SH)
g.bind('rdf', RDF)
g.bind('foaf', FOAF)
g.bind('dash', DASH)
g.bind('ORE', ORE)
g.bind('hsuser', HSUSER)
for rdf_schema, user_schema in user_schemas.items():
if isinstance(schema, user_schema):
return _rdf_graph(rdf_schema(**schema.dict(to_rdf=True)), Graph())
return _rdf_graph(schema, Graph())
return _rdf_graph(rdf_schema(**schema.dict(to_rdf=True)), g)
return _rdf_graph(schema, g)


def rdf_string(schema, rdf_format='pretty-xml'):
Expand Down

0 comments on commit 4e59956

Please sign in to comment.