implement singleton as requirement
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
efedfbf47c
commit
d0123acc2a
1 changed files with 12 additions and 9 deletions
|
@ -156,19 +156,22 @@ class Emulator(object):
|
||||||
self.log.debug("Recording requirement: " + requirement)
|
self.log.debug("Recording requirement: " + requirement)
|
||||||
requirement_parts = requirement.split(os.sep, 1)
|
requirement_parts = requirement.split(os.sep, 1)
|
||||||
requirement_type_name = requirement_parts[0]
|
requirement_type_name = requirement_parts[0]
|
||||||
requirement_object_id = requirement_parts[1]
|
try:
|
||||||
|
requirement_object_id = requirement_parts[1]
|
||||||
# FIXME: Add support for omitted object id == singleton
|
except IndexError:
|
||||||
#if len(requirement_parts) == 1:
|
# no object id, assume singleton
|
||||||
#except IndexError:
|
requirement_object_id = 'singleton'
|
||||||
# # no object id, must be singleton
|
|
||||||
# requirement_object_id = 'singleton'
|
# Remove leading / from object id
|
||||||
|
|
||||||
# Remove / if existent in object id
|
|
||||||
requirement_object_id = requirement_object_id.lstrip('/')
|
requirement_object_id = requirement_object_id.lstrip('/')
|
||||||
|
|
||||||
# Instantiate type which fails if type does not exist
|
# Instantiate type which fails if type does not exist
|
||||||
requirement_type = core.Type(self.type_base_path, requirement_type_name)
|
requirement_type = core.Type(self.type_base_path, requirement_type_name)
|
||||||
|
|
||||||
|
if requirement_object_id == 'singleton' \
|
||||||
|
and not requirement_type.is_singleton:
|
||||||
|
raise IllegalRequirementError(requirement, "Missing object_id and type is not a singleton.")
|
||||||
|
|
||||||
# Instantiate object which fails if the object_id is illegal
|
# Instantiate object which fails if the object_id is illegal
|
||||||
requirement_object = core.Object(requirement_type, self.object_base_path, requirement_object_id)
|
requirement_object = core.Object(requirement_type, self.object_base_path, requirement_object_id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue