MyCapytain API Documentation

Utilities, metadata and references

Module common contains tools such as a namespace dictionary as well as cross-implementation objects, like URN, Citations…

Base

class MyCapytain.common.base.Exportable(*args, **kwargs)[source]

Objects that supports Export

Variables:EXPORT_TO – List of Mimetypes the resource can export to
export(output=None, **kwargs)[source]

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
export_capacities

List Mimetypes that current object can export to

Constants

MyCapytain.common.constants.XPATH_NAMESPACES = {'cpt': 'http://purl.org/capitains/ns/1.0#', 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'tei': 'http://www.tei-c.org/ns/1.0', 'ti': 'http://chs.harvard.edu/xmlns/cts', 'xml': 'http://www.w3.org/XML/1998/namespace', 'xsd': 'http://www.w3.org/2001/XMLSchema#'}

List of XPath Namespaces used in guidelines

class MyCapytain.common.constants.RDF_NAMESPACES[source]

Namespaces Constants used to provide Namespace capacities across the library

Variables:
  • CTS – CTS Namespace
  • TEI – TEI Namespace
  • DC – DC Elements
  • CAPITAINS – CapiTainS Ontology
class MyCapytain.common.constants.Mimetypes[source]

Mimetypes constants that are used to provide export functionality to base MyCapytain object.

Variables:
  • JSON – JSON Resource mimetype
  • XML – XML Resource mimetype
  • PYTHON – Python Native Object
  • PLAINTEXT – Plain string format
class JSON[source]

Json Mimetype

Variables:
  • Std – Standard JSON Export
  • CTS – CTS Json Export
class DTS[source]

JSON DTS Expression

Variables:
  • Std – Standard DTS Json-LD Expression
  • NoParents – DTS Json-LD Expression without parents expression
class PYTHON[source]

Python Native Objects

Variables:
  • NestedDict – Nested Dictionary Object
  • ETREE – Python LXML Etree Object
class MyCapytain[source]

MyCapytain Objects

Variables:ReadableText – MyCapytain.resources.prototypes.text.CtsText
class XML[source]

XML Mimetype

Variables:
  • Std – Standard XML Export
  • RDF – RDF XML Expression Export
  • CTS – CTS API XML Expression Export
  • TEI – TEI XML Expression Export
class CapiTainS[source]

CapiTainS Guideline XML Structured metadata

MyCapytain.common.constants.bind_graph(graph=None)[source]

Bind a graph with generic MyCapytain prefixes

Parameters:graph – Graph (Optional)
Returns:Bound graph

URN, References and Citations

MyCapytain Base Objects

class MyCapytain.common.reference.NodeId(identifier=None, children=None, parent=None, siblings=(None, None), depth=None)[source]

Collection of directional references for a Tree

Parameters:
  • identifier (str) – Current object identifier
  • children ([str]) – Current node Children’s Identifier
  • parent (str) – Parent of the current node
  • siblings (str) – Previous and next node of the current node
  • depth (int) – Depth of the node in the global hierarchy of the text tree
class MyCapytain.common.reference.BaseCitationSet(children=None)[source]

A citation set is a collection of citations that optionnaly can be matched using a .match() function

Parameters:children ([BaseCitation]) – List of Citation
class MyCapytain.common.reference.BaseReference[source]

BaseReference represents a passage identifier, range or not

It is made of two major properties : .start and .end

To check if the object is a range, you can use the method .is_range()

class MyCapytain.common.reference.BaseReferenceSet[source]

A BaseReferenceSet is a set of Reference (= a bag of identifier) that can carry citation and level information (what kind of reference is this reference ? Where am I in the levels of the current document ?)

It can be iterate like a tuple and has a .citation and .level property

Canonical Text Services Objects

class MyCapytain.common.reference.Citation(name=None, xpath=None, scope=None, refsDecl=None, child=None)[source]

A citation object gives informations about the scheme

Parameters:
  • name (basestring) – Name of the citation (e.g. “book”)
  • xpath (basestring) – Xpath of the citation (As described by CTS norm)
  • scope – Scope of the citation (As described by CTS norm)
  • refsDecl (basestring) – refsDecl version
  • child (Citation) – A citation
Variables:
  • name – Name of the citation (e.g. “book”)
  • xpath – Xpath of the citation (As described by CTS norm)
  • scope – Scope of the citation (As described by CTS norm)
  • refsDecl – refsDecl version
  • child – A citation
class MyCapytain.common.reference.CtsReference[source]

A reference object giving information

Example:
>>>    a = CtsReference("1.1@Achiles[1]-1.2@Zeus[1]")
>>>    b = CtsReference("1.1")
>>>    CtsReference("1.1-2.2.2").highest == CtsSinglePassageId("1.1")

Reference object supports the following magic methods : len(), str() and eq().

Example:
>>>    len(a) == 2 && len(b) == 1
>>>    str(a) == "1.1@Achiles[1]-1.2@Zeus[1]"
>>>    b == CtsReference("1.1") && b != a

Note

Reference(…).subreference and .list are not available for range. You will need to convert .start or .end to a Reference

>>>    ref = CtsReference('1.2.3')
class MyCapytain.common.reference.CtsReferenceSet[source]

A CTS version of the BaseReferenceSet

Distributed Text Services Objects

class MyCapytain.common.reference.URN(urn)[source]

A URN object giving all useful sections

Parameters:

urn (str) – A CTS URN

Variables:
  • NAMESPACE – Constant representing the URN until its namespace
  • TEXTGROUP – Constant representing the URN until its textgroup
  • WORK – Constant representing the URN until its work
  • VERSION – Constant representing the URN until its version
  • PASSAGE – Constant representing the URN until its full passage
  • PASSAGE_START – Constant representing the URN until its passage (end excluded)
  • PASSAGE_END – Constant representing the URN until its passage (start excluded)
  • NO_PASSAGE – Constant representing the URN until its passage excluding its passage
  • COMPLETE – Constant representing the complete URN
