diff --git a/HookTest/units.py b/HookTest/units.py index b880efa..f438472 100644 --- a/HookTest/units.py +++ b/HookTest/units.py @@ -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 @@ -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: @@ -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 diff --git a/README.md b/README.md index 8d8069b..4c8e876 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ```