Skip to content

Commit 8687220

Browse files
committed
[tools/dict_parser] Reader.init: Add ignore_errors
Adding the 'ignore_errors' attribute to the DictReader init.
1 parent c6857d4 commit 8687220

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

odml/tools/dict_parser.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,22 @@ class DictReader:
169169
A reader to parse dictionaries with odML content into an odml.Document.
170170
"""
171171

172-
def __init__(self, show_warnings=True):
172+
def __init__(self, show_warnings=True, ignore_errors=False):
173173
"""
174174
:param show_warnings: Toggle whether to print warnings to the command line.
175175
Any warnings can be accessed via the Reader's class
176176
warnings attribute after parsing is done.
177+
:param ignore_errors: To allow loading and fixing of invalid odml files
178+
encountered errors can be converted to warnings
179+
instead. Such a document can only be saved when
180+
all errors have been addressed though.
177181
"""
178182
self.parsed_doc = None # Python dictionary object equivalent
179-
self.show_warnings = show_warnings
180183
self.warnings = []
181184

185+
self.show_warnings = show_warnings
186+
self.ignore_errors = ignore_errors
187+
182188
def is_valid_attribute(self, attr, fmt):
183189
"""
184190
Checks whether a provided attribute is valid for a provided odml class

0 commit comments

Comments
 (0)