Example:
>>>    a = URN(urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1")

URN object supports the following magic methods : len(), str() and eq(), gt() and lt().

Example:
>>>     b = URN("urn:cts:latinLit:phi1294.phi002")
>>>     a != b
>>>     a > b # It has more member. Only member count is compared
>>>     b < a
>>>     len(a) == 5 # CtsReference is not counted to not induce count equivalencies with the optional version
>>>     len(b) == 4
class MyCapytain.common.reference.DtsCitation(name=None, children=None, root=None)[source]
class MyCapytain.common.reference.DtsCitationSet(children=None)[source]

Set of citations following the DTS model (Unlike CTS, one citation can have two or more children)

Metadata containers

class MyCapytain.common.metadata.Metadata(node=None, *args, **kwargs)[source]

A metadatum aggregation object provided to centralize metadata

Parameters:

keys ([text_type]) – A metadata field names list

Variables:
  • EXPORT_TO – List of exportable supported formats
  • DEFAULT_EXPORT – Default export (CTS XML Inventory)
  • STORE – RDF Store
add(key, value, lang=None)[source]

Add a triple to the graph related to this node

Parameters:
  • key – Predicate of the triple
  • value – Object of the triple
  • lang – Language of the triple if applicable
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
export_capacities

List Mimetypes that current object can export to

get(key, lang=None)[source]

Returns triple related to this node. Can filter on lang

Parameters:
  • key – Predicate of the triple
  • lang – Language of the triple if applicable
Return type:

Literal or BNode or URIRef

static getOr(subject, predicate, *args, **kwargs)[source]

Retrieve a metadata node or generate a new one

Parameters:
  • subject – Subject to which the metadata node should be connected
  • predicate – Predicate by which the metadata node should be connected
Returns:

Metadata for given node

Return type:

Metadata

get_single(key, lang=None)[source]

Returns a single triple related to this node.

Parameters:
  • key – Predicate of the triple
  • lang – Language of the triple if applicable
Return type:

Literal or BNode or URIRef

graph

Quick access to the graph this node is connected to

Return type:Graph
predicate_object(predicate=None, obj=None)[source]

Retrieve predicate and object around this object

Parameters:
  • predicate – Predicate to match, None to match all
  • obj – Object to match, None to match all
Returns:

List of resources

remove(predicate=None, obj=None)[source]

Remove triple matching the predicate or the object

Parameters:
  • predicate – Predicate to match, None to match all
  • obj – Object to match, None to match all
set(key: rdflib.term.URIRef, value: Union[rdflib.term.Literal, rdflib.term.BNode, rdflib.term.URIRef, str, int], lang: Optional[str] = None)[source]

Set the VALUE for KEY predicate in the Metadata Graph

Parameters:
  • key – Predicate to be set (eg. DCT.creator)
  • value – Value to be stored (eg. “Cicero”)
  • lang – [Optional] Language of the value (eg. “la”)
unlink(subj=None, predicate=None)[source]

Remove triple where Metadata is the object

Parameters:
  • subj – Subject to match, None to match all
  • predicate – Predicate to match, None to match all

Utilities

API Retrievers

Module endpoints contains prototypes and implementation of retrievers in MyCapytain

CTS 5 API

class MyCapytain.retrievers.cts5.HttpCtsRetriever(endpoint, inventory=None)[source]

Bases: MyCapytain.retrievers.prototypes.CtsRetriever

Basic integration of the MyCapytain.retrievers.proto.CTS abstraction

call(parameters)[source]

Call an endpoint given the parameters

Parameters:parameters (dict) – Dictionary of parameters
Return type:text
getCapabilities(inventory=None, urn=None)[source]

Retrieve the inventory information of an API

Parameters:
  • inventory (text) – Name of the inventory
  • urn (str) – URN to filter with
Return type:

str

getFirstUrn(urn, inventory=None)[source]

Retrieve the first passage urn of a text

Parameters:
  • urn (text) – URN identifying the text
  • inventory (text) – Name of the inventory
Return type:

str

getLabel(urn, inventory=None)[source]

Retrieve informations about a CTS Urn

Parameters:
  • urn (text) – URN identifying the text’s passage (Minimum depth : 1)
  • inventory (text) – Name of the inventory
Return type:

str

getMetadata(objectId=None, **filters)[source]

Request metadata about a text or a collection

Parameters:
  • objectId – Filter for some object identifier
  • filters – Kwargs parameters. URN and Inv are available
Returns:

GetCapabilities CTS API request response

getPassage(urn, inventory=None, context=None)[source]

Retrieve a passage

Parameters:
  • urn (text) – URN identifying the text’s passage (Minimum depth : 1)
  • inventory (text) – Name of the inventory
  • context (int) – Number of citation units at the same level of the citation hierarchy as the requested urn, immediately preceding and immediately following the requested urn to include in the reply
Return type:

str

getPassagePlus(urn, inventory=None, context=None)[source]

Retrieve a passage and information about it

Parameters:
  • urn (text) – URN identifying the text’s passage (Minimum depth : 1)
  • inventory (text) – Name of the inventory
  • context (int) – Number of citation units at the same level of the citation hierarchy as the requested urn, immediately preceding and immediately following the requested urn to include in the reply
Return type:

str

getPrevNextUrn(urn, inventory=None)[source]

Retrieve the previous and next passage urn of one passage

Parameters:
  • urn (text) – URN identifying the text’s passage (Minimum depth : 1)
  • inventory (text) – Name of the inventory
Return type:

str

getReffs(textId, level=1, subreference=None)[source]

Retrieve the siblings of a textual node

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • level (int) – Depth for retrieval
  • subreference (str) – CapitainsCtsPassage Reference
Returns:

List of references

Return type:

[str]

getSiblings(textId, subreference)[source]

Retrieve the siblings of a textual node

Parameters:
  • textId – CtsTextMetadata Identifier
  • reference – CapitainsCtsPassage Reference
Returns:

GetPrevNextUrn request response from the endpoint

getTextualNode(textId, subreference=None, prevnext=False, metadata=False)[source]

Retrieve a text node from the API

Parameters:
  • textId – CtsTextMetadata Identifier
  • subreference – CapitainsCtsPassage Reference
  • prevnext – Retrieve graph representing previous and next passage
  • metadata – Retrieve metadata about the passage and the text
Returns:

GetPassage or GetPassagePlus CTS API request response

getValidReff(urn, inventory=None, level=None)[source]

Retrieve valid urn-references for a text

Parameters:
  • urn (text) – URN identifying the text
  • inventory (text) – Name of the inventory
  • level (int) – Depth of references expected
Returns:

XML Response from the API as string

Return type:

str

Prototypes

class MyCapytain.retrievers.prototypes.API(endpoint)[source]

Bases: object

API Prototype object

Parameters:
  • self (API) – Object
  • endpoint (text) – URL of the API
Variables:

endpoint – Url of the endpoint

class MyCapytain.retrievers.prototypes.CitableTextServiceRetriever(endpoint)[source]

Bases: MyCapytain.retrievers.prototypes.API

Citable CtsTextMetadata Service retrievers should have at least have some of the following properties

getMetadata(objectId=None, **filters)[source]

Request metadata about a text or a collection

Parameters:
  • objectId – CtsTextMetadata Identifier
  • filters – Kwargs parameters. URN and Inv are available
Returns:

Metadata of text from an API or the likes as bytes

getReffs(textId, level=1, subreference=None)[source]

Retrieve the siblings of a textual node

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • level (int) – Depth for retrieval
  • subreference (str) – CapitainsCtsPassage Reference
Returns:

List of references

Return type:

[str]

getSiblings(textId, subreference)[source]

Retrieve the siblings of a textual node

Parameters:
  • textId – CtsTextMetadata Identifier
  • subreference – CapitainsCtsPassage Reference
Returns:

Siblings references from an API or the likes as bytes

getTextualNode(textId, subreference=None, prevnext=False, metadata=False)[source]

Retrieve a text node from the API

Parameters:
  • textId – CtsTextMetadata Identifier
  • subreference – CapitainsCtsPassage Reference
  • prevnext – Retrieve graph representing previous and next passage
  • metadata – Retrieve metadata about the passage and the text
Returns:

CtsTextMetadata of a CapitainsCtsPassage from an API or the likes as bytes

class MyCapytain.retrievers.prototypes.CtsRetriever(endpoint)[source]

Bases: MyCapytain.retrievers.prototypes.CitableTextServiceRetriever

CTS API Endpoint Prototype

getCapabilities(inventory)[source]

Retrieve the inventory information of an API

Parameters:inventory (text) – Name of the inventory
Return type:str
getFirstUrn(urn, inventory)[source]

Retrieve the first passage urn of a text

Parameters:
  • urn (text) – URN identifying the text
  • inventory (text) – Name of the inventory
Return type:

str

getLabel(urn, inventory)[source]

Retrieve informations about a CTS Urn

Parameters:
  • urn (text) – URN identifying the text’s passage (Minimum depth : 1)
  • inventory (text) – Name of the inventory
Return type:

str

getMetadata(objectId=None, **filters)

Request metadata about a text or a collection

Parameters:
  • objectId – CtsTextMetadata Identifier
  • filters – Kwargs parameters. URN and Inv are available
Returns:

Metadata of text from an API or the likes as bytes

getPassage(urn, inventory, context=None)[source]

Retrieve a passage

Parameters:
  • urn (text) – URN identifying the text’s passage (Minimum depth : 1)
  • inventory (text) – Name of the inventory
  • context (int) – Number of citation units at the same level of the citation hierarchy as the requested urn, immediately preceding and immediately following the requested urn to include in the reply
Return type:

str

getPassagePlus(urn, inventory, context=None)[source]

Retrieve a passage and informations about it

Parameters:
  • urn (text) – URN identifying the text’s passage (Minimum depth : 1)
  • inventory (text) – Name of the inventory
  • context (int) – Number of citation units at the same level of the citation hierarchy as the requested urn, immediately preceding and immediately following the requested urn to include in the reply
Return type:

str

getPrevNextUrn(urn, inventory)[source]

Retrieve the previous and next passage urn of one passage

Parameters:
  • urn (text) – URN identifying the text’s passage (Minimum depth : 1)
  • inventory (text) – Name of the inventory
Return type:

str

getReffs(textId, level=1, subreference=None)

Retrieve the siblings of a textual node

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • level (int) – Depth for retrieval
  • subreference (str) – CapitainsCtsPassage Reference
Returns:

List of references

Return type:

[str]

getSiblings(textId, subreference)

Retrieve the siblings of a textual node

Parameters:
  • textId – CtsTextMetadata Identifier
  • subreference – CapitainsCtsPassage Reference
Returns:

Siblings references from an API or the likes as bytes

getTextualNode(textId, subreference=None, prevnext=False, metadata=False)

Retrieve a text node from the API

Parameters:
  • textId – CtsTextMetadata Identifier
  • subreference – CapitainsCtsPassage Reference
  • prevnext – Retrieve graph representing previous and next passage
  • metadata – Retrieve metadata about the passage and the text
Returns:

CtsTextMetadata of a CapitainsCtsPassage from an API or the likes as bytes

getValidReff(urn, inventory, level=1)[source]

Retrieve valid urn-references for a text

Parameters:
  • urn (text) – URN identifying the text
  • inventory (text) – Name of the inventory
  • level (int) – Depth of references expected
Return type:

str

Resolvers

Remote CTS API

class MyCapytain.resolvers.cts.api.HttpCtsResolver(endpoint)[source]

HttpCtsResolver provide a resolver for CTS API http endpoint.

Parameters:endpoint (HttpCtsRetriever) – CTS API Retriever
Variables:endpoint – CTS API Retriever
endpoint

CTS Endpoint of the resolver

Returns:CTS Endpoint
Return type:HttpCtsRetriever
getMetadata(objectId=None, **filters)[source]

Request metadata about a text or a collection

Parameters:
  • objectId (str) – Object Identifier to filter on
  • filters (dict) – Kwargs parameters.
Returns:

Collection

getReffs(textId, level=1, subreference=None)[source]

Retrieve the siblings of a textual node

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • level (int) – Depth for retrieval
  • subreference (str) – CapitainsCtsPassage Reference
Returns:

List of references

Return type:

[str]

getSiblings(textId, subreference)[source]

Retrieve the siblings of a textual node

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • subreference (str) – CapitainsCtsPassage Reference
Returns:

Tuple of references

Return type:

(str, str)

getTextualNode(textId, subreference=None, prevnext=False, metadata=False)[source]

Retrieve a text node from the API

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • subreference (str) – CapitainsCtsPassage Reference
  • prevnext (boolean) – Retrieve graph representing previous and next passage
  • metadata (boolean) – Retrieve metadata about the passage and the text
Returns:

CapitainsCtsPassage

Return type:

CapitainsCtsPassage

Local CapiTainS Guidelines CTS Resolver

class MyCapytain.resolvers.cts.local.CtsCapitainsLocalResolver(resource, name=None, logger=None, dispatcher=None, autoparse=True)[source]

XML Folder Based resolver. CtsTextMetadata and metadata resolver based on local directories

Parameters:
  • resource ([str]) – Resource should be a list of folders retaining data as Capitains Guidelines Repositories
  • name (str) – Key used to differentiate Repository and thus enabling different repo to be used
  • logger (logging) – Logging object
Variables:
  • TEXT_CLASS – CtsTextMetadata Class [not instantiated] to be used to parse Texts. Can be changed to support Cache for example
  • DEFAULT_PAGE – Default Page to show
  • PER_PAGE – Tuple representing the minimal number of texts returned, the default number and the maximum number of texts returned
getMetadata(objectId=None, **filters)[source]

Request metadata about a text or a collection

Parameters:
  • objectId (str) – Object Identifier to filter on
  • filters (dict) – Kwargs parameters.
Returns:

Collection

getReffs(textId, level=1, subreference=None)[source]

Retrieve the siblings of a textual node

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • level (int) – Depth for retrieval
  • subreference (str) – CapitainsCtsPassage CtsReference
Returns:

List of references

Return type:

[str]

getSiblings(textId, subreference: MyCapytain.common.reference._capitains_cts.CtsReference)[source]

Retrieve the siblings of a textual node

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • subreference (str) – CapitainsCtsPassage CtsReference
Returns:

Tuple of references

Return type:

(str, str)

getTextualNode(textId, subreference=None, prevnext=False, metadata=False)[source]

Retrieve a text node from the API

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • subreference (str) – CapitainsCtsPassage CtsReference
  • prevnext (boolean) – Retrieve graph representing previous and next passage
  • metadata (boolean) – Retrieve metadata about the passage and the text
Returns:

CapitainsCtsPassage

Return type:

CapitainsCtsPassage

static pagination(page, limit, length)[source]

Help for pagination :param page: Provided Page :param limit: Number of item to show :param length: Length of the list to paginate :return: (Start Index, End Index, Page Number, Item Count)

parse(resource)[source]

Parse a list of directories and reads it into a collection

Parameters:resource – List of folders
Returns:An inventory resource and a list of CtsTextMetadata metadata-objects
read(identifier, path)[source]

Retrieve and parse a text given an identifier

Parameters:
  • identifier (str) – Identifier of the text
  • path (str) – Path of the text
Returns:

Parsed Text

Return type:

CapitainsCtsText

xmlparse(file)[source]

Parse a XML file :param file: Opened File :return: Tree

Dispatcher

class MyCapytain.resolvers.utils.CollectionDispatcher(collection, default_inventory_name=None)[source]

Collection Dispatcher provides a utility to divide automatically texts and collections into different collections

Parameters:
  • collection – The root collection
  • default_inventory_name – The default name of the default collection
add(func, inventory_name)[source]

Register given function as a filter.

If this function “func” returns True when given an object, said object will be dispatched to Collection(inventory_name)

Parameters:
  • func – Callable
  • inventory_name – Identifier of the collection to dispatch to
dispatch(collection, **kwargs)[source]

Dispatch a collection using internal filters

Parameters:
  • collection – Collection object
  • kwargs – Additional keyword arguments that could be used by internal filters
Returns:

None

Raises:
inventory(inventory_name)[source]

Decorator to register filters for given inventory. For a function “abc”, it has the same effect

Parameters:inventory_name
Returns:
tic = CtsTextInventoryCollection()
latin = CtsTextInventoryMetadata("urn:perseus:latinLit", parent=tic)
latin.set_label("Classical Latin", "eng")
dispatcher = CollectionDispatcher(tic)

@dispatcher.inventory("urn:perseus:latinLit")
def dispatchLatinLit(collection, path=None, **kwargs):
    if collection.id.startswith("urn:cts:latinLit:"):
        return True
    return False
methods

List of methods to dispatch resources.

Each element is a tuple with two elements :
  • First one is the inventory identifier to dispatch to
  • Second one is a function which, if returns true, will activate dispatching to given
Return type:List

Prototypes

class MyCapytain.resolvers.prototypes.Resolver[source]

Resolver provide a native python API which returns python objects.

Initiation of resolvers are dependent on the implementation of the prototype

getMetadata(objectId: str = None, **filters) → MyCapytain.resources.prototypes.metadata.Collection[source]

Request metadata about a text or a collection

Parameters:
  • objectId (str) – Object Identifier to filter on
  • filters (dict) – Kwargs parameters.
Returns:

Collection

getReffs(textId: str, level: int = 1, subreference: Union[str, MyCapytain.common.reference._base.BaseReference] = None, include_descendants: bool = False, additional_parameters: Optional[Dict[str, Any]] = None) → MyCapytain.common.reference._base.BaseReferenceSet[source]

Retrieve the siblings of a textual node

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • level (int) – Depth for retrieval
  • subreference (str) – CapitainsCtsPassage Reference
  • include_descendants
  • additional_parameters
Returns:

List of references

Return type:

[str]

..toDo :: This starts to be a bloated function….

getSiblings(textId: str, subreference: Union[str, MyCapytain.common.reference._base.BaseReference]) → Tuple[MyCapytain.common.reference._base.BaseReference, MyCapytain.common.reference._base.BaseReference][source]

Retrieve the siblings of a textual node

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • subreference (str) – CapitainsCtsPassage Reference
Returns:

Tuple of references

Return type:

(str, str)

getTextualNode(textId: str, subreference: Union[str, MyCapytain.common.reference._base.BaseReference] = None, prevnext: bool = False, metadata: bool = False) → MyCapytain.resources.prototypes.text.TextualNode[source]

Retrieve a text node from the API

Parameters:
  • textId (str) – CtsTextMetadata Identifier
  • subreference (str) – CapitainsCtsPassage Reference
  • prevnext (boolean) – Retrieve graph representing previous and next passage
  • metadata (boolean) – Retrieve metadata about the passage and the text
Returns:

CapitainsCtsPassage

Return type:

CapitainsCtsPassage

Texts and inventories

Text

TEI based texts

Locally read text

class MyCapytain.resources.texts.local.capitains.cts.CapitainsCtsText(urn=None, citation=None, resource=None)[source]

Bases: MyCapytain.resources.texts.local.capitains.cts._SharedMethods, MyCapytain.resources.prototypes.cts.text.PrototypeCtsText

Implementation of CTS tools for local files

Parameters:
  • urn (MyCapytain.common.reference._capitains_cts.URN) – A URN identifier
  • resource (lxml.etree._Element) – A resource
  • citation (Citation) – Highest XmlCtsCitation level
  • autoreffs (bool) – Parse references on load (default : True)
Variables:

resource – lxml

DEFAULT_EXPORT = 'text/plain'
EXPORT_TO = ['python/lxml', 'text/xml', 'python/NestedDict', 'text/plain', 'text/xml:tei']
PLAINTEXT_STRING_JOIN = ' '
asNode() → rdflib.term.Identifier
childIds

Identifiers of children

Returns:Identifiers of children
children

Children TextualNode

citation

Citation system of the object

Return type:Citation
default_exclude = []
depth

Depth of the node in the global hierarchy of the text tree

export(output: str = None, exclude: List[str] = None, **kwargs)

Export the collection item in the Mimetype required.

..note:: If current implementation does not have special mimetypes, reuses default_export method

Parameters:
  • output (str) – Mimetype to export to (Uses MyCapytain.common.constants.Mimetypes)
  • exclude ([str]) – Information to exclude. Specific to implementations
Returns:

Object using a different representation

export_capacities

List Mimetypes that current object can export to

first

First TextualNode

firstId

First child’s id of current TextualNode

getLabel() → MyCapytain.resources.prototypes.metadata.Collection

Retrieve metadata about the text

Return type:Collection
Returns:Retrieve Label informations in a Collection format
getReffs(level: int = 1, subreference: MyCapytain.common.reference._capitains_cts.CtsReference = None) → MyCapytain.common.reference._capitains_cts.CtsReferenceSet

CtsReference available at a given level

Parameters:
  • level – Depth required. If not set, should retrieve first encountered level (1 based)
  • subreference – Subreference (optional)
Returns:

List of levels

getTextualNode(subreference=None, simple=False)

Finds a passage in the current text

Parameters:
  • subreference (Union[list, CtsReference]) – Identifier of the subreference / passages
  • simple (boolean) – If set to true, retrieves nodes up to the given one, cleaning non required siblings.
Return type:

CapitainsCtsPassage, ContextPassage

Returns:

Asked passage

getValidReff(level: int = 1, reference: MyCapytain.common.reference._capitains_cts.CtsReference = None, _debug: bool = False) → MyCapytain.common.reference._capitains_cts.CtsReferenceSet

Retrieve valid passages directly

Parameters:
  • level (int) – Depth required. If not set, should retrieve first encountered level (1 based)
  • reference (CtsReference) – CapitainsCtsPassage Reference
  • _debug (bool) – Check on passages duplicates
Returns:

List of levels

Note

GetValidReff works for now as a loop using CapitainsCtsPassage, subinstances of CtsTextMetadata, to retrieve the valid informations. Maybe something is more powerfull ?

get_creator(lang: str = None) → rdflib.term.Literal

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_metadata(key: str, lang: str = None) → rdflib.term.Literal

Get easily a metadata from the CTS namespace

Parameters:
  • key – CTS property to retrieve
  • lang – Language in which it should be
Returns:

Literal value of the CTS graph property

get_description(lang: str = None) → rdflib.term.Literal

Get the description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_subject(lang=None) → rdflib.term.Literal

Get the subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang: str = None) → rdflib.term.Literal

