From 037c17c69e1e8e0a2d7f1b5a41b5cafe4a12f82a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 12:18:57 +0200 Subject: [PATCH 01/12] (PR 3.0.0) Comment 6 of @sonofmun review : DtsCitationSet docstring completed --- MyCapytain/common/reference/_dts_1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MyCapytain/common/reference/_dts_1.py b/MyCapytain/common/reference/_dts_1.py index 77214864..60743134 100644 --- a/MyCapytain/common/reference/_dts_1.py +++ b/MyCapytain/common/reference/_dts_1.py @@ -100,7 +100,8 @@ def match(self, passageId): class DtsCitationSet(BaseCitationSet): - """ Set of citation that are supposed + """ Set of citations following the DTS model (Unlike CTS, one citation + can have two or more children) """ From f6ebffe25c0c5aa41a497cc3a51bc9101864c38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 12:21:42 +0200 Subject: [PATCH 02/12] (PR 3.0.0) Comment 7 of @sonofmun review : Example on JSONLdCollection --- MyCapytain/errors.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MyCapytain/errors.py b/MyCapytain/errors.py index 7c6fd551..2d6852b6 100644 --- a/MyCapytain/errors.py +++ b/MyCapytain/errors.py @@ -15,7 +15,10 @@ class MyCapytainException(BaseException): class JsonLdCollectionMissing(MyCapytainException): - """ Error thrown when a JSON LD has now first ressource + """ Error thrown when a JSON LD has now first resource + + Raised when a json supposed to contain collection is parsed + but nothing is found """ From 2fdae24bbc2d544bcca31f517e2f5c59ffab81bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 12:23:09 +0200 Subject: [PATCH 03/12] (PR 3.0.0) Comment 8 of @sonofmun review : Better description of EmptyReference --- MyCapytain/errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MyCapytain/errors.py b/MyCapytain/errors.py index 2d6852b6..7eedc8f5 100644 --- a/MyCapytain/errors.py +++ b/MyCapytain/errors.py @@ -71,7 +71,7 @@ class UnknownCollection(KeyError, MyCapytainException): class EmptyReference(SyntaxWarning, MyCapytainException): - """ Error generated when a CtsReference is wrong + """ Error generated when a CtsReference does not exist or is invalid """ From 713e0db92fcb5cc180859fae3c97a811b1d5f2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 12:25:59 +0200 Subject: [PATCH 04/12] (PR 3.0.0) Comment 9/10 of @sonofmun review : Used _parse_wrapper in resolvers.cts.local --- MyCapytain/resolvers/cts/local.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MyCapytain/resolvers/cts/local.py b/MyCapytain/resolvers/cts/local.py index 9a5296d8..0b224288 100644 --- a/MyCapytain/resolvers/cts/local.py +++ b/MyCapytain/resolvers/cts/local.py @@ -286,14 +286,14 @@ def parse(self, resource): for folder in resource: cts_files = glob("{base_folder}/data/*/__cts__.xml".format(base_folder=folder)) for cts_file in cts_files: - textgroup, cts_file = self._parse_textgroup(cts_file) + textgroup, cts_file = self._parse_textgroup_wrapper(cts_file) textgroups.append((textgroup, cts_file)) for textgroup, cts_textgroup_file in textgroups: cts_work_files = glob("{parent}/*/__cts__.xml".format(parent=os.path.dirname(cts_textgroup_file))) for cts_work_file in cts_work_files: - _, parsed_texts, directory = self._parse_work(cts_work_file, textgroup) + _, parsed_texts, directory = self._parse_work_wrapper(cts_work_file, textgroup) texts.extend([(text, directory) for text in parsed_texts]) for text, directory in texts: From 45bc00db4d08eebc46100be63eea335fa3c476b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 14:00:29 +0200 Subject: [PATCH 05/12] (PR 3.0.0) Comment 12 of @sonofmun review : Clean up of _cls_dict in some docstrings --- MyCapytain/resources/collections/cts.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/MyCapytain/resources/collections/cts.py b/MyCapytain/resources/collections/cts.py index 67bcc95b..d4092182 100644 --- a/MyCapytain/resources/collections/cts.py +++ b/MyCapytain/resources/collections/cts.py @@ -257,10 +257,8 @@ def parse(cls, resource, parent=None, _with_children=False): """ Parse a resource :param resource: Element rerpresenting a work - :param type: basestring, etree._Element :param parent: Parent of the object :type parent: XmlCtsTextgroupMetadata - :param _cls_dict: Dictionary of classes to generate subclasses """ xml = xmlparser(resource) o = cls(urn=xml.get("urn"), parent=parent) @@ -307,7 +305,6 @@ def parse(cls, resource, parent=None): :param resource: Element representing the textgroup :param parent: Parent of the textgroup - :param _cls_dict: Dictionary of classes to generate subclasses """ xml = xmlparser(resource) o = cls(urn=xml.get("urn"), parent=parent) @@ -334,7 +331,6 @@ def parse(cls, resource): """ Parse a resource :param resource: Element representing the text inventory - :param _cls_dict: Dictionary of classes to generate subclasses """ xml = xmlparser(resource) o = cls(name=xml.xpath("//ti:TextInventory", namespaces=XPATH_NAMESPACES)[0].get("tiid") or "") From b4a5c0d75692c1c818c9478e8f159e491ac4dcbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 14:01:50 +0200 Subject: [PATCH 06/12] (PR 3.0.0) Comment 13 of @sonofmun review : Fix docstring for type in prototypes.cts.text.set_metadata... --- MyCapytain/resources/prototypes/cts/text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MyCapytain/resources/prototypes/cts/text.py b/MyCapytain/resources/prototypes/cts/text.py index 7eefedc2..0584a19f 100644 --- a/MyCapytain/resources/prototypes/cts/text.py +++ b/MyCapytain/resources/prototypes/cts/text.py @@ -95,7 +95,7 @@ def set_metadata_from_collection(self, text_metadata: CtsTextMetadata): """ Set the object metadata using its collections recursively :param text_metadata: Object representing the current text as a collection - :type text_metadata: CtsEditionMetadata or CtsTranslationMetadata + :type text_metadata: CtsTextMetadata """ edition, work, textgroup = tuple(([text_metadata] + text_metadata.parents)[:3]) From 5c54ac01b48ae282c7fe503d0154cb50603d30cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 14:04:54 +0200 Subject: [PATCH 07/12] (PR 3.0.0) Comment 14 of @sonofmun review : Fix docstring for retrievers and resolvers --- MyCapytain/resolvers/dts/api_v1.py | 4 +++- MyCapytain/retrievers/dts/__init__.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/MyCapytain/resolvers/dts/api_v1.py b/MyCapytain/resolvers/dts/api_v1.py index e405863a..1defc8a5 100644 --- a/MyCapytain/resolvers/dts/api_v1.py +++ b/MyCapytain/resolvers/dts/api_v1.py @@ -70,6 +70,7 @@ def endpoint(self) -> HttpDtsRetriever: return self._endpoint def getMetadata(self, objectId: str=None, **filters) -> HttpResolverDtsCollection: + """ Retrieves metadata calling the Collections Endpoint """ req = self.endpoint.get_collection(objectId) req.raise_for_status() @@ -87,6 +88,7 @@ def getReffs( include_descendants: bool=False, additional_parameters: Optional[Dict[str, Any]]=None ) -> DtsReferenceSet: + """ Retrieve references by calling the Navigation API """ if not additional_parameters: additional_parameters = {} @@ -151,7 +153,7 @@ def getTextualNode( prevnext: bool=False, metadata: bool=False ) -> DtsResolverDocument: - """ Retrieve a text node from the API + """ Retrieve a text node from the API via the Document Endpoint :param textId: CtsTextMetadata Identifier :type textId: str diff --git a/MyCapytain/retrievers/dts/__init__.py b/MyCapytain/retrievers/dts/__init__.py index f3de2995..cf833bfb 100644 --- a/MyCapytain/retrievers/dts/__init__.py +++ b/MyCapytain/retrievers/dts/__init__.py @@ -158,7 +158,7 @@ def get_navigation( def get_document( self, collection_id, ref=None, mimetype="application/tei+xml, application/xml"): - """ Make a navigation request on the DTS API + """ Make a document request on the DTS API :param collection_id: Id of the collection :param ref: If ref is a tuple, it is treated as a range. String or int are treated as single ref From 1470a55428432df26d9ca841a406cdf16a35c608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 14:06:44 +0200 Subject: [PATCH 08/12] (PR 3.0.0) Comment 16/17 of @sonofmun review : Fix error message in test_citation_dts --- tests/common/test_reference/test_citation_dts.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/common/test_reference/test_citation_dts.py b/tests/common/test_reference/test_citation_dts.py index e2083bce..169d874d 100644 --- a/tests/common/test_reference/test_citation_dts.py +++ b/tests/common/test_reference/test_citation_dts.py @@ -112,14 +112,14 @@ def test_ingest_simple_line(self): cite = DtsCitationSet.ingest(_context(_ex_2)) children = {c.name: c for c in cite} - self.assertEqual(2, cite.depth, "There should be 3 levels of citation") - self.assertEqual(2, len(cite), "There should be 5 children") + self.assertEqual(2, cite.depth, "There should be 2 levels of citation") + self.assertEqual(2, len(cite), "There should be 2 children") self.assertEqual(list(cite[-1]), [children["line"]], "Last level should contain line only") self.assertEqual(list(cite[-1]), list(cite[1]), "-1 level == level 1") self.assertCountEqual(list(cite[-2]), [children["poem"]], "-2 level == level 0") - self.assertCountEqual(list(cite[-2]), list(cite[0]), "-32 level == level 0") + self.assertCountEqual(list(cite[-2]), list(cite[0]), "-2 level == level 0") self.assertIsInstance(cite, DtsCitationSet, "Root should be a DtsCitationSet") self.assertEqual([type(child) for child in cite.children], [DtsCitation], "Children should be DtsCitation") From 12c3433591ccf67f3a9050e63b0cf619bb320cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 14:09:01 +0200 Subject: [PATCH 09/12] (PR 3.0.0) Comment 18 of @sonofmun review : Fix next/previous reference in test_local of cts --- tests/resolvers/cts/test_local.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/resolvers/cts/test_local.py b/tests/resolvers/cts/test_local.py index 0e674b9c..e6f22212 100644 --- a/tests/resolvers/cts/test_local.py +++ b/tests/resolvers/cts/test_local.py @@ -544,11 +544,11 @@ def test_getSiblings(self): ) self.assertEqual( previous, CtsReference("1.pr"), - "Previous should be well computed" + "Previous reference should be well computed" ) self.assertEqual( nextious, CtsReference("1.2"), - "Previous should be well computed" + "Next reference should be well computed" ) def test_getSiblings_nextOnly(self): @@ -558,11 +558,11 @@ def test_getSiblings_nextOnly(self): ) self.assertEqual( previous, None, - "Previous Should not exist" + "Previous reference should not exist" ) self.assertEqual( nextious, CtsReference("1.1"), - "Next should be well computed" + "Next reference should be well computed" ) def test_getSiblings_prevOnly(self): @@ -572,11 +572,11 @@ def test_getSiblings_prevOnly(self): ) self.assertEqual( previous, CtsReference("14.222"), - "Previous should be well computed" + "Previous reference should be well computed" ) self.assertEqual( nextious, None, - "Next should not exist" + "Next reference should not exist" ) def test_getReffs_full(self): From 76da910b90f9291b6c985c2847edba59958f96bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 14:11:25 +0200 Subject: [PATCH 10/12] (PR 3.0.0) Comment 19 of @sonofmun review : correct title of col.1.1.1 --- .../api_v1/data/collection/readableDescendants/coll1_1_1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resolvers/dts/api_v1/data/collection/readableDescendants/coll1_1_1.json b/tests/resolvers/dts/api_v1/data/collection/readableDescendants/coll1_1_1.json index 6d6a95be..1a084e88 100644 --- a/tests/resolvers/dts/api_v1/data/collection/readableDescendants/coll1_1_1.json +++ b/tests/resolvers/dts/api_v1/data/collection/readableDescendants/coll1_1_1.json @@ -7,5 +7,5 @@ "@id": "/coll1_1_1", "@type": "Resource", "totalItems": 0, - "title": "Collection 1.2.1" + "title": "Collection 1.1.1" } \ No newline at end of file From 6813cbecd9920ff9e86c6193a234660557a4b682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 14:12:30 +0200 Subject: [PATCH 11/12] (PR 3.0.0) Comment 20 of @sonofmun review : Remove trailing print --- tests/resolvers/dts/api_v1/test_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resolvers/dts/api_v1/test_metadata.py b/tests/resolvers/dts/api_v1/test_metadata.py index 34cab98b..cc3aa107 100644 --- a/tests/resolvers/dts/api_v1/test_metadata.py +++ b/tests/resolvers/dts/api_v1/test_metadata.py @@ -254,7 +254,7 @@ def add_mock(mocks, id_): "Collections should be retrieved automatically" ) history = [history.url for history in mock_set.request_history] - print(history) + self.assertNotIn( self.root_uri+"/collections?id=%2Fcoll1_2_2_1", history, From 3860683fffb96ec68299e85b00d54af73edc5fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Tue, 15 Oct 2019 18:47:14 +0200 Subject: [PATCH 12/12] Fixed typo not/now --- MyCapytain/errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MyCapytain/errors.py b/MyCapytain/errors.py index 7eedc8f5..d05c5a5f 100644 --- a/MyCapytain/errors.py +++ b/MyCapytain/errors.py @@ -15,7 +15,7 @@ class MyCapytainException(BaseException): class JsonLdCollectionMissing(MyCapytainException): - """ Error thrown when a JSON LD has now first resource + """ Error thrown when a JSON LD contains no principle collection Raised when a json supposed to contain collection is parsed but nothing is found