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

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 Mimetypes.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.CitableText
class Mimetypes.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

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

List of XPath Namespaces used in guidelines

URN, References and Citations

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
childIds

Children Node

Return type:[str]
depth

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

Return type:int
firstId

First child Node

Return type:str
id

Current object identifier

Return type:str
lastId

Last child Node

Return type:str
nextId

Next Node (Sibling)

Return type:str
parentId

Parent Node

Return type:str
prevId

Previous Node (Sibling)

Return type:str
siblingsId

Siblings Node

Return type:(str, str)
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 # Reference is not counted to not induce count equivalencies with the optional version
>>>     len(b) == 4
static model()[source]

Generate a standard dictionary model for URN inside function

Returns:Dictionary of CTS elements
namespace

CTS Namespace element of the URN

Return type:str
Returns:Namespace part of the URN
reference

Reference element of the URN

Return type:Reference
Returns:Reference part of the URN
textgroup

Textgroup element of the URN

Return type:str
Returns:Textgroup part of the URN
upTo(key)[source]

Returns the urn up to given level using URN Constants

Parameters:

key (int) – Identifier of the wished resource using URN constants

Returns:

String representation of the partial URN requested

Return type:

str

Example:
>>>    a = URN(urn="urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.1") 
>>>    a.upTo(URN.TEXTGROUP) == "urn:cts:latinLit:phi1294"
urn_namespace

General Namespace element of the URN

Return type:str
Returns:Namespace part of the URN
version

Version element of the URN

Return type:str
Returns:Version part of the URN
work

CtsWorkMetadata element of the URN

Return type:str
Returns:CtsWorkMetadata part of the URN
class MyCapytain.common.reference.Reference(reference='')[source]

A reference object giving information

Parameters:

reference (basestring) – CapitainsCtsPassage Reference part of a Urn

