Skip to content

Commit 837c322

Browse files
committed
[tools/parser] Refactor InvalidVersion message
When failing trying to open an old odML version file advertise the VersionConverter to import the file instead in the Exception message.
1 parent 37b32dc commit 837c322

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

odml/tools/dict_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ def to_odml(self, parsed_doc):
131131
raise ParserException("Invalid odML document: Could not find odml-version.")
132132

133133
elif self.parsed_doc.get('odml-version') != FORMAT_VERSION:
134-
msg = ("Cannot read file: invalid odML document format version '%s'. \n"
135-
"This package supports odML format versions: '%s'."
136-
% (self.parsed_doc.get('odml-version'), FORMAT_VERSION))
134+
msg = ("Cannot parse odML document with format version '%s'. \n"
135+
"\tUse the 'tools.VersionConverter' to import previous odML formats."
136+
% self.parsed_doc.get('odml-version'))
137137
raise InvalidVersionException(msg)
138138

139139
self.parsed_doc = self.parsed_doc['Document']

odml/tools/xmlparser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ def _handle_version(root):
159159
raise ParserException("Could not find format version attribute "
160160
"in <odML> tag.\n")
161161
elif root.attrib['version'] != FORMAT_VERSION:
162-
msg = ("Cannot read file: invalid odML document format version '%s'. \n"
163-
"This package supports odML format versions: '%s'."
164-
% (root.attrib['version'], FORMAT_VERSION))
162+
msg = ("Cannot parse odML document with format version '%s'. \n"
163+
"\tUse the 'tools.VersionConverter' to import previous odML formats."
164+
% root.attrib['version'])
165165
raise InvalidVersionException(msg)
166166

167167
def from_file(self, xml_file):

0 commit comments

Comments
 (0)