Skip to content

Commit

Permalink
Renaming of objects
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique committed Apr 21, 2017
1 parent 7f94144 commit addd29c
Show file tree
Hide file tree
Showing 45 changed files with 1,886 additions and 1,635 deletions.
4 changes: 2 additions & 2 deletions MyCapytain/common/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __childOrNone__(liste):
class Reference(object):
""" A reference object giving information
:param reference: CapitainsCTSPassage Reference part of a Urn
:param reference: CapitainsCtsPassage Reference part of a Urn
:type reference: basestring
:Example:
Expand Down Expand Up @@ -810,7 +810,7 @@ def __len__(self):
def fill(self, passage=None, xpath=None):
""" Fill the xpath with given informations
:param passage: CapitainsCTSPassage reference
:param passage: CapitainsCtsPassage reference
:type passage: Reference or list or None. Can be list of None and not None
:param xpath: If set to True, will return the replaced self.xpath value and not the whole self.refsDecl
:type xpath: Boolean
Expand Down
2 changes: 1 addition & 1 deletion MyCapytain/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def make_xml_node(graph, name, close=False, attributes=None, text="", complete=F
:param name: Name of the tag
:param close: Produce closing tag (close=False -> "<tag>", close=True -> "</tag>")
:param attributes: Dictionary of attributes
:param text: CapitainsCTSText to put inside the node
:param text: CapitainsCtsText to put inside the node
:param complete: Complete node (node with opening and closing tag)
:param innerXML: XML to append to the node
:return: String representation of the node
Expand Down
22 changes: 11 additions & 11 deletions MyCapytain/resolvers/cts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"""

from MyCapytain.resolvers.prototypes import Resolver
from MyCapytain.resources.texts.remote.cts import CTSText
from MyCapytain.resources.texts.remote.cts import CtsText
from MyCapytain.resources.collections.cts import XmlCtsTextInventoryMetadata
from MyCapytain.retrievers.cts5 import HttpCtsRetriever


class HttpCTSResolver(Resolver):
""" HttpCTSResolver provide a resolver for CTS API http endpoint.
class HttpCtsResolver(Resolver):
""" HttpCtsResolver provide a resolver for CTS API http endpoint.
:param endpoint: CTS API Retriever
:type endpoint: CTS
Expand All @@ -42,16 +42,16 @@ def getTextualNode(self, textId, subreference=None, prevnext=False, metadata=Fal
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCTSPassage Reference
:param subreference: CapitainsCtsPassage Reference
:type subreference: str
:param prevnext: Retrieve graph representing previous and next passage
:type prevnext: boolean
:param metadata: Retrieve metadata about the passage and the text
:type metadata: boolean
:return: CapitainsCTSPassage
:rtype: CapitainsCTSPassage
:return: CapitainsCtsPassage
:rtype: CapitainsCtsPassage
"""
text = CTSText(
text = CtsText(
urn=textId,
retriever=self.endpoint
)
Expand All @@ -65,12 +65,12 @@ def getSiblings(self, textId, subreference):
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCTSPassage Reference
:param subreference: CapitainsCtsPassage Reference
:type subreference: str
:return: Tuple of references
:rtype: (str, str)
"""
text = CTSText(
text = CtsText(
urn=textId,
retriever=self.endpoint
)
Expand All @@ -83,12 +83,12 @@ def getReffs(self, textId, level=1, subreference=None):
:type textId: str
:param level: Depth for retrieval
:type level: int
:param subreference: CapitainsCTSPassage Reference
:param subreference: CapitainsCtsPassage Reference
:type subreference: str
:return: List of references
:rtype: [str]
"""
text = CTSText(
text = CtsText(
urn=textId,
retriever=self.endpoint
)
Expand Down
28 changes: 14 additions & 14 deletions MyCapytain/resolvers/cts/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
from MyCapytain.resources.collections.cts import XmlCtsTextInventoryMetadata, XmlCtsTextgroupMetadata, XmlCtsWorkMetadata, XmlCtsCitation, XmlCtsTextMetadata as InventoryText, \
XmlCtsTranslationMetadata, XmlCtsEditionMetadata
from MyCapytain.resources.prototypes.cts.inventory import CtsTextInventoryCollection
from MyCapytain.resources.texts.local.capitains.cts import CapitainsCTSText
from MyCapytain.resources.texts.local.capitains.cts import CapitainsCtsText


class CTSCapitainsLocalResolver(Resolver):
class CtsCapitainsLocalResolver(Resolver):
""" XML Folder Based resolver. CtsTextMetadata and metadata resolver based on local directories
:param resource: Resource should be a list of folders retaining data as Capitains Guidelines Repositories
Expand All @@ -35,7 +35,7 @@ class CTSCapitainsLocalResolver(Resolver):
"""
TEXT_CLASS = CapitainsCTSText
TEXT_CLASS = CapitainsCtsText
DEFAULT_PAGE = 1
PER_PAGE = (1, 10, 100) # Min, Default, Mainvex,
RAISE_ON_UNDISPATCHED = False
Expand Down Expand Up @@ -122,7 +122,7 @@ def parse(self, resource):
if os.path.isfile(__text__.path):
try:
with io.open(__text__.path) as f:
t = CapitainsCTSText(resource=self.xmlparse(f))
t = CapitainsCtsText(resource=self.xmlparse(f))
cites = list()
for cite in [c for c in t.citation][::-1]:
if len(cites) >= 1:
Expand Down Expand Up @@ -166,7 +166,7 @@ def __getText__(self, urn):
:param urn: URN of a text to retrieve
:type urn: str, URN
:return: Textual resource and metadata
:rtype: (CapitainsCTSText, InventoryText)
:rtype: (CapitainsCtsText, InventoryText)
"""
if not isinstance(urn, URN):
urn = URN(urn)
Expand Down Expand Up @@ -250,11 +250,11 @@ def pagination(page, limit, length):
:return: (Start Index, End Index, Page Number, Item Count)
"""
realpage = page
page = page or CTSCapitainsLocalResolver.DEFAULT_PAGE
limit = limit or CTSCapitainsLocalResolver.PER_PAGE[1]
page = page or CtsCapitainsLocalResolver.DEFAULT_PAGE
limit = limit or CtsCapitainsLocalResolver.PER_PAGE[1]

if limit < CTSCapitainsLocalResolver.PER_PAGE[0] or limit > CTSCapitainsLocalResolver.PER_PAGE[2]:
limit = CTSCapitainsLocalResolver.PER_PAGE[1]
if limit < CtsCapitainsLocalResolver.PER_PAGE[0] or limit > CtsCapitainsLocalResolver.PER_PAGE[2]:
limit = CtsCapitainsLocalResolver.PER_PAGE[1]

page = (page - 1) * limit

Expand Down Expand Up @@ -316,14 +316,14 @@ def getTextualNode(self, textId, subreference=None, prevnext=False, metadata=Fal
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCTSPassage Reference
:param subreference: CapitainsCtsPassage Reference
:type subreference: str
:param prevnext: Retrieve graph representing previous and next passage
:type prevnext: boolean
:param metadata: Retrieve metadata about the passage and the text
:type metadata: boolean
:return: CapitainsCTSPassage
:rtype: CapitainsCTSPassage
:return: CapitainsCtsPassage
:rtype: CapitainsCtsPassage
"""
text, text_metadata = self.__getText__(textId)
if subreference is not None:
Expand All @@ -338,7 +338,7 @@ def getSiblings(self, textId, subreference):
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCTSPassage Reference
:param subreference: CapitainsCtsPassage Reference
:type subreference: str
:return: Tuple of references
:rtype: (str, str)
Expand All @@ -354,7 +354,7 @@ def getReffs(self, textId, level=1, subreference=None):
:type textId: str
:param level: Depth for retrieval
:type level: int
:param subreference: CapitainsCTSPassage Reference
:param subreference: CapitainsCtsPassage Reference
:type subreference: str
:return: List of references
:rtype: [str]
Expand Down
10 changes: 5 additions & 5 deletions MyCapytain/resolvers/prototypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def getTextualNode(self, textId, subreference=None, prevnext=False, metadata=Fal
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCTSPassage Reference
:param subreference: CapitainsCtsPassage Reference
:type subreference: str
:param prevnext: Retrieve graph representing previous and next passage
:type prevnext: boolean
:param metadata: Retrieve metadata about the passage and the text
:type metadata: boolean
:return: CapitainsCTSPassage
:rtype: CapitainsCTSPassage
:return: CapitainsCtsPassage
:rtype: CapitainsCtsPassage
"""
raise NotImplementedError()

Expand All @@ -46,7 +46,7 @@ def getSiblings(self, textId, subreference):
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCTSPassage Reference
:param subreference: CapitainsCtsPassage Reference
:type subreference: str
:return: Tuple of references
:rtype: (str, str)
Expand All @@ -60,7 +60,7 @@ def getReffs(self, textId, level=1, subreference=None):
:type textId: str
:param level: Depth for retrieval
:type level: int
:param subreference: CapitainsCTSPassage Reference
:param subreference: CapitainsCtsPassage Reference
:type subreference: str
:return: List of references
:rtype: [str]
Expand Down
2 changes: 1 addition & 1 deletion MyCapytain/resolvers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ def dispatch(self, collection, **kwargs):
if method(collection, **kwargs) is True:
collection.parent = self.collection.children[inventory]
return
raise UndispatchedTextError("CapitainsCTSText not dispatched %s" % collection.id)
raise UndispatchedTextError("CapitainsCtsText not dispatched %s" % collection.id)
2 changes: 1 addition & 1 deletion MyCapytain/resources/collections/cts.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def xpathDict(xml, xpath, cls, parent, **kwargs):
:param cls: Class identifying children
:type cls: inventory.Resource
:param parent: Parent of object
:type parent: CTSCollection
:type parent: CtsCollection
:rtype: collections.defaultdict.<basestring, inventory.Resource>
:returns: Dictionary of children
"""
Expand Down
32 changes: 16 additions & 16 deletions MyCapytain/resources/prototypes/cts/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@
from rdflib.namespace import DC


class PrototypeCTSCollection(Collection):
class PrototypeCtsCollection(Collection):
""" Resource represents any resource from the inventory
:param identifier: Identifier representing the CtsTextInventoryMetadata
:type identifier: str,URN
:cvar CTSMODEL: String Representation of the type of collection
:cvar CTS_MODEL: String Representation of the type of collection
"""
CTSMODEL = "CTSCollection"
CTS_MODEL = "CtsCollection"
DC_TITLE_KEY = None
CTS_PROPERTIES = []

EXPORT_TO = [Mimetypes.PYTHON.ETREE]
DEFAULT_EXPORT = Mimetypes.PYTHON.ETREE

def __init__(self, identifier=""):
super(PrototypeCTSCollection, self).__init__(identifier)
super(PrototypeCtsCollection, self).__init__(identifier)

if hasattr(type(self), "CTSMODEL"):
self.graph.set((self.asNode(), RDF.type, RDF_Namespaces.CTS.term(self.CTSMODEL)))
self.graph.set((self.asNode(), RDF_Namespaces.CTS.isA, RDF_Namespaces.CTS.term(self.CTSMODEL)))
if hasattr(type(self), "CTS_MODEL"):
self.graph.set((self.asNode(), RDF.type, RDF_Namespaces.CTS.term(self.CTS_MODEL)))
self.graph.set((self.asNode(), RDF_Namespaces.CTS.isA, RDF_Namespaces.CTS.term(self.CTS_MODEL)))

self.__urn__ = ""

Expand Down Expand Up @@ -134,13 +134,13 @@ def __export__(self, output=None, domain=""):
return xmlparser(self.export(output=Mimetypes.XML.CTS))


class CtsTextMetadata(ResourceCollection, PrototypeCTSCollection):
class CtsTextMetadata(ResourceCollection, PrototypeCtsCollection):
""" Represents a CTS CtsTextMetadata
:param urn: Identifier of the CtsTextMetadata
:type urn: str
:param parent: Item parents of the current collection
:type parent: [PrototypeCTSCollection]
:type parent: [PrototypeCtsCollection]
:ivar urn: URN Identifier
:type urn: URN
Expand Down Expand Up @@ -185,7 +185,7 @@ def readable(self):
def members(self):
""" Children of the collection's item
.. warning:: CapitainsCTSText has no children
.. warning:: CapitainsCtsText has no children
:rtype: list
"""
Expand All @@ -195,7 +195,7 @@ def members(self):
def descendants(self):
""" Descendants of the collection's item
.. warning:: CapitainsCTSText has no Descendants
.. warning:: CapitainsCtsText has no Descendants
:rtype: list
"""
Expand All @@ -222,7 +222,7 @@ def editions(self):
]

def __export__(self, output=None, domain="", namespaces=True, lines="\n"):
""" Create a {output} version of the CapitainsCTSText
""" Create a {output} version of the CapitainsCtsText
:param output: Format to be chosen
:type output: basestring
Expand Down Expand Up @@ -330,7 +330,7 @@ class CtsTranslationMetadata(CtsTextMetadata):
SUBTYPE = "translation"


class CtsWorkMetadata(PrototypeCTSCollection):
class CtsWorkMetadata(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 \
Expand Down Expand Up @@ -452,7 +452,7 @@ def __export__(self, output=None, domain="", namespaces=True):
return self.__xml_export_generic__(attrs, namespaces=namespaces)


class CtsTextgroupMetadata(PrototypeCTSCollection):
class CtsTextgroupMetadata(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 \
Expand Down Expand Up @@ -540,7 +540,7 @@ def __export__(self, output=None, domain="", namespaces=True):
return self.__xml_export_generic__(attrs, namespaces=namespaces)


class CtsTextInventoryMetadata(PrototypeCTSCollection):
class CtsTextInventoryMetadata(PrototypeCtsCollection):
""" Initiate a CtsTextInventoryMetadata resource
:param resource: Resource representing the CtsTextInventoryMetadata
Expand Down Expand Up @@ -599,7 +599,7 @@ def __export__(self, output=None, domain="", namespaces=True):
return self.__xml_export_generic__(attrs, namespaces=namespaces)


class CtsTextInventoryCollection(PrototypeCTSCollection):
class CtsTextInventoryCollection(PrototypeCtsCollection):
""" Initiate a CtsTextInventoryMetadata resource
:param resource: Resource representing the CtsTextInventoryMetadata
Expand Down

0 comments on commit addd29c

Please sign in to comment.