Example:
>>>    a = Reference(reference="1.1@Achiles[1]-1.2@Zeus[1]")
>>>    b = Reference(reference="1.1")
>>>    Reference("1.1-2.2.2").highest == ["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 == Reference("1.1") && b != a

Note

While Reference(...).subreference and .list are not available for range, Reference(..).start.subreference and Reference(..).end.subreference as well as .list are available

static convert_subreference(word, counter)[source]

Convert a word and a counter into a standard tuple representation

Parameters:
  • word – Word Element of the subreference
  • counter – Index of the Word
Returns:

Tuple representing the element

Return type:

(str, int)

end

Quick access property for reference end list

Return type:Reference
highest

Return highest reference level

For references such as 1.1-1.2.8, with different level, it can be useful to access to the highest node in the hierarchy. In this case, the highest level would be 1.1. The function would return [“1”, “1”]

Note

By default, this property returns the start level

Return type:Reference
list

Return a list version of the object if it is a single passage

Note

Access to start list and end list should be done through obj.start.list and obj.end.list

Return type:[str]
parent

Parent of the actual URN, for example, 1.1 for 1.1.1

Return type:Reference
start

Quick access property for start list

Return type:Reference
subreference

Return the subreference of a single node reference

Note

Access to start and end subreference should be done through obj.start.subreference and obj.end.subreference

Return type:(str, int)
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
__iter__()[source]

Iteration method

Loop over the citation childs

Example:
>>>    c = XmlCtsCitation(name="line")
>>>    b = XmlCtsCitation(name="poem", child=c)
>>>    a = XmlCtsCitation(name="book", child=b)
>>>    [e for e in a] == [a, b, c]
__len__()[source]

Length method

Return type:int
Returns:Number of nested citations
fill(passage=None, xpath=None)[source]

Fill the xpath with given informations

Parameters:
  • passage (Reference 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(Reference("1.1"))
# /TEI/text/body/div/div[@n='1']//l[@n='1']
print(citation.fill("1", xpath=True)
# //l[@n='1']

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
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

MyCapytain.common.utils.LiteralToDict(value)[source]

Transform an object value into a dict readable value

Parameters:value (Literal or URIRef) – Object of a triple which is not a BNode
Returns:dict or str or list
class MyCapytain.common.utils.OrderedDefaultDict(default_factory=None, *args, **kwargs)[source]

Extension of Default Dict that makes an OrderedDefaultDict

Parameters:default_factory – Default class to initiate
class MyCapytain.common.utils.Subgraph(namespace_manager)[source]

Utility class to generate subgraph around one or more items

:param

graphiter(graph, target, ascendants=0, descendants=1)[source]

Iter on a graph to finds object connected

Parameters:
  • graph (Graph) – Graph to serialize
  • target (Node) – Node to iterate over
  • ascendants – Number of level to iter over upwards (-1 = No Limit)
  • descendants – Number of level to iter over downwards (-1 = No limit)
Returns:

MyCapytain.common.utils.copyNode(node, children=False, parent=False)[source]

Copy an XML Node

Parameters:
  • node – Etree Node
  • children – Copy children nodes is set to True
  • parent – Append copied node to parent if given
Returns:

New Element

MyCapytain.common.utils.expand_namespace(nsmap, string)[source]

If the string starts with a known prefix in nsmap, replace it by full URI

Parameters:
  • nsmap – Dictionary of prefix -> uri of namespace
  • string – String in which to replace the namespace
Returns:

Expanded string with no namespace

MyCapytain.common.utils.make_xml_node(graph, name, close=False, attributes=None, text='', complete=False, innerXML='')[source]

Create an XML Node

Parameters:
  • graph – Graph used to geneates prefixes
  • name – Name of the tag
  • close – Produce closing tag (close=False -> “<tag>”, close=True -> “</tag>”)
  • attributes – Dictionary of attributes
  • text – CapitainsCtsText to put inside the node
  • complete – Complete node (node with opening and closing tag)
  • innerXML – XML to append to the node
Returns:

String representation of the node

Return type:

str

MyCapytain.common.utils.nested_get(dictionary, keys)[source]

Get value in dictionary for dictionary[keys[0]][keys[1]][keys[..n]]

Parameters:
  • dictionary – An input dictionary
  • keys – Keys where to store data
Returns:

MyCapytain.common.utils.nested_ordered_dictionary()[source]

Helper to create a nested ordered default dictionary

Rtype OrderedDefaultDict:
 
Returns:Nested Ordered Default Dictionary instance
MyCapytain.common.utils.nested_set(dictionary, keys, value)[source]

Set value in dictionary for dictionary[keys[0]][keys[1]][keys[..n]]

Parameters:
  • dictionary – An input dictionary
  • keys – Keys where to store data
  • value – Value to set at keys** target
Returns:

None

MyCapytain.common.utils.normalize(string)[source]

Remove double-or-more spaces in a string

Parameters:string (text_type) – A string to change
Return type:text_type
Returns:Clean string
MyCapytain.common.utils.normalizeXpath(xpath)[source]

Normalize XPATH split around slashes

Parameters:xpath ([str]) – List of xpath elements
Returns:List of refined xpath
Return type:[str]
MyCapytain.common.utils.passageLoop(parent, new_tree, xpath1, xpath2=None, preceding_siblings=False, following_siblings=False)[source]

Loop over passages to construct and increment new tree given a parent and XPaths

Parameters:
  • parent – Parent on which to perform xpath
  • new_tree – Parent on which to add nodes
  • xpath1 ([str]) – List of xpath elements
  • xpath2 ([str]) – List of xpath elements
  • preceding_siblings – Append preceding siblings of XPath 1/2 match to the tree
  • following_siblings – Append following siblings of XPath 1/2 match to the tree
Returns:

Newly incremented tree

MyCapytain.common.utils.performXpath(parent, xpath)[source]

Perform an XPath on an element and indicate if we need to loop over it to find something

Parameters:
  • parent – XML Node on which to perform XPath
  • xpath – XPath to run
Returns:

(Result, Need to loop Indicator)

MyCapytain.common.utils.xmliter(node)[source]

Provides a simple XML Iter method which complies with either _Element or _ObjectifiedElement

Parameters:node – XML Node
Returns:Iterator for iterating over children of said node.
MyCapytain.common.utils.xmlparser(xml, objectify=True)[source]

Parse xml

Parameters:xml (Union[text_type, lxml.etree._Element]) – XML element
Return type:lxml.etree._Element
Returns:An element object
Raises:TypeError if element is not in accepted type

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)[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
TEXT_CLASS

alias of CapitainsCtsText

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

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 reades it into a collection

Parameters:resource – List of folders
Returns:An inventory resource and a list of CtsTextMetadata metadata-objects
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=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

Texts and inventories

Text

TEI based texts

class MyCapytain.resources.texts.base.tei.TEIResource(resource, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.text.InteractiveTextualNode

TEI Encoded Resource

Parameters:

resource (Union[str,_Element]) – XML Resource that needs to be parsed into a CapitainsCtsPassage/CtsTextMetadata

Variables:
DEFAULT_EXPORT = 'text/plain'
EXPORT_TO = ['python/lxml', 'text/xml', 'python/NestedDict', 'text/plain', 'text/xml:tei']
asNode()
childIds

Identifiers of children

Returns:Identifiers of children
Return type:[str]
children

Children Passages

Return type:iterator(CapitainsCtsPassage)
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
Return type:Citation
default_exclude = []
depth

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

Return type:int
export(output=None, exclude=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 CapitainsCtsPassage

Return type:Passage
firstId

First child of current CapitainsCtsPassage

Return type:str
Returns:First passage node Information
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)
  • passage (Reference) – Subreference (optional)
Return type:

[text_type]

Returns:

List of levels

getTextualNode(subreference)

Retrieve a passage and store it in the object

Parameters:subreference (str or Node or Reference) – Reference of the passage to retrieve
Return type:TextualNode
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a Reference
get_creator(lang=None)

Get the DC Creator literal value

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

Get the description of the object

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

Get the subject of the object

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

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
Return type:text_type
last

Last CapitainsCtsPassage

Return type:Passage
lastId

Last child of current CapitainsCtsPassage

Return type:str
Returns:Last passage Node representation
metadata

Metadata information about the text

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

Get Next CapitainsCtsPassage

Return type:Passage
nextId

Next Node (Sibling)

Return type:str
parent

Parent CapitainsCtsPassage

Return type:Passage
parentId

Parent Node

Return type:str
prev

Get Previous CapitainsCtsPassage

Return type:Passage
prevId

Previous Node (Sibling)

Return type:str
set_creator(value, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters:lang – Language in which the value is
siblingsId

Siblings Node

Return type:(str, str)
text

String representation of the text

Returns:String representation of the text
Return type:text_type
xml

XML Representation of the CapitainsCtsPassage

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

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.texts.base.tei.TEIResource, MyCapytain.resources.prototypes.text.CitableText

Implementation of CTS tools for local files

Parameters:
  • urn (MyCapytain.common.reference.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']
asNode()
childIds

Identifiers of children

Returns:Identifiers of children
Return type:[str]
children

Children Passages

Return type:iterator(CapitainsCtsPassage)
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
Return type:Citation
default_exclude = []
depth

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

Return type:int
export(output=None, exclude=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 CapitainsCtsPassage

Return type:Passage
firstId

First child of current CapitainsCtsPassage

Return type:str
Returns:First passage node Information
getLabel()

Retrieve metadata about the text

Return type:Collection
Returns:Retrieve Label informations in a Collection format
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 (str) – Subreference (optional)
Return type:

List.basestring

Returns:

List of levels

getTextualNode(subreference=None, simple=False)

Finds a passage in the current text

Parameters:
  • subreference (Union[list, Reference]) – 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=None, reference=None, _debug=False)

Retrieve valid passages directly

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

List of levels

Return type:

list(basestring, str)

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=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_metadata(key, lang=None)
get_description(lang=None)

Get the description of the object

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

Get the subject of the object

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

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
Return type:text_type
last

Last CapitainsCtsPassage

Return type:Passage
lastId

Last child of current CapitainsCtsPassage

Return type:str
Returns:Last passage Node representation
metadata

Metadata information about the text

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

Get Next CapitainsCtsPassage

Return type:Passage
nextId

Next Node (Sibling)

Return type:str
parent

Parent CapitainsCtsPassage

Return type:Passage
parentId

Parent Node

Return type:str
prev

Get Previous CapitainsCtsPassage

Return type:Passage
prevId

Previous Node (Sibling)

Return type:str
reffs

Get all valid reffs for every part of the CitableText

Return type:[str]
set_creator(value, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_metadata_from_collection(text_metadata)

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsEditionMetadata or CtsTranslationMetadata) – Object representing the current text as a collection
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters:lang – Language in which the value is
siblingsId

Siblings Node

Return type:(str, str)
test()[source]

Parse the object and generate the children

text

String representation of the text

Returns:String representation of the text
Return type:text_type
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

Return type:URN
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.texts.base.tei.TEIResource, MyCapytain.resources.prototypes.text.Passage

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 (Reference) – 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']
asNode()
childIds

Children of the passage

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

Children Passages

Return type:iterator(CapitainsCtsPassage)
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
Return type:Citation
default_exclude = []
depth

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

Return type:int
export(output=None, exclude=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 CapitainsCtsPassage

Return type:Passage
firstId

First child of current CapitainsCtsPassage

Return type:str
Returns:First passage node Information
getLabel()

Retrieve metadata about the text

Return type:Collection
Returns:Retrieve Label informations in a Collection format
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 (str) – Subreference (optional)
Return type:

List.basestring

Returns:

List of levels

getTextualNode(subreference=None, *args, **kwargs)[source]
getValidReff(level=None, reference=None, _debug=False)

Retrieve valid passages directly

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

List of levels

Return type:

list(basestring, str)

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=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_metadata(key, lang=None)
get_description(lang=None)

Get the description of the object

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

Get the subject of the object

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

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
Return type:text_type
last

Last CapitainsCtsPassage

Return type:Passage
lastId

Last child of current CapitainsCtsPassage

Return type:str
Returns:Last passage Node representation
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, Reference
parent

Parent CapitainsCtsPassage

Return type:Passage
parentId

Parent Node

Return type:str
prev

Previous CapitainsCtsPassage (Interactive CapitainsCtsPassage)

prevId

Get the Previous passage reference

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

Reference of the object

set_creator(value, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_metadata_from_collection(text_metadata)

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsEditionMetadata or CtsTranslationMetadata) – Object representing the current text as a collection
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters: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
Return type:text_type
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

Return type:URN
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.__SimplePassage__(resource, reference, citation, text, urn=None)[source]

Bases: MyCapytain.resources.texts.local.capitains.cts.__SharedMethods__, MyCapytain.resources.texts.base.tei.TEIResource, MyCapytain.resources.prototypes.text.Passage

CapitainsCtsPassage for simple and quick parsing of texts

Parameters:
  • resource (etree._Element) – Element representing the passage
  • reference (Reference) – CapitainsCtsPassage reference
  • urn (URN) – URN of the source text or of the passage
  • citation (Citation) – XmlCtsCitation scheme of the text
  • text (CapitainsCtsText) – CtsTextMetadata containing the passage
childIds

Children of the passage

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

Children Passages

Return type:iterator(CapitainsCtsPassage)
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
Return type:Citation
depth

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

Return type:int
export(output=None, exclude=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 CapitainsCtsPassage

Return type:Passage
firstId

First child of current CapitainsCtsPassage

Return type:str
Returns:First passage node Information
getLabel()

Retrieve metadata about the text

Return type:Collection
Returns:Retrieve Label informations in a Collection format
getReffs(level=1, subreference=None)[source]

Reference available at a given level

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

List.basestring

Returns:

List of levels

getTextualNode(subreference=None)[source]

Special GetPassage implementation for SimplePassage (Simple is True by default)

Parameters:subreference
Returns:
getValidReff(level=None, reference=None, _debug=False)

Retrieve valid passages directly

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

List of levels

Return type:

list(basestring, str)

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=None)

Get the DC Creator literal value

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

Get the description of the object

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

Get the subject of the object

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

Get the title of the object

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

Identifier of the text

Returns:Identifier of the text
Return type:text_type
last

Last CapitainsCtsPassage

Return type:Passage
lastId

Last child of current CapitainsCtsPassage

Return type:str
Returns:Last passage Node representation
metadata

Metadata information about the text

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

Get Next CapitainsCtsPassage

Return type:Passage
nextId

Next passage

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

Parent CapitainsCtsPassage

Return type:Passage
parentId

Parent Node

Return type:str
prev

Get Previous CapitainsCtsPassage

Return type:Passage
prevId

Get the Previous passage reference

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

URN CapitainsCtsPassage Reference

Returns:Reference
Return type:Reference
set_creator(value, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_metadata_from_collection(text_metadata)

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsEditionMetadata or CtsTranslationMetadata) – Object representing the current text as a collection
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters: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
Return type:text_type
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

Return type:URN
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.text.CitableText

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()
childIds

Identifiers of children

Returns:Identifiers of children
Return type:[str]
children

Children Passages

Return type:iterator(CapitainsCtsPassage)
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
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 CapitainsCtsPassage

Return type:Passage
firstId

Children passage

Return type:str
Returns:First children of the graph. Shortcut to self.graph.children[0]
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 (Reference, str) – Reference 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 (Reference 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[Reference, str]) – Reference from which to find siblings
Returns:(Previous CapitainsCtsPassage Reference,Next CapitainsCtsPassage Reference)
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 (Reference) – 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[Reference, URN, str, list]) – Reference 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 Reference
getValidReff(level=1, reference=None)

Given a resource, CitableText will compute valid reffs

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

list(str)

Returns:

List of levels

get_creator(lang=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_metadata(key, lang=None)
get_description(lang=None)

Get the description of the object

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

Get the subject of the object

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

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
Return type:text_type
last

Last CapitainsCtsPassage

Return type:Passage
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
nextId
parent

Parent CapitainsCtsPassage

Return type:Passage
parentId

Parent Node

Return type:str
prev
prevId
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 CitableText

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

Retriever object used to query for more data

Return type:CitableTextServiceRetriever
set_creator(value, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_metadata_from_collection(text_metadata)

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsEditionMetadata or CtsTranslationMetadata) – Object representing the current text as a collection
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters:lang – Language in which the value is
siblingsId
text

String representation of the text

Returns:String representation of the text
Return type:text_type
urn

URN Identifier of the object

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

Bases: MyCapytain.resources.texts.remote.cts.__SharedMethod__, MyCapytain.resources.prototypes.text.Passage, 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']
asNode()
childIds

Identifiers of children

Returns:Identifiers of children
Return type:[str]
children

Children Passages

Return type:iterator(CapitainsCtsPassage)
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
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=None, exclude=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 CapitainsCtsPassage

Return type:Passage
firstId

Children passage

Return type:str
Returns:First children of the graph. Shortcut to self.graph.children[0]
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 (Reference, str) – Reference 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 (Reference 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[Reference, str]) – Reference from which to find siblings
Returns:(Previous CapitainsCtsPassage Reference,Next CapitainsCtsPassage Reference)
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 (Reference) – 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[Reference, URN, str, list]) – Reference 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 Reference
getValidReff(level=1, reference=None)

Given a resource, CitableText will compute valid reffs

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

list(str)

Returns:

List of levels

get_creator(lang=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_metadata(key, lang=None)
get_description(lang=None)

Get the description of the object

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

Get the subject of the object

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

Get the title of the object

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

Last CapitainsCtsPassage

Return type:Passage
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 CapitainsCtsPassage

Return type:Passage
nextId

Shortcut for getting the following passage identifier

Return type:Reference
Returns:Following passage reference
parent

Parent CapitainsCtsPassage

Return type:Passage
parentId

Shortcut for getting the parent passage identifier

Return type:Reference
Returns:Following passage reference
prev

Get Previous CapitainsCtsPassage

Return type:Passage
prevId

Previous passage Identifier

Return type:CtsPassage
Returns:Previous passage at same level
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, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_metadata_from_collection(text_metadata)

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsEditionMetadata or CtsTranslationMetadata) – Object representing the current text as a collection
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters:lang – Language in which the value is
siblingsId

Shortcut for getting the previous and next passage identifier

Return type:Reference
Returns:Following passage reference
text

String representation of the text

Returns:String representation of the text
Return type:text_type
urn

URN Identifier of the object

Return type:URN
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('http://w3id.org/dts-ontology/collection')
TYPE_URI = rdflib.term.URIRef('http://w3id.org/dts-ontology/collection')
asNode()[source]

Node representation of the collection in the graph

Return type:URIRef
capabilities
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
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('http://w3id.org/dts-ontology/collection')
TYPE_URI = rdflib.term.URIRef('http://w3id.org/dts-ontology/collection')
asNode()

Node representation of the collection in the graph

Return type:URIRef
capabilities
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
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.Citation

XmlCtsCitation XML implementation for CtsTextInventoryMetadata

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

Child of a citation

Type:XmlCtsCitation or None
Example:XmlCtsCitation.name==poem would have a child XmlCtsCitation.name==line
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 (Reference 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(Reference("1.1"))
# /TEI/text/body/div/div[@n='1']//l[@n='1']
print(citation.fill("1", xpath=True)
# //l[@n='1']
static 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

isEmpty()

Check if the citation has not been set

Returns:True if nothing was setup
Return type:bool
name

Type of the citation represented

Type:text_type
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’]
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.XmlCtsCommentaryMetadata(urn='', parent=None, lang=None)[source]

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

Create a commentary subtyped PrototypeText object

CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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]
static parse(resource, parent=None)[source]
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
readable
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(urn='', parent=None, lang=None)[source]

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

Create an edition subtyped CtsTextMetadata object

CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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]
static parse(resource, parent=None)[source]
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
readable
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.XmlCtsTextInventoryMetadata(name='defaultInventory', parent=None)[source]

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

Represents a CTS Inventory file

CTS_LINKS = []
CTS_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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]
static parse(resource)[source]

Parse a resource

Parameters:
  • resource – Element representing the text inventory
  • type – basestring, etree._Element
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(urn='', parent=None, lang=None)[source]

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

Represents a CTS CtsTextMetadata

CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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]
static 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
readable
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

CTS_LINKS = []
CTS_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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]
static 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.XmlCtsTranslationMetadata(urn='', parent=None, lang=None)[source]

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

Create a translation subtyped CtsTextMetadata object

CTS_LINKS = [rdflib.term.URIRef('http://chs.harvard.edu/xmlns/cts/about')]
CTS_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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]
static parse(resource, parent=None)[source]
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
readable
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.XmlCtsWorkMetadata(urn=None, parent=None)[source]

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

Represents a CTS Textgroup in XML

CTS_LINKS = []
CTS_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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]
static parse(resource, parent=None)[source]

