Source code for MyCapytain.common.constants

from rdflib import Namespace, Graph
from rdflib.namespace import SKOS

__all__ = [

#: List of XPath Namespaces used in guidelines
    "tei": "",
    "ti": "",
    "cpt": "",
    "xsd": "",
    "xml": "",
    "rdf": ""

[docs]class RDF_NAMESPACES: """ Namespaces Constants used to provide Namespace capacities across the library :cvar CTS: CTS Namespace :type CTS: Namespace :cvar TEI: TEI Namespace :type TEI: Namespace :cvar DC: DC Elements :type DC: Namespace :cvar CAPITAINS: CapiTainS Ontology :type CAPITAINS: Namespace """ CTS = Namespace("") DTS = Namespace("") TEI = Namespace("") CAPITAINS = Namespace("") HYDRA = Namespace("")
[docs]class Mimetypes: """ Mimetypes constants that are used to provide export functionality to base MyCapytain object. :cvar JSON: JSON Resource mimetype :cvar XML: XML Resource mimetype :cvar PYTHON: Python Native Object :cvar PLAINTEXT: Plain string format """
[docs] class JSON: """ Json Mimetype :cvar Std: Standard JSON Export :cvar CTS: CTS Json Export """ Std = "application/text" CTS = "application/ld+json:CTS" LD = "application/ld+json"
[docs] class DTS: """ JSON DTS Expression :cvar Std: Standard DTS Json-LD Expression :cvar NoParents: DTS Json-LD Expression without parents expression """ Std = "application/ld+json:DTS" NoParents = "application/ld+json:DTS/NoParents"
[docs] class XML: """ XML Mimetype :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"
[docs] class CapiTainS: """ CapiTainS Guideline XML Structured metadata """ CTS = "text/xml:CTS_CapiTainS"
[docs] class PYTHON: """ Python Native Objects :cvar NestedDict: Nested Dictionary Object :cvar ETREE: Python LXML Etree Object """ NestedDict = "python/NestedDict" ETREE = "python/lxml"
[docs] class MyCapytain: """ MyCapytain Objects :cvar ReadableText: MyCapytain.resources.prototypes.text.CtsText """ TextualElement = "Capitains/TextualElement"
PLAINTEXT = "text/plain"
[docs]def bind_graph(graph=None): """ Bind a graph with generic MyCapytain prefixes :param graph: Graph (Optional) :return: Bound graph """ if graph is None: graph = Graph() for prefix, ns in GRAPH_BINDINGS.items(): graph.bind(prefix, ns, True) return graph
global __MYCAPYTAIN_TRIPLE_GRAPH__ __MYCAPYTAIN_TRIPLE_GRAPH__ = bind_graph() def set_graph(graph): global __MYCAPYTAIN_TRIPLE_GRAPH__ __MYCAPYTAIN_TRIPLE_GRAPH__ = graph def get_graph(): return __MYCAPYTAIN_TRIPLE_GRAPH__ RDFLIB_MAPPING = { Mimetypes.XML.RDF: "xml", Mimetypes.JSON.LD: "json-ld", Mimetypes.JSON.DTS.Std: "json-ld" }