diff options
-rwxr-xr-x | check | 8 | ||||
-rw-r--r-- | morphlib/morphloader.py | 11 | ||||
-rwxr-xr-x | scripts/check-copyright-year | 18 |
3 files changed, 16 insertions, 21 deletions
@@ -92,13 +92,12 @@ export PYTHONPATH # Run the style checks -errors=0 if "$run_style" && [ -d .git ]; then echo "Checking copyright statements" if ! (git ls-files --cached -z | xargs -0r scripts/check-copyright-year); then - errors=1 + exit 1 fi echo 'Checking source code for silliness' @@ -107,12 +106,9 @@ then grep -Ev 'tests[^/]*/.*\.std(out|err)' | grep -vF 'tests.build/build-system-autotools.script' | xargs -r scripts/check-silliness); then - errors=1 + exit 1 fi fi -if [ "$errors" != 0 ]; then - exit "$errors" -fi # Clean up artifacts from previous (possibly failed) runs, build, # and run the tests. diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index cd005fae..ca5902a6 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -41,8 +41,8 @@ class MorphologyObsoleteFieldWarning(UserWarning): class MorphologySyntaxError(morphlib.Error): - def __init__(self, morphology): - self.msg = 'Syntax error in morphology %s' % morphology + def __init__(self, morphology, errmsg): + self.msg = 'Syntax error in morphology %s:\n%s' % (morphology, errmsg) class NotADictionaryError(morphlib.Error): @@ -344,8 +344,7 @@ class MorphologyLoader(object): try: obj = yaml.safe_load(text) except yaml.error.YAMLError as e: - logging.error('Could not load morphology as YAML:\n%s' % str(e)) - raise MorphologySyntaxError(whence) + raise MorphologySyntaxError(whence, e) if not isinstance(obj, dict): raise NotADictionaryError(whence) @@ -435,7 +434,7 @@ class MorphologyLoader(object): for spec in strata: name = spec.get('alias', spec['morph']) if name in names: - raise DuplicateStratumError(morph['name'], name) + raise DuplicateStratumError(morph['name'], name) names.add(name) # Validate stratum spec fields @@ -460,7 +459,7 @@ class MorphologyLoader(object): for spec in morph['chunks']: name = spec.get('alias', spec['name']) if name in names: - raise DuplicateChunkError(morph['name'], name) + raise DuplicateChunkError(morph['name'], name) names.add(name) # All chunk refs must be strings. diff --git a/scripts/check-copyright-year b/scripts/check-copyright-year index d72ddbc6..e72eaeea 100755 --- a/scripts/check-copyright-year +++ b/scripts/check-copyright-year @@ -17,13 +17,14 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +from __future__ import print_function import datetime import re +import sys import cliapp - class CheckCopyrightYear(cliapp.Application): pat = re.compile(r'^[ #/*]*Copyright\s+(\(C\)\s*)' @@ -39,7 +40,8 @@ class CheckCopyrightYear(cliapp.Application): def cleanup(self): if not self.all_ok: - raise cliapp.AppException('Some copyright years need fixing') + print('ERROR: Some copyright years need fixing', file=sys.stderr) + sys.exit(1) def get_uncommitted_files(self): filenames = set() @@ -73,14 +75,12 @@ class CheckCopyrightYear(cliapp.Application): if start <= year <= end: ok = True - if self.settings['verbose']: - if ok: + if ok: + if self.settings['verbose']: self.output.write('OK %s\n' % filename) - else: - self.output.write('BAD %s:%s:%s\n' % - (filename, self.lineno, line.strip())) - elif not ok: - self.output.write('%s\n' % filename) + else: + self.output.write('BAD %s:%s:%s\n' % + (filename, self.lineno, line.strip())) self.all_ok = self.all_ok and ok |