Skip to content

Commit

Permalink
Merged new mater into stray_print
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmun committed Jul 27, 2018
2 parents e83c5f5 + 5539b67 commit baa6bc8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
@@ -1,4 +1,5 @@
### 2018-07-27 2.0.9 @sonofmun

- Removed a random print statement that had been used for debugging empty references

### 2018-06-25 2.0.8 @sonofmun
Expand Down
7 changes: 6 additions & 1 deletion MyCapytain/errors.py
Expand Up @@ -66,7 +66,12 @@ class EmptyReference(SyntaxWarning, MyCapytainException):
""" Error generated when a duplicate is found in Reference
"""


class CitationDepthError(UnknownObjectError, MyCapytainException):
""" Error generated when the depth of a requested citation is deeper than the citation scheme of the text
"""


class MissingRefsDecl(Exception, MyCapytainException):
""" A text has no properly encoded refsDecl
"""
4 changes: 3 additions & 1 deletion MyCapytain/resources/texts/local/capitains/cts.py
Expand Up @@ -11,7 +11,7 @@

import warnings

from MyCapytain.errors import DuplicateReference, MissingAttribute, RefsDeclError, EmptyReference, CitationDepthError
from MyCapytain.errors import DuplicateReference, MissingAttribute, RefsDeclError, EmptyReference, CitationDepthError, MissingRefsDecl
from MyCapytain.common.utils import copyNode, passageLoop, normalizeXpath
from MyCapytain.common.constants import XPATH_NAMESPACES, RDF_NAMESPACES
from MyCapytain.common.reference import URN, Citation, Reference
Expand Down Expand Up @@ -454,6 +454,8 @@ def __findCRefPattern(self, xml):
citation = xml.xpath("//tei:refsDecl[@n='CTS']", namespaces=XPATH_NAMESPACES)
if len(citation):
self.citation = Citation.ingest(resource=citation[0], xpath=".//tei:cRefPattern")
else:
raise MissingRefsDecl("No reference declaration (refsDecl) found.")

def test(self):
""" Parse the object and generate the children
Expand Down
6 changes: 2 additions & 4 deletions tests/resources/texts/local/commonTests.py
Expand Up @@ -247,10 +247,8 @@ def test_complex_reffs(self):

def test_xml_no_refs_Decl(self):
""" Test the result of parsing when there is no citation """
text = self.parse("tests/testing_data/texts/refsDeclButNoCTS.xml")
self.assertEqual(
text.citation.isEmpty(), True, "There should be no citation"
)
with self.assertRaises(MyCapytain.errors.MissingRefsDecl):
self.parse("tests/testing_data/texts/refsDeclButNoCTS.xml")

def test_xml_with_xml_id(self):
""" Test that xml:id is Citation xpath works fine in passage retriaval """
Expand Down

0 comments on commit baa6bc8

Please sign in to comment.