namespaces.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import rdflib
  2. from rdflib import Graph
  3. from rdflib.namespace import Namespace, NamespaceManager
  4. from lakesuperior.config_parser import config
  5. # Core namespace prefixes. These add to and override any user-defined prefixes.
  6. # @TODO Some of these have been copy-pasted from FCREPO4 and may be deprecated.
  7. core_namespaces = {
  8. 'dc' : rdflib.namespace.DC,
  9. 'dcterms' : rdflib.namespace.DCTERMS,
  10. 'ebucore' : Namespace(
  11. 'http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#'),
  12. 'fcrepo' : Namespace('http://fedora.info/definitions/v4/repository#'),
  13. 'fcadmin' : Namespace('info:fcsystem/graph/admin'),
  14. 'fcres' : Namespace('info:fcres'),
  15. 'fcmain' : Namespace('info:fcsystem/graph/userdata/_main'),
  16. 'fcstruct' : Namespace('info:fcsystem/graph/structure'),
  17. 'fcsystem' : Namespace('info:fcsystem/'),
  18. 'foaf': Namespace('http://xmlns.com/foaf/0.1/'),
  19. 'iana' : Namespace('http://www.iana.org/assignments/relation/'),
  20. 'ldp' : Namespace('http://www.w3.org/ns/ldp#'),
  21. 'pcdm': Namespace('http://pcdm.org/models#'),
  22. 'premis' : Namespace('http://www.loc.gov/premis/rdf/v1#'),
  23. 'rdf' : rdflib.namespace.RDF,
  24. 'rdfs' : rdflib.namespace.RDFS,
  25. 'webac' : Namespace('http://www.w3.org/ns/auth/acl#'),
  26. 'xsd' : rdflib.namespace.XSD,
  27. }
  28. ns_collection = {pfx: Namespace(ns) for pfx, ns in config['namespaces'].items()}
  29. ns_collection.update(core_namespaces)
  30. ns_mgr = NamespaceManager(Graph())
  31. # Collection of prefixes in a dict.
  32. for ns,uri in ns_collection.items():
  33. ns_mgr.bind(ns, uri, override=False)