Get the title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph
id

Identifier of the text

Returns:Identifier of the text
last

Last CapitainsCtsPassage

lastId

Last child’s id of current TextualNode

metadata

Metadata information about the text

Returns:Collection object with metadata about the text
Return type:Metadata
next

Get Next TextualNode

nextId

Next Id

parent

Parent TextualNode

parentId

Parent Id

plaintext_string_join

String used to join xml node’s texts in export

prev

Get Previous TextualNode

prevId

Previous Id (Sibling)

reffs

Get all valid reffs for every part of the CtsText

Return type:[str]
set_creator(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Creator literal value

Parameters:
  • value – Value of the creator node
  • lang – Language in which the value is
set_description(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Description literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
set_metadata_from_collection(text_metadata: MyCapytain.resources.prototypes.cts.inventory.CtsTextMetadata)

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsTextMetadata) – Object representing the current text as a collection
set_subject(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Subject literal value

Parameters:
  • value – Value of the subject node
  • lang – Language in which the value is
set_title(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Title literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
siblingsId

Siblings Id

test()[source]

Parse the object and generate the children

text

String representation of the text

Returns:String representation of the text
textObject

Textual Object with full capacities (Unlike Simple CapitainsCtsPassage)

Return type:CtsTextMetadata, CapitainsCtsPassage
Returns:Textual Object with full capacities (Unlike Simple CapitainsCtsPassage)
tostring(*args, **kwargs)

Transform the CapitainsCtsPassage in XML string

Parameters:
  • args – Ordered arguments for etree.tostring() (except the first one)
  • kwargs – Named arguments
Returns:

urn

URN Identifier of the object

xml

XML Representation of the CapitainsCtsPassage

Return type:lxml.etree._Element
Returns:XML element representing the passage
xpath(*args, **kwargs)

Perform XPath on the passage XML

Parameters:
  • args – Ordered arguments for etree._Element().xpath()
  • kwargs – Named arguments
Returns:

Result list

Return type:

list(etree._Element)

class MyCapytain.resources.texts.local.capitains.cts.CapitainsCtsPassage(reference, urn=None, citation=None, resource=None, text=None)[source]

Bases: MyCapytain.resources.texts.local.capitains.cts._SharedMethods, MyCapytain.resources.prototypes.cts.text.PrototypeCtsPassage

CapitainsCtsPassage class for local texts which rebuilds the tree up to the passage.

For design purposes, some people would prefer the output of GetPassage to be consistent. ContextPassage rebuilds the tree of the text up to the passage, keeping attributes of original nodes

Example : for a text with a citation scheme with following refsDecl : /TEI/text/body/div[@type=’edition’]/div[@n=’$1’]/div[@n=’$2’]/l[@n=’$3’] and a passage 1.1.1-1.2.3, this class will build an XML tree looking like the following

<TEI ...>
    <text ...>
        <body ...>
            <div type='edition' ...>
                <div n='1' ...>

                    <div n='1' ...>
                        <l n='1'>...</l>
                        ...
                    </div>
                    <div n='2' ...>
                        <l n='3'>...</l>
                    </div>
                </div>
            </div>
        </body>
    </text>
</TEI>
Parameters:
  • reference (CtsReference) – CapitainsCtsPassage reference
  • urn (URN) – URN of the source text or of the passage
  • citation (XmlCtsCitation) – XmlCtsCitation scheme of the text
  • resource (etree._Element) – Element representing the passage
  • text (CtsTextMetadata) – CtsTextMetadata containing the passage

Note

.prev, .next, .first and .last won’t run on passage with a range made of two different level, such as 1.1-1.2.3 or 1-a.b. Those will raise InvalidSiblingRequest

DEFAULT_EXPORT = 'text/plain'
EXPORT_TO = ['python/lxml', 'text/xml', 'python/NestedDict', 'text/plain', 'text/xml:tei']
PLAINTEXT_STRING_JOIN = ' '
asNode() → rdflib.term.Identifier
childIds

Children of the passage

Return type:None, CtsReference
Returns:Dictionary of chidren, where key are subreferences
children

Children TextualNode

citation

Citation system of the object

Return type:Citation
default_exclude = []
depth

Depth of the node in the global hierarchy of the text tree

export(output: str = None, exclude: List[str] = None, **kwargs)

Export the collection item in the Mimetype required.

..note:: If current implementation does not have special mimetypes, reuses default_export method

Parameters:
  • output (str) – Mimetype to export to (Uses MyCapytain.common.constants.Mimetypes)
  • exclude ([str]) – Information to exclude. Specific to implementations
Returns:

Object using a different representation

export_capacities

List Mimetypes that current object can export to

first

First TextualNode

firstId

First child’s id of current TextualNode

getLabel() → MyCapytain.resources.prototypes.metadata.Collection

Retrieve metadata about the text

Return type:Collection
Returns:Retrieve Label informations in a Collection format
getReffs(level: int = 1, subreference: MyCapytain.common.reference._capitains_cts.CtsReference = None) → MyCapytain.common.reference._capitains_cts.CtsReferenceSet

CtsReference available at a given level

Parameters:
  • level – Depth required. If not set, should retrieve first encountered level (1 based)
  • subreference – Subreference (optional)
Returns:

List of levels

getTextualNode(subreference=None, *args, **kwargs)[source]

Finds a passage in the current text

Parameters:
  • subreference (Union[list, CtsReference]) – Identifier of the subreference / passages
  • simple (boolean) – If set to true, retrieves nodes up to the given one, cleaning non required siblings.
Return type:

CapitainsCtsPassage, ContextPassage

Returns:

Asked passage

getValidReff(level: int = 1, reference: MyCapytain.common.reference._capitains_cts.CtsReference = None, _debug: bool = False) → MyCapytain.common.reference._capitains_cts.CtsReferenceSet

Retrieve valid passages directly

Parameters:
  • level (int) – Depth required. If not set, should retrieve first encountered level (1 based)
  • reference (CtsReference) – CapitainsCtsPassage Reference
  • _debug (bool) – Check on passages duplicates
Returns:

List of levels

Note

GetValidReff works for now as a loop using CapitainsCtsPassage, subinstances of CtsTextMetadata, to retrieve the valid informations. Maybe something is more powerfull ?

get_creator(lang: str = None) → rdflib.term.Literal

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_metadata(key: str, lang: str = None) → rdflib.term.Literal

Get easily a metadata from the CTS namespace

Parameters:
  • key – CTS property to retrieve
  • lang – Language in which it should be
Returns:

Literal value of the CTS graph property

get_description(lang: str = None) → rdflib.term.Literal

Get the description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_subject(lang=None) → rdflib.term.Literal

Get the subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang: str = None) → rdflib.term.Literal

Get the title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph
id

Identifier of the text

Returns:Identifier of the text
last

Last CapitainsCtsPassage

lastId

Last child’s id of current TextualNode

metadata

Metadata information about the text

Returns:Collection object with metadata about the text
Return type:Metadata
next

Next CapitainsCtsPassage (Interactive CapitainsCtsPassage)

nextId

Next passage

Returns:Next passage at same level
Return type:None, CtsReference
parent

Parent TextualNode

parentId

Parent Id

plaintext_string_join

String used to join xml node’s texts in export

prev

Previous CapitainsCtsPassage (Interactive CapitainsCtsPassage)

prevId

Get the Previous passage reference

Returns:Previous passage reference at the same level
Return type:None, CtsReference
reference

CtsReference of the object

set_creator(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Creator literal value

Parameters:
  • value – Value of the creator node
  • lang – Language in which the value is
set_description(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Description literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
set_metadata_from_collection(text_metadata: MyCapytain.resources.prototypes.cts.inventory.CtsTextMetadata)

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsTextMetadata) – Object representing the current text as a collection
set_subject(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Subject literal value

Parameters:
  • value – Value of the subject node
  • lang – Language in which the value is
set_title(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Title literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
siblingsId

Siblings Identifiers of the passage

Return type:(str, str)
text

String representation of the text

Returns:String representation of the text
textObject

CtsTextMetadata Object. Required for NextPrev

Return type:CapitainsCtsText
tostring(*args, **kwargs)

Transform the CapitainsCtsPassage in XML string

Parameters:
  • args – Ordered arguments for etree.tostring() (except the first one)
  • kwargs – Named arguments
Returns:

urn

URN Identifier of the object

xml

XML Representation of the CapitainsCtsPassage

Return type:lxml.etree._Element
Returns:XML element representing the passage
xpath(*args, **kwargs)

Perform XPath on the passage XML

Parameters:
  • args – Ordered arguments for etree._Element().xpath()
  • kwargs – Named arguments
Returns:

Result list

Return type:

list(etree._Element)

CTS API Texts

Formerly MyCapytain.resources.texts.api (< 2.0.0)

class MyCapytain.resources.texts.remote.cts.CtsText(urn, retriever, citation=None, **kwargs)[source]

Bases: MyCapytain.resources.texts.remote.cts._SharedMethod, MyCapytain.resources.prototypes.cts.text.PrototypeCtsText

API CtsTextMetadata object

Parameters:
  • urn (Union[URN, str, unicode]) – A URN identifier
  • resource (CitableTextServiceRetriever) – An API endpoint
  • citation (XmlCtsCitation) – XmlCtsCitation for children level
  • id (List) – Identifier of the subreference without URN informations
DEFAULT_EXPORT = None
DEFAULT_LANG = 'eng'
EXPORT_TO = []
asNode() → rdflib.term.Identifier
childIds

Identifiers of children

Returns:Identifiers of children
children

Children TextualNode

citation

Citation system of the object

Return type:Citation
default_exclude = []
depth

Depth of the current opbject

Returns:Int representation of the depth based on URN information
Return type:int
export(output='text/plain', exclude=None, **kwargs)[source]

Export the collection item in the Mimetype required.

..note:: If current implementation does not have special mimetypes, reuses default_export method

Parameters:
  • output (str) – Mimetype to export to (Uses Mimetypes)
  • exclude ([str]) – Informations to exclude. Specific to implementations
Returns:

Object using a different representation

export_capacities

List Mimetypes that current object can export to

first

First TextualNode

firstId

Children passage

Return type:str
Returns:First children of the graph. Shortcut to self.graph.children[0]
static firstUrn(resource)

Parse a resource to get the first URN

Parameters:resource (etree._Element) – XML Resource
Returns:Tuple representing previous and next urn
Return type:str
getFirstUrn(reference=None)

Get the first children URN for a given resource

Parameters:reference (CtsReference, str) – CtsReference from which to find child (If None, find first reference)
Returns:Children URN
Return type:URN
getLabel()

Retrieve metadata about the text

Return type:Metadata
Returns:Dictionary with label informations
getPassagePlus(reference=None)

Retrieve a passage and informations around it and store it in the object

Parameters:reference (CtsReference or List of text_type) – Reference of the passage
Return type:CtsPassage
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a Reference
getPrevNextUrn(reference)

Get the previous URN of a reference of the text

Parameters:reference (Union[CtsReference, str]) – CtsReference from which to find siblings
Returns:(Previous CapitainsCtsPassage CtsReference,Next CapitainsCtsPassage CtsReference)
getReffs(level=1, subreference=None)

Reference available at a given level

Parameters:
  • level (Int) – Depth required. If not set, should retrieve first encountered level (1 based)
  • subreference (CtsReference) – Subreference (optional)
Return type:

[text_type]

Returns:

List of levels

getTextualNode(subreference=None)

Retrieve a passage and store it in the object

Parameters:subreference (Union[CtsReference, URN, str, list]) – CtsReference of the passage (Note : if given a list, this should be a list of string that compose the reference)
Return type:CtsPassage
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a CtsReference
getValidReff(level=1, reference=None)

Given a resource, CtsText will compute valid reffs

Parameters:
  • level (Int) – Depth required. If not set, should retrieve first encountered level (1 based)
  • reference (CtsReference) – CapitainsCtsPassage reference
Return type:

list(str)

Returns:

List of levels

get_creator(lang: str = None) → rdflib.term.Literal

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_metadata(key: str, lang: str = None) → rdflib.term.Literal

Get easily a metadata from the CTS namespace

Parameters:
  • key – CTS property to retrieve
  • lang – Language in which it should be
Returns:

Literal value of the CTS graph property

get_description(lang: str = None) → rdflib.term.Literal

Get the description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_subject(lang=None) → rdflib.term.Literal

Get the subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang: str = None) → rdflib.term.Literal

Get the title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph
id

Identifier of the text

Returns:Identifier of the text
last

Last CapitainsCtsPassage

lastId

Children passage

Return type:str
Returns:First children of the graph. Shortcut to self.graph.children[0]
metadata

Metadata information about the text

Returns:Collection object with metadata about the text
Return type:Metadata
next

Get Next TextualNode

nextId

Next Id

parent

Parent TextualNode

parentId

Parent Id

prev

Get Previous TextualNode

prevId

Previous Id (Sibling)

static prevnext(resource)

Parse a resource to get the prev and next urn

Parameters:resource (etree._Element) – XML Resource
Returns:Tuple representing previous and next urn
Return type:(str, str)
reffs

Get all valid reffs for every part of the CtsText

Return type:MyCapytain.resources.texts.tei.XmlCtsCitation
retriever

Retriever object used to query for more data

Return type:CitableTextServiceRetriever
set_creator(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Creator literal value

Parameters:
  • value – Value of the creator node
  • lang – Language in which the value is
set_description(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Description literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
set_metadata_from_collection(text_metadata: MyCapytain.resources.prototypes.cts.inventory.CtsTextMetadata)

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsTextMetadata) – Object representing the current text as a collection
set_subject(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Subject literal value

Parameters:
  • value – Value of the subject node
  • lang – Language in which the value is
set_title(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Title literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
siblingsId

Siblings Id

text

String representation of the text

Returns:String representation of the text
urn

URN Identifier of the object

class MyCapytain.resources.texts.remote.cts.CtsPassage(urn, resource, *args, **kwargs)[source]

Bases: MyCapytain.resources.texts.remote.cts._SharedMethod, MyCapytain.resources.prototypes.cts.text.PrototypeCtsPassage, MyCapytain.resources.texts.base.tei.TeiResource

CapitainsCtsPassage representing

Parameters:
  • urn
  • resource
  • retriever
  • args
  • kwargs
DEFAULT_EXPORT = 'text/plain'
EXPORT_TO = ['python/lxml', 'text/xml', 'python/NestedDict', 'text/plain', 'text/xml:tei']
PLAINTEXT_STRING_JOIN = ' '
asNode() → rdflib.term.Identifier
childIds

Identifiers of children

Returns:Identifiers of children
children

Children TextualNode

citation

Citation system of the object

Return type:Citation
default_exclude = []
depth

Depth of the current opbject

Returns:Int representation of the depth based on URN information
Return type:int
export(output: str = None, exclude: List[str] = None, **kwargs)

Export the collection item in the Mimetype required.

..note:: If current implementation does not have special mimetypes, reuses default_export method

Parameters:
  • output (str) – Mimetype to export to (Uses MyCapytain.common.constants.Mimetypes)
  • exclude ([str]) – Information to exclude. Specific to implementations
Returns:

Object using a different representation

export_capacities

List Mimetypes that current object can export to

first

First TextualNode

firstId

Children passage

Return type:str
Returns:First children of the graph. Shortcut to self.graph.children[0]
static firstUrn(resource)

Parse a resource to get the first URN

Parameters:resource (etree._Element) – XML Resource
Returns:Tuple representing previous and next urn
Return type:str
getFirstUrn(reference=None)

Get the first children URN for a given resource

Parameters:reference (CtsReference, str) – CtsReference from which to find child (If None, find first reference)
Returns:Children URN
Return type:URN
getLabel()

Retrieve metadata about the text

Return type:Metadata
Returns:Dictionary with label informations
getPassagePlus(reference=None)

Retrieve a passage and informations around it and store it in the object

Parameters:reference (CtsReference or List of text_type) – Reference of the passage
Return type:CtsPassage
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a Reference
getPrevNextUrn(reference)

Get the previous URN of a reference of the text

Parameters:reference (Union[CtsReference, str]) – CtsReference from which to find siblings
Returns:(Previous CapitainsCtsPassage CtsReference,Next CapitainsCtsPassage CtsReference)
getReffs(level=1, subreference=None)

Reference available at a given level

Parameters:
  • level (Int) – Depth required. If not set, should retrieve first encountered level (1 based)
  • subreference (CtsReference) – Subreference (optional)
Return type:

[text_type]

Returns:

List of levels

getTextualNode(subreference=None)

Retrieve a passage and store it in the object

Parameters:subreference (Union[CtsReference, URN, str, list]) – CtsReference of the passage (Note : if given a list, this should be a list of string that compose the reference)
Return type:CtsPassage
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a CtsReference
getValidReff(level=1, reference=None)

Given a resource, CtsText will compute valid reffs

Parameters:
  • level (Int) – Depth required. If not set, should retrieve first encountered level (1 based)
  • reference (CtsReference) – CapitainsCtsPassage reference
Return type:

list(str)

Returns:

List of levels

get_creator(lang: str = None) → rdflib.term.Literal

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_metadata(key: str, lang: str = None) → rdflib.term.Literal

Get easily a metadata from the CTS namespace

Parameters:
  • key – CTS property to retrieve
  • lang – Language in which it should be
Returns:

Literal value of the CTS graph property

get_description(lang: str = None) → rdflib.term.Literal

Get the description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_subject(lang=None) → rdflib.term.Literal

Get the subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang: str = None) → rdflib.term.Literal

Get the title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph
id

Identifier of the text

Returns:Identifier of the text
last

Last CapitainsCtsPassage

lastId

Children passage

Return type:str
Returns:First children of the graph. Shortcut to self.graph.children[0]
metadata

Metadata information about the text

Returns:Collection object with metadata about the text
Return type:Metadata
next

Get Next TextualNode

nextId

Shortcut for getting the following passage identifier

Return type:CtsReference
Returns:Following passage reference
parent

Parent TextualNode

parentId

Shortcut for getting the parent passage identifier

Return type:CtsReference
Returns:Following passage reference
plaintext_string_join

String used to join xml node’s texts in export

prev

Get Previous TextualNode

prevId

Previous passage Identifier

Return type:CtsPassage
Returns:Previous passage at same level
static prevnext(resource)

Parse a resource to get the prev and next urn

Parameters:resource (etree._Element) – XML Resource
Returns:Tuple representing previous and next urn
Return type:(str, str)
reference
retriever

Retriever object used to query for more data

Return type:CitableTextServiceRetriever
set_creator(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Creator literal value

Parameters:
  • value – Value of the creator node
  • lang – Language in which the value is
set_description(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Description literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
set_metadata_from_collection(text_metadata: MyCapytain.resources.prototypes.cts.inventory.CtsTextMetadata)

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsTextMetadata) – Object representing the current text as a collection
set_subject(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Subject literal value

Parameters:
  • value – Value of the subject node
  • lang – Language in which the value is
set_title(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Title literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
siblingsId

Shortcut for getting the previous and next passage identifier

Return type:CtsReference
Returns:Following passage reference
text

String representation of the text

Returns:String representation of the text
urn

URN Identifier of the object

xml

XML Representation of the CapitainsCtsPassage

Return type:lxml.etree._Element
Returns:XML element representing the passage

Collections

Metadata

class MyCapytain.resources.prototypes.metadata.Collection(identifier='', *args, **kwargs)[source]

Bases: MyCapytain.common.base.Exportable

Collection represents any resource’s metadata. It has members and parents

Variables:
  • properties – Properties of the collection
  • parents – Parent of the node from the direct parent to the highest ascendant
  • metadata – Metadata
DEFAULT_EXPORT = None
EXPORT_TO = ['application/ld+json', 'application/ld+json:DTS', 'application/rdf+xml']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
TYPE_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
asNode()[source]

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Any descendant (no max level) of the collection’s item

Return type:[Collection]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)[source]

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_label(lang=None)[source]

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
graph

RDFLib Graph space

Return type:Graph
id
members

Children of the collection’s item

Return type:[Collection]
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_label(label, lang)[source]

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
size
type
version
class MyCapytain.resources.prototypes.metadata.ResourceCollection(identifier='', *args, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.metadata.Collection

DEFAULT_EXPORT = None
EXPORT_TO = ['application/ld+json', 'application/ld+json:DTS', 'application/rdf+xml']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
TYPE_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Any descendant (no max level) of the collection’s item

Return type:[Collection]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_creator(lang=None)[source]

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_description(lang=None)[source]

Get the description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_subject(lang=None)[source]

Get the subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang=None)[source]

Get the title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph

RDFLib Graph space

Return type:Graph
id
lang

Languages this text is in

Returns:List of available languages
members

Children of the collection’s item

Return type:[Collection]
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
size
type
version

CTS inventory

class MyCapytain.resources.collections.cts.XmlCtsCitation(name=None, xpath=None, scope=None, refsDecl=None, child=None)[source]

Bases: MyCapytain.common.reference._capitains_cts.Citation

XmlCtsCitation XML implementation for CtsTextInventoryMetadata

DEFAULT_EXPORT = 'text/xml:CTS'
EXPORT_TO = ['text/xml:CTS', 'text/xml:tei']
add_child(child)

Adds a child to the CitationSet

Parameters:child – Child citation to add
Returns:
attribute

Attribute that serves as a reference getter

child

Child of a citation

Type:XmlCtsCitation or None
Example:XmlCtsCitation.name==poem would have a child XmlCtsCitation.name==line
children

Children of a citation

Return type:[BaseCitation]
depth

Depth of the citation scheme

Return type:int
Returns:Depth of the citation scheme
escape = re.compile('(")')
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
export_capacities

List Mimetypes that current object can export to

fill(passage=None, xpath=None)

Fill the xpath with given informations

Parameters:
  • passage (CtsReference or list or None. Can be list of None and not None) – CapitainsCtsPassage reference
  • xpath (Boolean) – If set to True, will return the replaced self.xpath value and not the whole self.refsDecl
Return type:

basestring

Returns:

Xpath to find the passage

citation = XmlCtsCitation(name="line", scope="/TEI/text/body/div/div[@n="?"]",xpath="//l[@n="?"]")
print(citation.fill(["1", None]))
# /TEI/text/body/div/div[@n='1']//l[@n]
print(citation.fill(None))
# /TEI/text/body/div/div[@n]//l[@n]
print(citation.fill(CtsReference("1.1"))
# /TEI/text/body/div/div[@n='1']//l[@n='1']
print(citation.fill("1", xpath=True)
# //l[@n='1']
classmethod ingest(resource, element=None, xpath='ti:citation')[source]

Ingest xml to create a citation

Parameters:
  • resource – XML on which to do xpath
  • element – Element where the citation should be stored
  • xpath – XPath to use to retrieve citation
Returns:

XmlCtsCitation

is_empty() → bool

Check if the citation has not been set

Returns:True if nothing was setup
Return type:bool
is_root() → str
Returns:If the current object is the root of the citation set, True
Return type:bool
is_set() → bool

Check if the citation has been set

Returns:True if set up, False if not
Return type:bool
match(passageId)

Given a passageId matches a citation level

Parameters:passageId – A passage to match
Returns:
name

Type of the citation represented

Return type:str
Example:Book, Chapter, Textpart, Section, Poem…
refsDecl

ResfDecl expression of the citation scheme

Return type:str
Example:/tei:TEI/tei:text/tei:body/tei:div//tei:l[@n=’$1’]
root

Returns the root of the citation set

Returns:Root of the Citation set
Return type:BaseCitationSet
scope

CtsTextInventoryMetadata scope property of a citation (ie. identifier of all element but the last of the citation)

Type:basestring
Example:/tei:TEI/tei:text/tei:body/tei:div
xpath

CtsTextInventoryMetadata xpath property of a citation (ie. identifier of the last element of the citation)

Type:basestring
Example://tei:l[@n=”?”]
class MyCapytain.resources.collections.cts.XmlCtsWorkMetadata(urn=None, parent=None)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.CtsWorkMetadata

Represents a CTS Textgroup in XML

CLASS_COMMENTARY

alias of XmlCtsCommentaryMetadata

CLASS_EDITION

alias of XmlCtsEditionMetadata

CLASS_TRANSLATION

alias of XmlCtsTranslationMetadata

CTS_LINKS = []
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/title')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/title')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/work')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Any descendant (no max level) of the collection’s item

Return type:[Collection]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
get_translation_in(key=None)

Find a translation with given language

Parameters:key (text_type) – Language to find
Return type:[CtsTextMetadata]
Returns:List of availables translations
graph

RDFLib Graph space

Return type:Graph
id
lang

Languages this text is in

Returns:List of available languages
members

Children of the collection’s item

Return type:[Collection]
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
classmethod parse(resource, parent=None, _with_children=False)[source]

Parse a resource

Parameters:
  • resource – Element rerpresenting a work
  • parent (XmlCtsTextgroupMetadata) – Parent of the object
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
texts

Texts

Returns:Dictionary of texts
Return type:defaultdict(PrototypeTexts)
type
update(other)

Merge two XmlCtsWorkMetadata Objects.

  • Original (left Object) keeps his parent.
  • Added document overwrite text if it already exists
Parameters:other (CtsWorkMetadata) – XmlCtsWorkMetadata object
Returns:XmlCtsWorkMetadata Object
Rtype XmlCtsWorkMetadata:
 
urn
version
class MyCapytain.resources.collections.cts.XmlCtsCommentaryMetadata(*args, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.CtsCommentaryMetadata, MyCapytain.resources.collections.cts.XmlCtsTextMetadata

Create a commentary subtyped PrototypeText object

CLASS_CITATION

alias of XmlCtsCitation

CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label'), rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/description')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#resource')
SUBTYPE = 'commentary'
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/commentary')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Descendants of the collection’s item

Warning

CapitainsCtsText has no Descendants

Return type:list
editions()

Get all editions of the texts

Returns:List of editions
Return type:[CtsTextMetadata]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_creator(lang=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_description(lang=None)

Get the DC description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
get_subject(lang=None)

Get the DC subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang=None)

Get the DC Title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph

RDFLib Graph space

Return type:Graph
id
lang

Languages this text is in

Returns:List of available languages
members

Children of the collection’s item

Warning

CapitainsCtsText has no children

Return type:list
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
classmethod parse(resource, parent=None)[source]
classmethod parse_metadata(obj, xml)

Parse a resource to feed the object

Parameters:
  • obj (XmlCtsTextMetadata) – Obj to set metadata of
  • xml (lxml.etree._Element) – An xml representation object
path
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
subtype

Subtype of the object

Returns:string representation of subtype
translations(key=None)

Get translations in given language

Parameters:key – Language ISO Code to filter on
Returns:
type
urn
version
class MyCapytain.resources.collections.cts.XmlCtsTranslationMetadata(*args, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.CtsTranslationMetadata, MyCapytain.resources.collections.cts.XmlCtsTextMetadata

Create a translation subtyped CtsTextMetadata object

CLASS_CITATION

alias of XmlCtsCitation

CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label'), rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/description')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#resource')
SUBTYPE = 'translation'
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/translation')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Descendants of the collection’s item

Warning

CapitainsCtsText has no Descendants

Return type:list
editions()

Get all editions of the texts

Returns:List of editions
Return type:[CtsTextMetadata]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_creator(lang=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_description(lang=None)

Get the DC description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
get_subject(lang=None)

Get the DC subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang=None)

Get the DC Title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph

RDFLib Graph space

Return type:Graph
id
lang

Languages this text is in

Returns:List of available languages
members

Children of the collection’s item

Warning

CapitainsCtsText has no children

Return type:list
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
classmethod parse(resource, parent=None)[source]
classmethod parse_metadata(obj, xml)

Parse a resource to feed the object

Parameters:
  • obj (XmlCtsTextMetadata) – Obj to set metadata of
  • xml (lxml.etree._Element) – An xml representation object
path
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
subtype

Subtype of the object

Returns:string representation of subtype
translations(key=None)

Get translations in given language

Parameters:key – Language ISO Code to filter on
Returns:
type
urn
version
class MyCapytain.resources.collections.cts.XmlCtsEditionMetadata(*args, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.CtsEditionMetadata, MyCapytain.resources.collections.cts.XmlCtsTextMetadata

Create an edition subtyped CtsTextMetadata object

CLASS_CITATION

alias of XmlCtsCitation

CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label'), rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/description')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#resource')
SUBTYPE = 'edition'
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/edition')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Descendants of the collection’s item

Warning

CapitainsCtsText has no Descendants

Return type:list
editions()

Get all editions of the texts

Returns:List of editions
Return type:[CtsTextMetadata]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_creator(lang=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_description(lang=None)

Get the DC description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
get_subject(lang=None)

Get the DC subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang=None)

Get the DC Title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph

RDFLib Graph space

Return type:Graph
id
lang

Languages this text is in

Returns:List of available languages
members

Children of the collection’s item

Warning

CapitainsCtsText has no children

Return type:list
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
classmethod parse(resource, parent=None)[source]
classmethod parse_metadata(obj, xml)

Parse a resource to feed the object

Parameters:
  • obj (XmlCtsTextMetadata) – Obj to set metadata of
  • xml (lxml.etree._Element) – An xml representation object
path
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
subtype

Subtype of the object

Returns:string representation of subtype
translations(key=None)

Get translations in given language

Parameters:key – Language ISO Code to filter on
Returns:
type
urn
version
class MyCapytain.resources.collections.cts.XmlCtsTextgroupMetadata(urn='', parent=None)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.CtsTextgroupMetadata

Represents a CTS Textgroup in XML

CLASS_WORK

alias of XmlCtsWorkMetadata

CTS_LINKS = []
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/groupname')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/groupname')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/textgroup')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Any descendant (no max level) of the collection’s item

Return type:[Collection]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
graph

RDFLib Graph space

Return type:Graph
id
members

Children of the collection’s item

Return type:[Collection]
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
classmethod parse(resource, parent=None)[source]

Parse a textgroup resource

Parameters:
  • resource – Element representing the textgroup
  • parent – Parent of the textgroup
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
type
update(other)

Merge two Textgroup Objects.

  • Original (left Object) keeps his parent.
  • Added document merges with work if it already exists
Parameters:other (CtsTextgroupMetadata) – Textgroup object
Returns:Textgroup Object
Return type:CtsTextgroupMetadata
urn
version
works

Works

Returns:Dictionary of works
Return type:defaultdict(PrototypeWorks)
class MyCapytain.resources.collections.cts.XmlCtsTextInventoryMetadata(name='defaultInventory', parent=None)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.CtsTextInventoryMetadata

Represents a CTS Inventory file

CLASS_TEXTGROUP

alias of XmlCtsTextgroupMetadata

CTS_LINKS = []
CTS_PROPERTIES = []
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/name')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/TextInventory')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Any descendant (no max level) of the collection’s item

Return type:[Collection]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
graph

RDFLib Graph space

Return type:Graph
id
members

Children of the collection’s item

Return type:[Collection]
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
classmethod parse(resource)[source]

Parse a resource

Parameters:resource – Element representing the text inventory
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
textgroups

Textgroups

Returns:Dictionary of textgroups
Return type:defaultdict(CtsTextgroupMetadata)
type
urn
version
class MyCapytain.resources.collections.cts.XmlCtsTextMetadata(*args, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.CtsTextMetadata

Represents a CTS CtsTextMetadata

CLASS_CITATION

alias of XmlCtsCitation

CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label'), rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/description')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#resource')
SUBTYPE = 'unknown'
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/text')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Descendants of the collection’s item

Warning

CapitainsCtsText has no Descendants

Return type:list
editions()

Get all editions of the texts

Returns:List of editions
Return type:[CtsTextMetadata]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_creator(lang=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_description(lang=None)

Get the DC description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
get_subject(lang=None)

Get the DC subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang=None)

Get the DC Title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph

RDFLib Graph space

Return type:Graph
id
lang

Languages this text is in

Returns:List of available languages
members

Children of the collection’s item

Warning

CapitainsCtsText has no children

Return type:list
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
classmethod parse_metadata(obj, xml)[source]

Parse a resource to feed the object

Parameters:
  • obj (XmlCtsTextMetadata) – Obj to set metadata of
  • xml (lxml.etree._Element) – An xml representation object
path
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
subtype

Subtype of the object

Returns:string representation of subtype
translations(key=None)

Get translations in given language

Parameters:key – Language ISO Code to filter on
Returns:
type
urn
version

CTS Inventory Prototypes

class MyCapytain.resources.prototypes.cts.inventory.PrototypeCtsCollection(identifier='')[source]

Bases: MyCapytain.resources.prototypes.metadata.Collection

Resource represents any resource from the inventory

Parameters:identifier (str,URN) – Identifier representing the CtsTextInventoryMetadata
Variables:CTS_MODEL – String Representation of the type of collection
CTS_LINKS = []
CTS_PROPERTIES = []
DC_TITLE_KEY = None
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['python/lxml']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
TYPE_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Any descendant (no max level) of the collection’s item

Return type:[Collection]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_cts_property(prop, lang=None)[source]

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)[source]

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
graph

RDFLib Graph space

Return type:Graph
id
members

Children of the collection’s item

Return type:[Collection]
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)[source]

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)[source]

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
type
urn
version
class MyCapytain.resources.prototypes.cts.inventory.CtsTextInventoryCollection(identifier='default')[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.PrototypeCtsCollection

Initiate a CtsTextInventoryMetadata resource

Parameters:
  • resource (Any) – Resource representing the CtsTextInventoryMetadata
  • name (str) – Identifier of the CtsTextInventoryMetadata
CTS_LINKS = []
CTS_PROPERTIES = []
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/name')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'application/ld+json:DTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/CtsTextInventoryCollection')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Any descendant (no max level) of the collection’s item

Return type:[Collection]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
graph

RDFLib Graph space

Return type:Graph
id
members

Children of the collection’s item

Return type:[Collection]
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
type
urn
version
class MyCapytain.resources.prototypes.cts.inventory.CtsEditionMetadata(urn='', parent=None, lang=None)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.CtsTextMetadata

Represents a CTS XmlCtsEditionMetadata

Parameters:
  • urn (str) – Identifier of the CtsTextMetadata
  • parent (CtsWorkMetadata) – Parent of current item
CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label'), rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/description')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#resource')
SUBTYPE = 'edition'
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/edition')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Descendants of the collection’s item

Warning

CapitainsCtsText has no Descendants

Return type:list
editions()

Get all editions of the texts

Returns:List of editions
Return type:[CtsTextMetadata]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_creator(lang=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_description(lang=None)

Get the DC description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
get_subject(lang=None)

Get the DC subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang=None)

Get the DC Title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph

RDFLib Graph space

Return type:Graph
id
lang

Languages this text is in

Returns:List of available languages
members

Children of the collection’s item

Warning

CapitainsCtsText has no children

Return type:list
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
subtype

Subtype of the object

Returns:string representation of subtype
translations(key=None)

Get translations in given language

Parameters:key – Language ISO Code to filter on
Returns:
type
urn
version
class MyCapytain.resources.prototypes.cts.inventory.CtsWorkMetadata(urn=None, parent=None)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.PrototypeCtsCollection

Represents a CTS CtsWorkMetadata

CTS CtsWorkMetadata can be added to each other which would most likely happen if you take your data from multiple API or Textual repository. This works close to dictionary update in Python. See update

Parameters:
  • urn (URN) – Identifier of the CtsWorkMetadata
  • parent (CtsTextgroupMetadata) – Parent of current object
Variables:

urn – URN Identifier

CTS_LINKS = []
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/title')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/title')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/work')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Any descendant (no max level) of the collection’s item

Return type:[Collection]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
get_translation_in(key=None)[source]

Find a translation with given language

Parameters:key (text_type) – Language to find
Return type:[CtsTextMetadata]
Returns:List of availables translations
graph

RDFLib Graph space

Return type:Graph
id
lang

Languages this text is in

Returns:List of available languages
members

Children of the collection’s item

Return type:[Collection]
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
texts

Texts

Returns:Dictionary of texts
Return type:defaultdict(PrototypeTexts)
type
update(other)[source]

Merge two XmlCtsWorkMetadata Objects.

  • Original (left Object) keeps his parent.
  • Added document overwrite text if it already exists
Parameters:other (CtsWorkMetadata) – XmlCtsWorkMetadata object
Returns:XmlCtsWorkMetadata Object
Rtype XmlCtsWorkMetadata:
 
urn
version
class MyCapytain.resources.prototypes.cts.inventory.CtsCommentaryMetadata(urn='', parent=None, lang=None)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.CtsTextMetadata

Represents a CTS Commentary

Parameters:
  • urn (str) – Identifier of the PrototypeText
  • parent (PrototypeWork) – Parent of current item
  • lang (Lang) – Language of the commentary
CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label'), rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/description')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#resource')
SUBTYPE = 'commentary'
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/commentary')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Descendants of the collection’s item

Warning

CapitainsCtsText has no Descendants

Return type:list
editions()

Get all editions of the texts

Returns:List of editions
Return type:[CtsTextMetadata]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_creator(lang=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_description(lang=None)

Get the DC description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
get_subject(lang=None)

Get the DC subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang=None)

Get the DC Title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph

RDFLib Graph space

Return type:Graph
id
lang

Languages this text is in

Returns:List of available languages
members

Children of the collection’s item

Warning

CapitainsCtsText has no children

Return type:list
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
subtype

Subtype of the object

Returns:string representation of subtype
translations(key=None)

Get translations in given language

Parameters:key – Language ISO Code to filter on
Returns:
type
urn
version
class MyCapytain.resources.prototypes.cts.inventory.CtsTextgroupMetadata(urn='', parent=None)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.PrototypeCtsCollection

Represents a CTS Textgroup

CTS CtsTextgroupMetadata can be added to each other which would most likely happen if you take your data from multiple API or Textual repository. This works close to dictionary update in Python. See update

Parameters:
  • urn (URN) – Identifier of the CtsTextgroupMetadata
  • parent (CtsTextInventoryMetadata) – Parent of the current object
Variables:

urn – URN Identifier

CTS_LINKS = []
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/groupname')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/groupname')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/textgroup')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Any descendant (no max level) of the collection’s item

Return type:[Collection]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
graph

RDFLib Graph space

Return type:Graph
id
members

Children of the collection’s item

Return type:[Collection]
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
type
update(other)[source]

Merge two Textgroup Objects.

  • Original (left Object) keeps his parent.
  • Added document merges with work if it already exists
Parameters:other (CtsTextgroupMetadata) – Textgroup object
Returns:Textgroup Object
Return type:CtsTextgroupMetadata
urn
version
works

Works

Returns:Dictionary of works
Return type:defaultdict(PrototypeWorks)
class MyCapytain.resources.prototypes.cts.inventory.CtsTextInventoryMetadata(name='defaultInventory', parent=None)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.PrototypeCtsCollection

Initiate a CtsTextInventoryMetadata resource

Parameters:
  • resource (Any) – Resource representing the CtsTextInventoryMetadata
  • name (str) – Identifier of the CtsTextInventoryMetadata
CTS_LINKS = []
CTS_PROPERTIES = []
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/name')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#collection')
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/TextInventory')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Any descendant (no max level) of the collection’s item

