-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98e9d97
commit 9735b79
Showing
6 changed files
with
81 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from MyCapytain.resolvers.prototypes import Resolver | ||
from MyCapytain.resources.texts.api.cts import Text, Passage | ||
from MyCapytain.retrievers.cts5 import CTS | ||
|
||
|
||
class HttpCTSResolver(Resolver): | ||
def __init__(self, endpoint): | ||
if not isinstance(endpoint, CTS): | ||
raise TypeError("Endpoint should be a CTS Endpoint object") | ||
self.__endpoint__ = endpoint | ||
|
||
@property | ||
def endpoint(self): | ||
""" CTS Endpoint of the resolver | ||
:return: CTS Endpoint | ||
:rtype: CTS | ||
""" | ||
return self.__endpoint__ | ||
|
||
def getPassage(self, textId, subreference=None, prevnext=False, metadata=False): | ||
""" Retrieve a text node from the API | ||
:param textId: Text Identifier | ||
:param subreference: Passage Reference | ||
:param prevnext: Retrieve graph representing previous and next passage | ||
:param metadata: Retrieve metadata about the passage and the text | ||
:return: Passage | ||
:rtype: Passage | ||
""" | ||
text = Text( | ||
urn=textId, | ||
retriever=self.endpoint | ||
) | ||
if metadata or prevnext: | ||
return text.getPassagePlus(reference=subreference) | ||
else: | ||
return text.getPassage(reference=subreference) | ||
|
||
def getSiblings(self, textId, subreference): | ||
""" Retrieve the siblings of a textual node | ||
:param textId: Text Identifier | ||
:param subreference: Passage Reference | ||
:return: (str, str) | ||
""" | ||
text = Text( | ||
urn=textId, | ||
retriever=self.endpoint | ||
) | ||
return text.getPrevNextUrn(subreference) | ||
|
||
def getSiblings(self, textId, subreference): | ||
""" Retrieve the siblings of a textual node | ||
:param textId: Text Identifier | ||
:param subreference: Passage Reference | ||
:return: (str, str) | ||
""" | ||
text = Text( | ||
urn=textId, | ||
retriever=self.endpoint | ||
) | ||
return text.getPrevNextUrn(subreference) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
requests>=2.8.1 | ||
lxml==3.6.4 | ||
mock==1.3.0 | ||
future==0.15.2 | ||
lxml>=3.6.4 | ||
mock>=2.0.0 | ||
future>=0.16.0 | ||
six>=1.10.0 | ||
xmlunittest>=0.3.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters