namespaces.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #'fcrconfig' : Namespace('http://fedora.info/definitions/v4/config#'),
  13. 'fcrepo' : Namespace('http://fedora.info/definitions/v4/repository#'),
  14. 'fcadmin' : Namespace('info:fcsystem/graph/admin'),
  15. 'fcres' : Namespace('info:fcres'),
  16. 'fcmain' : Namespace('info:fcsystem/graph/userdata/_main'),
  17. 'fcstruct' : Namespace('info:fcsystem/graph/structure'),
  18. 'fcsystem' : Namespace('info:fcsystem/'),
  19. 'foaf': Namespace('http://xmlns.com/foaf/0.1/'),
  20. 'iana' : Namespace('http://www.iana.org/assignments/relation/'),
  21. 'ldp' : Namespace('http://www.w3.org/ns/ldp#'),
  22. # This is used in the layout attribute router.
  23. 'pcdm': Namespace('http://pcdm.org/models#'),
  24. 'premis' : Namespace('http://www.loc.gov/premis/rdf/v1#'),
  25. 'rdf' : rdflib.namespace.RDF,
  26. 'rdfs' : rdflib.namespace.RDFS,
  27. 'webac' : Namespace('http://www.w3.org/ns/auth/acl#'),
  28. 'xml' : Namespace('http://www.w3.org/XML/1998/namespace'),
  29. 'xsd' : rdflib.namespace.XSD,
  30. 'xsi' : Namespace('http://www.w3.org/2001/XMLSchema-instance'),
  31. }
  32. ns_collection = core_namespaces.copy()
  33. ns_collection.update(config['namespaces'])
  34. ns_mgr = NamespaceManager(Graph())
  35. ns_pfx_sparql = {}
  36. # Collection of prefixes in a dict.
  37. for ns,uri in ns_collection.items():
  38. ns_mgr.bind(ns, uri, override=False)
  39. #ns_pfx_sparql[ns] = 'PREFIX {}: <{}>'.format(ns, uri)