Return type:[Collection]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
graph

RDFLib Graph space

Return type:Graph
id
members

Children of the collection’s item

Return type:[Collection]
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
textgroups

Textgroups

Returns:Dictionary of textgroups
Return type:defaultdict(CtsTextgroupMetadata)
type
urn
version
class MyCapytain.resources.prototypes.cts.inventory.CtsTextMetadata(urn='', parent=None, lang=None)[source]

Bases: MyCapytain.resources.prototypes.metadata.ResourceCollection, MyCapytain.resources.prototypes.cts.inventory.PrototypeCtsCollection

Represents a CTS CtsTextMetadata

Parameters:
  • urn (URN) – Identifier of the CtsTextMetadata
  • parent ([PrototypeCtsCollection]) – Item parents of the current collection
Variables:

urn – URN Identifier

CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label'), rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/description')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#resource')
SUBTYPE = 'unknown'
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/text')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Descendants of the collection’s item

Warning

CapitainsCtsText has no Descendants

Return type:list
editions()[source]

Get all editions of the texts

Returns:List of editions
Return type:[CtsTextMetadata]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_creator(lang=None)[source]

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_description(lang=None)[source]

Get the DC description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
get_subject(lang=None)[source]

Get the DC subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang=None)[source]

Get the DC Title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph

