Skip to content

Commit

Permalink
RDFLib as a metadata backend (#106)
Browse files Browse the repository at this point in the history
Generally replaces the OLD metadata system
Fixes #100
Fixes #101
Fixes #104
  • Loading branch information
PonteIneptique committed Jan 26, 2017
1 parent bca6c86 commit 0bb48d1
Show file tree
Hide file tree
Showing 42 changed files with 2,538 additions and 3,202 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ after_success:
branches:
only:
- master
- 0.1.0dev
- rdflib-shift
- dts-dev
2 changes: 1 addition & 1 deletion MyCapytain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
.. module:: MyCapytain
:platform: Unix, Windows
:synopsis: Canonical Text Service and Canonical URN tool suite for Python
:synopsis: Canonical PrototypeText Service and Canonical URN tool suite for Python
.. moduleauthor:: Thibault Clérice <leponteineptique@gmail.com>
Expand Down
34 changes: 26 additions & 8 deletions MyCapytain/common/constants.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from collections import namedtuple
from inspect import getmro
from rdflib import Namespace, Graph
from rdflib.namespace import SKOS


#: List of XPath Namespaces used in guidelines
NS = {
"tei": "http://www.tei-c.org/ns/1.0",
"ahab": "http://localhost.local",
"ti": "http://chs.harvard.edu/xmlns/cts",
"xml": "http://www.w3.org/XML/1998/namespace"
}
Expand Down Expand Up @@ -63,9 +64,6 @@
'http://xmlns.com/wot/0.1/': 'wot'
}

#: Namespace tuple that can be used to express namespace information
Namespace = namedtuple("Namespace", ["uri", "prefix"])


class NAMESPACES:
""" Namespaces Constants used to provide Namespace capacities across the library
Expand All @@ -77,9 +75,9 @@ class NAMESPACES:
:cvar DC: DC Elements
:type DC: Namespace
"""
CTS = Namespace("http://chs.harvard.edu/xmlns/cts/", "ti")
TEI = Namespace("http://www.tei-c.org/ns/1.0/", "tei")
DC = Namespace("http://purl.org/dc/elements/1.1/", "dc")
CTS = Namespace("http://chs.harvard.edu/xmlns/cts/")
DTS = Namespace("http://w3id.org/dts-ontology/")
TEI = Namespace("http://www.tei-c.org/ns/1.0/")


class Mimetypes:
Expand All @@ -100,6 +98,7 @@ class JSON:
"""
Std = "application/text"
CTS = "application/ld+json:CTS"
LD = "application/ld+json"

class DTS:
""" JSON DTS Expression
Expand All @@ -116,10 +115,13 @@ class XML:
:cvar Std: Standard XML Export
:cvar RDF: RDF XML Expression Export
:cvar CTS: CTS API XML Expression Export
:cvar TEI: TEI XML Expression Export
"""
Std = "text/xml"
RDF = "application/rdf+xml"
RDFa = "application/rdfa+xml"
CTS = "text/xml:CTS"
TEI = "text/xml:tei"

class PYTHON:
""" Python Native Objects
Expand Down Expand Up @@ -148,6 +150,9 @@ class Exportable(object):
EXPORT_TO = []
DEFAULT_EXPORT = None

def __init__(self, *args, **kwargs):
pass

@property
def export_capacities(self):
""" List Mimetypes that current object can export to
Expand Down Expand Up @@ -179,3 +184,16 @@ def export(self, output=None, **kwargs):
raise NotImplementedError(
"Mimetype {} has not been implemented for this resource".format(output or "(No Mimetype)")
)


GRAPH = Graph()
GRAPH.bind("", NAMESPACES.CTS)
GRAPH.bind("dts", NAMESPACES.DTS)
GRAPH.bind("tei", NAMESPACES.TEI)
GRAPH.bind("skos", SKOS)

RDFLIB_MAPPING = {
Mimetypes.XML.RDF: "xml",
Mimetypes.JSON.LD: "json-ld",
Mimetypes.JSON.DTS.Std: "json-ld"
}

0 comments on commit 0bb48d1

Please sign in to comment.