Skip to content

Commit

Permalink
Moved to 1.0.0 (#77)
Browse files Browse the repository at this point in the history
- Fixed #76 : renamed endpoints to retrievers for clarity
  • Loading branch information
PonteIneptique committed Apr 14, 2016
1 parent e5fe59d commit 150861d
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 45 deletions.
4 changes: 2 additions & 2 deletions MyCapytain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"""

__name__ = "MyCapytain"
__version__ = "0.1.3"
__all__ = ["common", "endpoints", "resources"]
__version__ = "1.0.0"
__all__ = ["common", "retrievers", "resources"]
9 changes: 0 additions & 9 deletions MyCapytain/endpoints/__init__.py

This file was deleted.

4 changes: 2 additions & 2 deletions MyCapytain/resources/texts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import MyCapytain.resources.proto.text
import MyCapytain.resources.texts.tei
import MyCapytain.resources.inventory
import MyCapytain.endpoints.proto
import MyCapytain.retrievers.proto
import MyCapytain.common.metadata
import MyCapytain.common.utils
import MyCapytain.common.reference
Expand All @@ -19,7 +19,7 @@ class Text(MyCapytain.resources.proto.text.Text):
:param urn: A URN identifier
:type urn: MyCapytain.common.reference.URN
:param resource: An API endpoint
:type resource: MyCapytain.endpoints.proto.CTS
:type resource: MyCapytain.retrievers.proto.CTS
:param citation: Citation for children level
:type citation: MyCapytain.resources.texts.tei.Citation
:param id: Identifier of the subreference without URN informations
Expand Down
9 changes: 9 additions & 0 deletions MyCapytain/retrievers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
"""
.. module:: MyCapytain.retrievers
:synopsis: Implementation and abstraction of CTS related retrievers
.. moduleauthor:: Thibault Clérice <[email protected]>
"""
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
"""
.. module:: MyCapytain.endpoints.ahab
.. module:: MyCapytain.retrievers.ahab
:synopsis: Ahab endpoint implementation
.. moduleauthor:: Thibault Clérice <[email protected]>
"""
import MyCapytain.endpoints.proto
import MyCapytain.retrievers.proto
import requests


Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# -*- coding: utf-8 -*-
"""
.. module:: MyCapytain.endpoints.cts5
.. module:: MyCapytain.retrievers.cts5
:synopsis: CTS5 endpoint implementation
.. moduleauthor:: Thibault Clérice <[email protected]>
"""
import MyCapytain.endpoints.proto
import MyCapytain.retrievers.proto
import requests


class CTS(MyCapytain.endpoints.proto.CTS):
class CTS(MyCapytain.retrievers.proto.CTS):

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

def __init__(self, endpoint, inventory=None):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""
.. module:: MyCapytain.endpoints.proto
.. module:: MyCapytain.retrievers.proto
:synopsis: Prototypes of APIs endpoint
.. moduleauthor:: Thibault Clérice <[email protected]>
Expand Down
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
:target: https://zenodo.org/badge/latestdoi/3923/Capitains/MyCapytain
.. image:: https://img.shields.io/pypi/dm/MyCapytain.svg
:target: https://pypi.python.org/pypi/MyCapytain
.. image:: https://api.codacy.com/project/badge/grade/8e63e69a94274422865e4f275dbf08ea
:target: https://www.codacy.com/app/leponteineptique/MyCapytain
MyCapytain is a python package which provides a large set of tools to deal with CTS and Capitains Guidelines in Python.

Installation and Requirements
Expand Down
12 changes: 6 additions & 6 deletions doc/MyCapytain.api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,31 @@ Utilities
:undoc-members:
:show-inheritance:

API Endpoints
#############
API Retrievers
##############

Module endpoints contains prototypes and implementation of endpoints calls in MyCapytain
Module endpoints contains prototypes and implementation of retrievers in MyCapytain

Ahab
****

.. automodule:: MyCapytain.endpoints.ahab
.. automodule:: MyCapytain.retrievers.ahab
:members:
:undoc-members:
:show-inheritance:

CTS 5 API
*********

.. automodule:: MyCapytain.endpoints.cts5
.. automodule:: MyCapytain.retrievers.cts5
:members:
:undoc-members:
:show-inheritance:

Prototypes
**********

.. automodule:: MyCapytain.endpoints.proto
.. automodule:: MyCapytain.retrievers.proto
:members:
:undoc-members:
:show-inheritance:
Expand Down
6 changes: 3 additions & 3 deletions doc/MyCapytain.endpoint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Introduction
A first important point for MyCapytains endpoint is that the resources are not parsed into object but should only
provide the request by default.

Getting Passage from an Endpoint
################################
Getting Passage from an endpoint using a Retriever
##################################################

.. code-block:: python
from MyCapytain.endpoints import cts5
from MyCapytain.retrievers import cts5
from MyCapytain.resources.texts.api import Text
# We set the variable up, as if we were in a function
Expand Down
6 changes: 4 additions & 2 deletions doc/MyCapytain.uses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ If you are using MyCapytain and wish to appear here, please feel free to open an
Extensions
##########

Softwares and software extensions
Nautilus
********
`Nautilus <https://github.com/Capitains/Nautilus/>`_ provides a local retriever to build inventory based on a set of folders available locally.

Flask Capitains Nemo
********************

`Flask Capitains Nemo <https://github.com/Capitains/flask-capitains-nemo/>`_ is an extension for Flask to build a browsing interface
using both endpoints and resources modules. You will find example of use in a web based environment.
using both retrievers and resources modules. You will find example of use in a web based environment.

HookTest
********
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
setup(
name='MyCapytain',
version=MyCapytain.__version__,
description='Abstraction of CTS API for Python',
description='Library for CTS APIs and CapiTainS guidelines in Python',
url='http://github.com/Capitains/MyCapytain',
author='Thibault Clerice',
author_email='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion tests/endpoints/test_cts5.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from mock import patch
from MyCapytain.endpoints.cts5 import *
from MyCapytain.retrievers.cts5 import *


class TestEndpointsCTS5(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions tests/endpoints/test_proto.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import unittest

from MyCapytain.endpoints.proto import *
from MyCapytain.retrievers.proto import *


class TestEndpointsProto(unittest.TestCase):

""" Testing prototypes endpoints """
""" Testing prototypes retrievers """

def setUp(self):
self.ahab = Ahab("http://ahab.com")
Expand Down
20 changes: 10 additions & 10 deletions tests/resources/texts/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from MyCapytain.common.utils import xmlparser, NS
from MyCapytain.resources.texts.api import *
from MyCapytain.resources.texts.tei import Citation
from MyCapytain.endpoints.cts5 import CTS
from MyCapytain.retrievers.cts5 import CTS
from MyCapytain.common.reference import Reference, URN
from lxml import etree
import mock
Expand Down Expand Up @@ -62,7 +62,7 @@ def test_init(self):
)
self.assertIsInstance(text.metadata["testing"], MyCapytain.common.metadata.Metadatum)

@mock.patch("MyCapytain.endpoints.cts5.requests.get", create=True)
@mock.patch("MyCapytain.retrievers.cts5.requests.get", create=True)
def test_getvalidreff(self, requests):
text = Text("urn:cts:latinLit:phi1294.phi002.perseus-lat2", self.endpoint, citation=self.citation)
requests.return_value.text = GET_VALID_REFF
Expand Down Expand Up @@ -125,7 +125,7 @@ def test_getvalidreff(self, requests):
# Test the parsing
self.assertEqual(reffs[0], "urn:cts:latinLit:phi1294.phi002.perseus-lat2:1.pr.1")

@mock.patch("MyCapytain.endpoints.cts5.requests.get", create=True)
@mock.patch("MyCapytain.retrievers.cts5.requests.get", create=True)
def test_getpassage(self, requests):
text = Text("urn:cts:latinLit:phi1294.phi002.perseus-lat2", self.endpoint, citation=self.citation)
requests.return_value.text = GET_PASSAGE
Expand Down Expand Up @@ -157,7 +157,7 @@ def test_getpassage(self, requests):
}
)

@mock.patch("MyCapytain.endpoints.cts5.requests.get", create=True)
@mock.patch("MyCapytain.retrievers.cts5.requests.get", create=True)
def test_getpassageplus(self, requests):
text = Text("urn:cts:latinLit:phi1294.phi002.perseus-lat2", self.endpoint)
requests.return_value.text = GET_PASSAGE_PLUS
Expand Down Expand Up @@ -191,15 +191,15 @@ def test_getpassageplus(self, requests):
}
)

@mock.patch("MyCapytain.endpoints.cts5.requests.get", create=True)
@mock.patch("MyCapytain.retrievers.cts5.requests.get", create=True)
def test_get_prev_next_urn(self, requests):
text = Text("urn:cts:latinLit:phi1294.phi002.perseus-lat2", resource=self.endpoint)
requests.return_value.text = NEXT_PREV
_prev, _next = text.getPrevNextUrn("1.1")
self.assertEqual(str(_prev.reference), "1.pr", "Endpoint should be called and URN should be parsed")
self.assertEqual(str(_next.reference), "1.2", "Endpoint should be called and URN should be parsed")

@mock.patch("MyCapytain.endpoints.cts5.requests.get", create=True)
@mock.patch("MyCapytain.retrievers.cts5.requests.get", create=True)
def test_first_urn(self, requests):
text = Text("urn:cts:latinLit:phi1294.phi002.perseus-lat2", resource=self.endpoint)
requests.return_value.text = Get_FIRST
Expand All @@ -216,7 +216,7 @@ def test_first_urn(self, requests):
}
)

@mock.patch("MyCapytain.endpoints.cts5.requests.get", create=True)
@mock.patch("MyCapytain.retrievers.cts5.requests.get", create=True)
def test_first_urn_when_empty(self, requests):
text = Text("urn:cts:latinLit:phi1294.phi002.perseus-lat2", resource=self.endpoint)
requests.return_value.text = Get_FIRST_EMPTY
Expand All @@ -233,7 +233,7 @@ def test_first_urn_when_empty(self, requests):
}
)

@mock.patch("MyCapytain.endpoints.cts5.requests.get", create=True)
@mock.patch("MyCapytain.retrievers.cts5.requests.get", create=True)
def test_init_without_citation(self, requests):
text = Text("urn:cts:latinLit:phi1294.phi002.perseus-lat2", resource=self.endpoint)
requests.return_value.text = GET_PASSAGE
Expand All @@ -249,15 +249,15 @@ def test_init_without_citation(self, requests):
)
self.assertEqual(text.citation.name, "book")

@mock.patch("MyCapytain.endpoints.cts5.requests.get", create=True)
@mock.patch("MyCapytain.retrievers.cts5.requests.get", create=True)
def test_getLabel(self, requests):
text = Text("urn:cts:latinLit:phi1294.phi002.perseus-lat2", resource=self.endpoint)
requests.return_value.text = GET_LABEL

label = text.getLabel()
self.assertEqual(label["title"]["eng"], "Epigrammata")

@mock.patch("MyCapytain.endpoints.cts5.requests.get", create=True)
@mock.patch("MyCapytain.retrievers.cts5.requests.get", create=True)
def test_reffs(self, requests):
text = Text("urn:cts:latinLit:phi1294.phi002.perseus-lat2", citation=self.citation, resource=self.endpoint)
requests.return_value.text = GET_VALID_REFF
Expand Down

0 comments on commit 150861d

Please sign in to comment.