Skip to content

Commit

Permalink
Fix error()
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique committed Nov 26, 2015
1 parent f401711 commit 43aad0e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
42 changes: 17 additions & 25 deletions HookTest/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def log(self, message):

def error(self, error):
if isinstance(error, Exception):
self.__logs.append(">>>>>> " + str(type(error)) + " : " + str(error))
self.log(str(type(error)) + " : " + str(error))

def flush(self):
self.__archives = self.__archives + self.__logs
Expand Down Expand Up @@ -281,17 +281,15 @@ def capitain(self):
"""
if self.xml:
try:
self.Text = MyCapytain.resources.texts.local.Text(resource=self.xml.getroot(), autoreffs=False)
self.Text = MyCapytain.resources.texts.local.Text(resource=self.xml.getroot())
yield True
except XPathEvalError as E:
self.log("XPath given for citation can't be parsed")
self.error(E)
yield False
except MyCapytain.errors.RefsDeclError as E:
self.error(E)
yield False
except (IndexError, TypeError) as E:
self.error(E)
self.log("Text can't be read through Capitains standards")
yield False
else:
Expand Down Expand Up @@ -337,27 +335,21 @@ def tei(self):

def passages(self):
if self.Text:
self.Text.parse()
_continue = True

if _continue:
for i in range(0, len(self.Text.citation)):
try:
with warnings.catch_warnings(record=True) as w:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
passages = self.Text.getValidReff(level=i+1)
status = len(passages) > 0 and len(w) == 0
self.log(str(len(passages)) + " found")
if len(w) > 0:
self.log("Duplicate founds : {0}".format(", ".join([str(v.message) for v in w])))
yield status
except Exception as E:
self.error(E)
self.log("Error when searching passages at level {0}".format(i+1))
yield False
else:
yield False
for i in range(0, len(self.Text.citation)):
try:
with warnings.catch_warnings(record=True) as w:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
passages = self.Text.getValidReff(level=i+1)
status = len(passages) > 0 and len(w) == 0
self.log(str(len(passages)) + " found")
if len(w) > 0:
self.log("Duplicate founds : {0}".format(", ".join([str(v.message) for v in w])))
yield status
except Exception as E:
self.error(E)
self.log("Error when searching passages at level {0}".format(i+1))
yield False
else:
yield False

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Capitains HookTest is a python library and commandline tool for testing Capitain

```
usage: HookTest-Local [-h] [-i UUID] [-r REPOSITORY] [-b BRANCH] [-w WORKERS]
[-s SCHEME] [-v] [-p PING]
[-s SCHEME] [-v] [-j JSON] [-c] [-p PING]
path
HookTest provides local and easy to use tests for CTS resources package
Expand All @@ -32,6 +32,8 @@ optional arguments:
-s SCHEME, --scheme SCHEME
'tei' or 'epidoc' scheme to be used
-v, --verbose Show RNG's errors
-j JSON, --json JSON Save to specified json file the results
-c, --console Print to console
-p PING, --ping PING Send results to a server
```

Expand Down

0 comments on commit 43aad0e

Please sign in to comment.