RDFLib Graph space

Return type:Graph
id
lang

Languages this text is in

Returns:List of available languages
members

Children of the collection’s item

Warning

CapitainsCtsText has no children

Return type:list
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
subtype

Subtype of the object

Returns:string representation of subtype
translations(key=None)[source]

Get translations in given language

Parameters:key – Language ISO Code to filter on
Returns:
type
urn
version
class MyCapytain.resources.prototypes.cts.inventory.CtsTranslationMetadata(urn='', parent=None, lang=None)[source]

Bases: MyCapytain.resources.prototypes.cts.inventory.CtsTextMetadata

Represents a CTS XmlCtsTranslationMetadata

Parameters:
  • urn (str) – Identifier of the CtsTextMetadata
  • parent (CtsWorkMetadata) – Parent of current item
  • lang (Lang) – Language of the translation
CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_PROPERTIES = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label'), rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/description')]
DC_TITLE_KEY = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/label')
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['text/xml:CTS', 'text/xml:CTS_CapiTainS']
MODEL_URI = rdflib.term.URIRef('https://w3id.org/dts/api#resource')
SUBTYPE = 'translation'
TYPE_URI = rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/translation')
asNode()

Node representation of the collection in the graph

Return type:URIRef
children

Dictionary of childrens {Identifier: Collection}

