def set(self, facet, value):
"""Set values."""
+ if not self.origin.is_writeable() and not self.universe.loading:
+ # break if there is an attempt to update an element from a
+ # read-only file, unless the universe is in the midst of loading
+ # updated data from files
+ raise PermissionError("Altering elements in read-only files is "
+ "disallowed")
if facet in ["loglevel"]:
value = int(value)
if not self.has_facet(facet) or not self.get(facet) == value:
else:
try:
universe.contents[element].set(facet, value)
+ except PermissionError:
+ message = ('The "%s" element is kept in read-only file '
+ '"%s" and cannot be altered.' %
+ (element, universe.contents[
+ element].origin.filename))
except ValueError:
message = ('Value "%s" of type "%s" cannot be coerced '
'to the correct datatype for facet "%s".' %