Parse a resource

Parameters:
  • resource – Element rerpresenting a work
  • type – basestring, etree._Element
  • 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
MyCapytain.resources.collections.cts.xpathDict(xml, xpath, cls, parent, **kwargs)[source]

Returns a default Dict given certain information

Parameters:
  • xml (etree) – An xml tree
  • xpath (str) – XPath to find children
  • cls (inventory.Resource) – Class identifying children
  • parent (CtsCollection) – Parent of object
Return type:

collections.defaultdict.<basestring, inventory.Resource>

Returns:

Dictionary of children

CTS Inventory Prototypes

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_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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
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.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_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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
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.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_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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.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_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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
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.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_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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.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_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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
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_MODEL = 'CtsCollection'
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('http://w3id.org/dts-ontology/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
capabilities
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
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.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_MODEL = 'CtsCollection'
CTS_PROPERTIES = []
DC_TITLE_KEY = None
DEFAULT_EXPORT = 'python/lxml'
EXPORT_TO = ['python/lxml']
MODEL_URI = rdflib.term.URIRef('http://w3id.org/dts-ontology/collection')
TYPE_URI = rdflib.term.URIRef('http://w3id.org/dts-ontology/collection')
asNode()

Node representation of the collection in the graph

Return type:URIRef
capabilities
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
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

Text Prototypes

class MyCapytain.resources.prototypes.text.CitableText(citation=None, metadata=None, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.text.CtsNode

A CTS CitableText

DEFAULT_EXPORT = None
EXPORT_TO = []
asNode()
childIds

Identifiers of children

Returns:Identifiers of children
Return type:[str]
children

Children Passages

Return type:iterator(CapitainsCtsPassage)
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
Return type:Citation
default_exclude = []
depth

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

Return type:int
export(output=None, exclude=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 CapitainsCtsPassage

Return type:Passage
firstId

First child of current CapitainsCtsPassage

Return type:str
Returns:First passage node Information
getLabel()

Retrieve metadata about the text

Return type:Collection
Returns:Retrieve Label informations in a Collection format
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)
  • passage (Reference) – Subreference (optional)
Return type:

[text_type]

Returns:

List of levels

getTextualNode(subreference)

Retrieve a passage and store it in the object

Parameters:subreference (str or Node or Reference) – Reference of the passage to retrieve
Return type:TextualNode
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a Reference
getValidReff(level=1, reference=None)

Given a resource, CitableText will compute valid reffs

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

List.text_type

Returns:

List of levels

get_creator(lang=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_metadata(key, lang=None)
get_description(lang=None)

Get the description of the object

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

Get the subject of the object

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

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
Return type:text_type
last

Last CapitainsCtsPassage

Return type:Passage
lastId

Last child of current CapitainsCtsPassage

Return type:str
Returns:Last passage Node representation
metadata

Metadata information about the text

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

Get Next CapitainsCtsPassage

Return type:Passage
nextId

Next Node (Sibling)

Return type:str
parent

Parent CapitainsCtsPassage

Return type:Passage
parentId

Parent Node

Return type:str
prev

Get Previous CapitainsCtsPassage

Return type:Passage
prevId

Previous Node (Sibling)

Return type:str
reffs

Get all valid reffs for every part of the CitableText

Return type:[str]
set_creator(value, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_metadata_from_collection(text_metadata)

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsEditionMetadata or CtsTranslationMetadata) – Object representing the current text as a collection
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters:lang – Language in which the value is
siblingsId

Siblings Node

Return type:(str, str)
text

String representation of the text

Returns:String representation of the text
Return type:text_type
urn

URN Identifier of the object

Return type:URN
class MyCapytain.resources.prototypes.text.CtsNode(urn=None, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.text.InteractiveTextualNode

Initiate a Resource object

Parameters:
  • urn (URN) – A URN identifier
  • 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()
childIds

Identifiers of children

Returns:Identifiers of children
Return type:[str]
children

Children Passages

Return type:iterator(CapitainsCtsPassage)
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
Return type:Citation
default_exclude = []
depth

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

Return type:int
export(output=None, exclude=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 CapitainsCtsPassage

Return type:Passage
firstId

First child of current CapitainsCtsPassage

Return type:str
Returns:First passage node Information
getLabel()[source]

Retrieve metadata about the text

Return type:Collection
Returns:Retrieve Label informations in a Collection format
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)
  • passage (Reference) – Subreference (optional)
Return type:

[text_type]

Returns:

List of levels

getTextualNode(subreference)

Retrieve a passage and store it in the object

Parameters:subreference (str or Node or Reference) – Reference of the passage to retrieve
Return type:TextualNode
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a Reference
getValidReff(level=1, reference=None)[source]

Given a resource, CitableText will compute valid reffs

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

List.text_type

Returns:

List of levels

get_creator(lang=None)

Get the DC Creator literal value

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

Get the description of the object

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

Get the subject of the object

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

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
Return type:text_type
last

Last CapitainsCtsPassage

Return type:Passage
lastId

Last child of current CapitainsCtsPassage

Return type:str
Returns:Last passage Node representation
metadata

Metadata information about the text

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

Get Next CapitainsCtsPassage

Return type:Passage
nextId

Next Node (Sibling)

Return type:str
parent

Parent CapitainsCtsPassage

Return type:Passage
parentId

Parent Node

Return type:str
prev

Get Previous CapitainsCtsPassage

Return type:Passage
prevId

Previous Node (Sibling)

Return type:str
set_creator(value, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_metadata_from_collection(text_metadata)[source]

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsEditionMetadata or CtsTranslationMetadata) – Object representing the current text as a collection
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters:lang – Language in which the value is
siblingsId

Siblings Node

Return type:(str, str)
text

String representation of the text

Returns:String representation of the text
Return type:text_type
urn

URN Identifier of the object

Return type:URN
class MyCapytain.resources.prototypes.text.InteractiveTextualNode(identifier=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()
childIds

Identifiers of children

Returns:Identifiers of children
Return type:[str]
children

Children Passages

Return type:iterator(CapitainsCtsPassage)
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
Return type:Citation
default_exclude = []
depth

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

Return type:int
export(output=None, exclude=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 CapitainsCtsPassage

Return type:Passage
firstId

First child of current CapitainsCtsPassage

Return type:str
Returns:First passage node Information
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)
  • passage (Reference) – Subreference (optional)
Return type:

[text_type]

Returns:

List of levels

getTextualNode(subreference)

Retrieve a passage and store it in the object

Parameters:subreference (str or Node or Reference) – Reference of the passage to retrieve
Return type:TextualNode
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a Reference
get_creator(lang=None)

Get the DC Creator literal value

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

Get the description of the object

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

Get the subject of the object

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

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
Return type:text_type
last

Last CapitainsCtsPassage

Return type:Passage
lastId

Last child of current CapitainsCtsPassage

Return type:str
Returns:Last passage Node representation
metadata

Metadata information about the text

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

Get Next CapitainsCtsPassage

Return type:Passage
nextId

Next Node (Sibling)

Return type:str
parent

Parent CapitainsCtsPassage

Return type:Passage
parentId

Parent Node

Return type:str
prev

Get Previous CapitainsCtsPassage

Return type:Passage
prevId

Previous Node (Sibling)

Return type:str
set_creator(value, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters:lang – Language in which the value is
siblingsId

Siblings Node

Return type:(str, str)
text

String representation of the text

Returns:String representation of the text
Return type:text_type
class MyCapytain.resources.prototypes.text.Passage(**kwargs)[source]

Bases: MyCapytain.resources.prototypes.text.CtsNode

CapitainsCtsPassage objects possess metadata informations

Parameters:
  • urn (URN) – A URN identifier
  • 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()
childIds

Identifiers of children

Returns:Identifiers of children
Return type:[str]
children

Children Passages

Return type:iterator(CapitainsCtsPassage)
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
Return type:Citation
default_exclude = []
depth

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

Return type:int
export(output=None, exclude=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 CapitainsCtsPassage

Return type:Passage
firstId

First child of current CapitainsCtsPassage

Return type:str
Returns:First passage node Information
getLabel()

Retrieve metadata about the text

Return type:Collection
Returns:Retrieve Label informations in a Collection format
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)
  • passage (Reference) – Subreference (optional)
Return type:

[text_type]

Returns:

List of levels

getTextualNode(subreference)

Retrieve a passage and store it in the object

Parameters:subreference (str or Node or Reference) – Reference of the passage to retrieve
Return type:TextualNode
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a Reference
getValidReff(level=1, reference=None)

Given a resource, CitableText will compute valid reffs

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

List.text_type

Returns:

List of levels

get_creator(lang=None)

Get the DC Creator literal value

Parameters:lang – Language to retrieve
Returns:Creator string representation
Return type:Literal
get_cts_metadata(key, lang=None)
get_description(lang=None)

Get the description of the object

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

Get the subject of the object

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

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
Return type:text_type
last

Last CapitainsCtsPassage

Return type:Passage
lastId

Last child of current CapitainsCtsPassage

Return type:str
Returns:Last passage Node representation
metadata

Metadata information about the text

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

Get Next CapitainsCtsPassage

Return type:Passage
nextId

Next Node (Sibling)

Return type:str
parent

Parent CapitainsCtsPassage

Return type:Passage
parentId

Parent Node

Return type:str
prev

Get Previous CapitainsCtsPassage

Return type:Passage
prevId

Previous Node (Sibling)

Return type:str
reference
set_creator(value, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_metadata_from_collection(text_metadata)

Set the object metadata using its collections recursively

Parameters:text_metadata (CtsEditionMetadata or CtsTranslationMetadata) – Object representing the current text as a collection
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters:lang – Language in which the value is
siblingsId

Siblings Node

Return type:(str, str)
text

String representation of the text

Returns:String representation of the text
Return type:text_type
urn

URN Identifier of the object

Return type:URN
class MyCapytain.resources.prototypes.text.TextualElement(identifier=None, 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()[source]
default_exclude = []
export(output=None, 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 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=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_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
id

Identifier of the text

Returns:Identifier of the text
Return type:text_type
metadata

Metadata information about the text

Returns:Collection object with metadata about the text
Return type:Metadata
set_creator(value, lang)[source]

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)[source]

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_subject(value, lang=None)[source]

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)[source]

Set the DC Title literal value

Parameters:lang – Language in which the value is
text

String representation of the text

Returns:String representation of the text
Return type:text_type
class MyCapytain.resources.prototypes.text.TextualGraph(identifier=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()
childIds

Children Node

Return type:[str]
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
Return type:Citation
default_exclude = []
depth

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

Return type:int
export(output=None, exclude=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 Node

Return type:str
getReffs(level=1, subreference=None)[source]

Reference available at a given level

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

[text_type]

Returns:

List of levels

getTextualNode(subreference)[source]

Retrieve a passage and store it in the object

Parameters:subreference (str or Node or Reference) – Reference of the passage to retrieve
Return type:TextualNode
Returns:Object representing the passage
Raises:TypeError when reference is not a list or a Reference
get_creator(lang=None)

Get the DC Creator literal value

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

Get the description of the object

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

Get the subject of the object

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

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
Return type:text_type
lastId

Last child Node

Return type:str
metadata

Metadata information about the text

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

Next Node (Sibling)

Return type:str
parentId

Parent Node

Return type:str
prevId

Previous Node (Sibling)

Return type:str
set_creator(value, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters:lang – Language in which the value is
siblingsId

Siblings Node

Return type:(str, str)
text

String representation of the text

Returns:String representation of the text
Return type:text_type
class MyCapytain.resources.prototypes.text.TextualNode(identifier=None, citation=None, **kwargs)[source]

Bases: MyCapytain.resources.prototypes.text.TextualElement, MyCapytain.common.reference.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()
childIds

Children Node

Return type:[str]
citation

XmlCtsCitation Object of the CtsTextMetadata

Returns:XmlCtsCitation Object of the CtsTextMetadata
Return type:Citation
default_exclude = []
depth

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

Return type:int
export(output=None, exclude=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 Node

Return type:str
get_creator(lang=None)

Get the DC Creator literal value

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

Get the description of the object

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

Get the subject of the object

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

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
Return type:text_type
lastId

Last child Node

Return type:str
metadata

Metadata information about the text

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

Next Node (Sibling)

Return type:str
parentId

Parent Node

Return type:str
prevId

Previous Node (Sibling)

Return type:str
set_creator(value, lang)

Set the DC Creator literal value

Parameters:lang – Language in which the value is
set_description(value, lang=None)

Set the DC Description literal value

Parameters:lang – Language in which the value is
set_subject(value, lang=None)

Set the DC Subject literal value

Parameters:lang – Language in which the value is
set_title(value, lang=None)

Set the DC Title literal value

Parameters:lang – Language in which the value is
siblingsId

Siblings Node

Return type:(str, str)
text

String representation of the text

Returns:String representation of the text
Return type:text_type