Return type:dict
descendants

Descendants of the collection’s item

Warning

CapitainsCtsText has no Descendants

Return type:list
editions()

Get all editions of the texts

Returns:List of editions
Return type:[CtsTextMetadata]
export(output=None, **kwargs)

Export the collection item in the Mimetype required.

Parameters:output (str) – Mimetype to export to (Uses MyCapytain.common.utils.Mimetypes)
Returns:Object using a different representation
classmethod export_base_dts(graph, obj, nsm)

Export the base DTS information in a simple reusable way

Parameters:
  • graph – Current graph where the information lie
  • obj – Object for which we build info
  • nsm – Namespace manager
Returns:

Dict

export_capacities

List Mimetypes that current object can export to

get_creator(lang=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_property(prop, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to get (Without namespace)
  • lang – Language to get for given value
Returns:

Value or default if lang is set, else whole set of values

Return type:

dict or Literal

get_description(lang=None)

Get the DC description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_label(lang=None)

Return label for given lang or any default

Parameters:lang – Language to request
Returns:Label value
Return type:Literal
get_link(prop)

Get given link in CTS Namespace

Parameters:prop – Property to get (Without namespace)
Returns:whole set of values
Return type:list
get_subject(lang=None)

Get the DC subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang=None)

Get the DC Title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph

RDFLib Graph space

Return type:Graph
id
lang

Languages this text is in

Returns:List of available languages
members

Children of the collection’s item

Warning

CapitainsCtsText has no children

Return type:list
metadata
model
parent

Parent of current object

Return type:Collection
parents

Iterator to find parents of current collection, from closest to furthest

Return type:Generator[Collection]
readable

Readable property should return elements where the element can be queried for getPassage / getReffs

readableDescendants

List of element available which are readable

Return type:[Collection]
set_cts_property(prop, value, lang=None)

Set given property in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
  • lang – Language to set for given value
set_label(label, lang)

Add the label of the collection in given lang

Parameters:
  • label – Label Value
  • lang – Language code
set_link(prop, value)

Set given link in CTS Namespace

Parameters:
  • prop – Property to set (Without namespace)
  • value – Value to set for given property
size
subtype

Subtype of the object

Returns:string representation of subtype
translations(key=None)

Get translations in given language

Parameters:key – Language ISO Code to filter on
Returns:
type
urn
version

Text Prototypes

class MyCapytain.resources.prototypes.text.TextualElement(identifier: str = None, metadata: MyCapytain.common.metadata.Metadata = None)[source]

Bases: MyCapytain.common.base.Exportable

Node representing a text passage.

Parameters:
  • identifier (str) – Identifier of the text
  • metadata (Collection) – Collection Information about the Item
Variables:

default_exclude – Default exclude for exports

DEFAULT_EXPORT = None
EXPORT_TO = []
asNode() → rdflib.term.Identifier[source]
default_exclude = []
export(output: str = None, exclude: List[str] = None, **kwargs)[source]

Export the collection item in the Mimetype required.

..note:: If current implementation does not have special mimetypes, reuses default_export method

Parameters:
  • output (str) – Mimetype to export to (Uses MyCapytain.common.constants.Mimetypes)
  • exclude ([str]) – Information to exclude. Specific to implementations
Returns:

Object using a different representation

export_capacities

List Mimetypes that current object can export to

get_creator(lang: str = None) → rdflib.term.Literal[source]

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_description(lang: str = None) → rdflib.term.Literal[source]

Get the description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_subject(lang=None) → rdflib.term.Literal[source]

Get the subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang: str = None) → rdflib.term.Literal[source]

