Skip to content
Snippets Groups Projects
Commit c42a0c56 authored by florian's avatar florian
Browse files

MAINT: Make error message for missing datatype more precise

parent c7c2879b
No related branches found
No related tags found
1 merge request!22Release 0.3
Pipeline #13488 passed with warnings
......@@ -316,19 +316,22 @@ class Parser(object):
self.model[name].description = prop
elif prop_name == "recommended_properties":
self._add_to_recordtype(name, prop, importance=db.RECOMMENDED)
self._add_to_recordtype(
name, prop, importance=db.RECOMMENDED)
for n, e in prop.items():
self._treat_entity(n, e)
elif prop_name == "obligatory_properties":
self._add_to_recordtype(name, prop, importance=db.OBLIGATORY)
self._add_to_recordtype(
name, prop, importance=db.OBLIGATORY)
for n, e in prop.items():
self._treat_entity(n, e)
elif prop_name == "suggested_properties":
self._add_to_recordtype(name, prop, importance=db.SUGGESTED)
self._add_to_recordtype(
name, prop, importance=db.SUGGESTED)
for n, e in prop.items():
self._treat_entity(n, e)
......@@ -355,9 +358,13 @@ class Parser(object):
self.treated.append(name)
def _check_datatypes(self):
""" checks if datatype is valid.
datatype of properties is simply initialized with string. Here over
properties is iterated and datatype is corrected. """
"""Checks if the datatype is valid.
Iterate over all properties in this datamodel and choose a
valid datatype from the original datatype string in the yaml
file. Raise a ValueError if no datatype can be found.
"""
for key, value in self.model.items():
if isinstance(value, db.Property):
......@@ -368,7 +375,8 @@ class Parser(object):
try:
value.datatype = db.__getattribute__(value.datatype)
except AttributeError:
raise ValueError("Unknown Datatype.")
raise ValueError(
"Property {} has an unknown datatype: {}".format(value.name, value.datatype))
def _set_recordtypes(self):
""" properties are defined in first iteration; set remaining as RTs """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment