Skip to content

Commit 197279a

Browse files
authored
Merge pull request #285 from mpsonntag/uiconvert
Add custom InvalidVersion exception
2 parents c741854 + a4a52c9 commit 197279a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

odml/tools/dict_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from .. import format as odmlfmt
77
from ..info import FORMAT_VERSION
8-
from .parser_utils import ParserException
8+
from .parser_utils import InvalidVersionException, ParserException
99

1010

1111
class DictWriter:
@@ -131,7 +131,7 @@ def to_odml(self, parsed_doc):
131131
msg = ("Cannot read file: invalid odML document format version '%s'. \n"
132132
"This package supports odML format versions: '%s'."
133133
% (self.parsed_doc.get('odml-version'), FORMAT_VERSION))
134-
raise ParserException(msg)
134+
raise InvalidVersionException(msg)
135135

136136
self.parsed_doc = self.parsed_doc['Document']
137137

odml/tools/parser_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ class ParserException(Exception):
1111
Exception wrapper used by various odML parsers.
1212
"""
1313
pass
14+
15+
16+
class InvalidVersionException(ParserException):
17+
"""
18+
Exception wrapper to indicate a non-compatible odML version.
19+
"""
20+
pass

odml/tools/xmlparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from .. import format
2020
from ..info import FORMAT_VERSION
21-
from .parser_utils import ParserException
21+
from .parser_utils import InvalidVersionException, ParserException
2222

2323
try:
2424
unicode = unicode
@@ -162,7 +162,7 @@ def _handle_version(root):
162162
msg = ("Cannot read file: invalid odML document format version '%s'. \n"
163163
"This package supports odML format versions: '%s'."
164164
% (root.attrib['version'], FORMAT_VERSION))
165-
raise ParserException(msg)
165+
raise InvalidVersionException(msg)
166166

167167
def from_file(self, xml_file):
168168
"""

0 commit comments

Comments
 (0)