Get the title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph
id

Identifier of the text

Returns:Identifier of the text
metadata

Metadata information about the text

Returns:Collection object with metadata about the text
Return type:Metadata
set_creator(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)[source]

Set the DC Creator literal value

Parameters:
  • value – Value of the creator node
  • lang – Language in which the value is
set_description(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)[source]

Set the DC Description literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
set_subject(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)[source]

Set the DC Subject literal value

Parameters:
  • value – Value of the subject node
  • lang – Language in which the value is
set_title(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)[source]

Set the DC Title literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
text

String representation of the text

Returns:String representation of the text
class MyCapytain.resources.prototypes.text.TextualGraph(identifier: str = None, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.text.TextualNode

Node representing a text passage.

Parameters:
  • identifier (str) – Identifier of the text
  • metadata (Collection) – Collection Information about the Item
  • citation (Citation) – XmlCtsCitation system of the text
  • children ([str]) – Current node Children’s Identifier
  • parent (str) – Parent of the current node
  • siblings (str) – Previous and next node of the current node
  • depth (int) – Depth of the node in the global hierarchy of the text tree
  • resource – Resource used to navigate through the textual graph
Variables:

default_exclude – Default exclude for exports

DEFAULT_EXPORT = None
EXPORT_TO = []
asNode() → rdflib.term.Identifier
childIds

Children Ids

citation

Citation system of the object

Return type:Citation
default_exclude = []
depth

Depth of the node in the global hierarchy of the text tree

export(output: str = None, exclude: List[str] = None, **kwargs)

Export the collection item in the Mimetype required.

..note:: If current implementation does not have special mimetypes, reuses default_export method

Parameters:
  • output (str) – Mimetype to export to (Uses MyCapytain.common.constants.Mimetypes)
  • exclude ([str]) – Information to exclude. Specific to implementations
Returns:

Object using a different representation

export_capacities

List Mimetypes that current object can export to

firstId

First child Id

getReffs(level: int = 1, subreference: MyCapytain.common.reference._base.BaseReference = None) → MyCapytain.common.reference._base.BaseReferenceSet[source]

CtsReference available at a given level

Parameters:
  • level – Depth required. If not set, should retrieve first encountered level (1 based)
  • subreference – Subreference (optional)
Returns:

List of levels

getTextualNode(subreference: MyCapytain.common.reference._base.BaseReference) → MyCapytain.resources.prototypes.text.TextualGraph[source]

Retrieve a passage and store it in the object

Parameters:subreference – CtsReference of the passage to retrieve
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a CtsReference
get_creator(lang: str = None) → rdflib.term.Literal

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_description(lang: str = None) → rdflib.term.Literal

Get the description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_subject(lang=None) → rdflib.term.Literal

Get the subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang: str = None) → rdflib.term.Literal

