Skip to content

Commit d00503d

Browse files
committed
[validation] Refactor section type validations
Since Section type is now always set by default to 'n.s.' the previous section type validations have been updated as well and the corresponding messages have been changed.
1 parent 2417687 commit d00503d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

odml/validation.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,12 @@ def object_required_attributes(obj):
133133
args = obj.format().arguments
134134
for arg in args:
135135
if arg[1] == 1:
136+
msg = "Missing required attribute '%s'" % (arg[0])
136137
if not hasattr(obj, arg[0]):
137-
msg = "Missing attribute %s for %s" % (arg[0], obj.format().name.capitalize())
138138
yield ValidationError(obj, msg, LABEL_ERROR)
139139
continue
140140
obj_arg = getattr(obj, arg[0])
141141
if not obj_arg and not isinstance(obj_arg, bool):
142-
msg = "%s %s undefined" % (obj.format().name.capitalize(), arg[0])
143142
yield ValidationError(obj, msg, LABEL_ERROR)
144143

145144

@@ -150,12 +149,12 @@ def object_required_attributes(obj):
150149

151150
def section_type_must_be_defined(sec):
152151
"""
153-
Tests that no Section has an undefined type.
152+
Tests that no Section has an unspecified type and adds a warning otherwise.
154153
155154
:param sec: odml.Section.
156155
"""
157-
if sec.type is None or sec.type == '' or sec.type == 'undefined':
158-
yield ValidationError(sec, 'Section type undefined', LABEL_WARNING)
156+
if sec.type and sec.type == "n.s.":
157+
yield ValidationError(sec, "Section type not specified", LABEL_WARNING)
159158

160159

161160
Validation.register_handler('section', section_type_must_be_defined)

0 commit comments

Comments
 (0)