diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-01-18 16:18:20 +0000 |
---|---|---|
committer | Javier Jardón <javier.jardon@codethink.co.uk> | 2013-01-22 18:34:22 +0000 |
commit | 7ef9cb8922bd933ae8ee58cb24a2b38844a0e629 (patch) | |
tree | 74f71465c0002d98b8c741f4d728dc3cf6f620ad /morphlib/morphologyfactory.py | |
parent | a8d30277932099dcae31f99d3fbd531f74eb0249 (diff) | |
download | morph-7ef9cb8922bd933ae8ee58cb24a2b38844a0e629.tar.gz |
Parse as YAML if not valid JSON
Tests are currently broken, one because invalid JSON
can be valid YAML, and coverage is incomplete.
Diffstat (limited to 'morphlib/morphologyfactory.py')
-rw-r--r-- | morphlib/morphologyfactory.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/morphlib/morphologyfactory.py b/morphlib/morphologyfactory.py index a219ed9b..261dc908 100644 --- a/morphlib/morphologyfactory.py +++ b/morphlib/morphologyfactory.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,6 +13,8 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import yaml + import morphlib import cliapp @@ -81,7 +83,7 @@ class MorphologyFactory(object): try: morphology = morphlib.morph2.Morphology(text) - except ValueError as e: + except yaml.YAMLError as e: raise morphlib.Error("Error parsing %s: %s" % (filename, str(e))) |