Get the title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph
id

Identifier of the text

Returns:Identifier of the text
lastId

Last child id

metadata

Metadata information about the text

Returns:Collection object with metadata about the text
Return type:Metadata
nextId

Next Id

parentId

Parent Id

prevId

Previous Id (Sibling)

set_creator(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Creator literal value

Parameters:
  • value – Value of the creator node
  • lang – Language in which the value is
set_description(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Description literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
set_subject(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Subject literal value

Parameters:
  • value – Value of the subject node
  • lang – Language in which the value is
set_title(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Title literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
siblingsId

Siblings Id

text

String representation of the text

Returns:String representation of the text
class MyCapytain.resources.prototypes.text.TextualNode(identifier: str = None, citation: MyCapytain.common.reference._capitains_cts.Citation = None, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.text.TextualElement, MyCapytain.common.reference._base.NodeId

Node representing a text passage.

Parameters:
  • identifier (str) – Identifier of the text
  • metadata (Collection) – Collection Information about the Item
  • citation (Citation) – XmlCtsCitation system of the text
  • children ([str]) – Current node Children’s Identifier
  • parent (str) – Parent of the current node
  • siblings (str) – Previous and next node of the current node
  • depth (int) – Depth of the node in the global hierarchy of the text tree
Variables:

default_exclude – Default exclude for exports

DEFAULT_EXPORT = None
EXPORT_TO = []
asNode() → rdflib.term.Identifier
childIds

Children Ids

citation

Citation system of the object

Return type:Citation
default_exclude = []
depth

Depth of the node in the global hierarchy of the text tree

export(output: str = None, exclude: List[str] = None, **kwargs)

Export the collection item in the Mimetype required.

..note:: If current implementation does not have special mimetypes, reuses default_export method

Parameters:
  • output (str) – Mimetype to export to (Uses MyCapytain.common.constants.Mimetypes)
  • exclude ([str]) – Information to exclude. Specific to implementations
Returns:

Object using a different representation

export_capacities

List Mimetypes that current object can export to

firstId

First child Id

get_creator(lang: str = None) → rdflib.term.Literal

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_description(lang: str = None) → rdflib.term.Literal

Get the description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_subject(lang=None) → rdflib.term.Literal

Get the subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang: str = None) → rdflib.term.Literal

Get the title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph
id

Identifier of the text

Returns:Identifier of the text
lastId

Last child id

metadata

Metadata information about the text

Returns:Collection object with metadata about the text
Return type:Metadata
nextId

Next Id

parentId

Parent Id

prevId

Previous Id (Sibling)

set_creator(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Creator literal value

Parameters:
  • value – Value of the creator node
  • lang – Language in which the value is
set_description(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Description literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
set_subject(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Subject literal value

Parameters:
  • value – Value of the subject node
  • lang – Language in which the value is
set_title(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Title literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
siblingsId

Siblings Id

text

String representation of the text

Returns:String representation of the text
class MyCapytain.resources.prototypes.text.InteractiveTextualNode(identifier: str = None, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.text.TextualGraph

Node representing a text passage.

Parameters:
  • identifier (str) – Identifier of the text
  • metadata (Collection) – Collection Information about the Item
  • citation (Citation) – XmlCtsCitation system of the text
  • children ([str]) – Current node Children’s Identifier
  • parent (str) – Parent of the current node
  • siblings (str) – Previous and next node of the current node
  • depth (int) – Depth of the node in the global hierarchy of the text tree
  • resource – Resource used to navigate through the textual graph
Variables:

default_exclude – Default exclude for exports

DEFAULT_EXPORT = None
EXPORT_TO = []
asNode() → rdflib.term.Identifier
childIds

Identifiers of children

Returns:Identifiers of children
children

Children TextualNode

citation

Citation system of the object

Return type:Citation
default_exclude = []
depth

Depth of the node in the global hierarchy of the text tree

export(output: str = None, exclude: List[str] = None, **kwargs)

Export the collection item in the Mimetype required.

..note:: If current implementation does not have special mimetypes, reuses default_export method

Parameters:
  • output (str) – Mimetype to export to (Uses MyCapytain.common.constants.Mimetypes)
  • exclude ([str]) – Information to exclude. Specific to implementations
Returns:

Object using a different representation

export_capacities

List Mimetypes that current object can export to

first

First TextualNode

firstId

First child’s id of current TextualNode

getReffs(level: int = 1, subreference: MyCapytain.common.reference._base.BaseReference = None) → MyCapytain.common.reference._base.BaseReferenceSet

CtsReference available at a given level

Parameters:
  • level – Depth required. If not set, should retrieve first encountered level (1 based)
  • subreference – Subreference (optional)
Returns:

List of levels

getTextualNode(subreference: MyCapytain.common.reference._base.BaseReference) → MyCapytain.resources.prototypes.text.TextualGraph

Retrieve a passage and store it in the object

Parameters:subreference – CtsReference of the passage to retrieve
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a CtsReference
get_creator(lang: str = None) → rdflib.term.Literal

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_description(lang: str = None) → rdflib.term.Literal

Get the description of the object

Parameters:lang – Lang to retrieve
Returns:Description string representation
Return type:Literal
get_subject(lang=None) → rdflib.term.Literal

Get the subject of the object

Parameters:lang – Lang to retrieve
Returns:Subject string representation
Return type:Literal
get_title(lang: str = None) → rdflib.term.Literal

Get the title of the object

Parameters:lang – Lang to retrieve
Returns:Title string representation
Return type:Literal
graph
id

Identifier of the text

Returns:Identifier of the text
last

Last CapitainsCtsPassage

lastId

Last child’s id of current TextualNode

metadata

Metadata information about the text

Returns:Collection object with metadata about the text
Return type:Metadata
next

Get Next TextualNode

nextId

Next Id

parent

Parent TextualNode

parentId

Parent Id

prev

Get Previous TextualNode

prevId

Previous Id (Sibling)

set_creator(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Creator literal value

Parameters:
  • value – Value of the creator node
  • lang – Language in which the value is
set_description(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Description literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
set_subject(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Subject literal value

Parameters:
  • value – Value of the subject node
  • lang – Language in which the value is
set_title(value: Union[rdflib.term.Literal, rdflib.term.Identifier, str], lang: str = None)

Set the DC Title literal value

Parameters:
  • value – Value of the title node
  • lang – Language in which the value is
siblingsId

Siblings Id

text

String representation of the text

Returns:String representation of the text