def set(self, facet, value):
"""Set values."""
+ if facet in ["loglevel"]:
+ value = int(value)
if not self.has_facet(facet) or not self.get(facet) == value:
if self.old_style:
if self.key not in self.origin.data:
def portals(self):
"""Map the portal directions for an area to neighbors."""
portals = {}
- if re.match("""^area:-?\d+,-?\d+,-?\d+$""", self.key):
+ if re.match(r"""^area:-?\d+,-?\d+,-?\d+$""", self.key):
coordinates = [(int(x))
for x in self.key.split(":")[1].split(",")]
offsets = dict(
"$(eol)$(bld)%s$(nrm)" % e)
elif arguments[0] == "log":
if len(arguments) == 4:
- if re.match("^\d+$", arguments[3]) and int(arguments[3]) >= 0:
+ if re.match(r"^\d+$", arguments[3]) and int(arguments[3]) >= 0:
stop = int(arguments[3])
else:
stop = -1
else:
stop = 0
if len(arguments) >= 3:
- if re.match("^\d+$", arguments[2]) and int(arguments[2]) > 0:
+ if re.match(r"^\d+$", arguments[2]) and int(arguments[2]) > 0:
start = int(arguments[2])
else:
start = -1
else:
start = 10
if len(arguments) >= 2:
- if (re.match("^\d+$", arguments[1])
+ if (re.match(r"^\d+$", arguments[1])
and 0 <= int(arguments[1]) <= 9):
level = int(arguments[1])
else:
if element not in universe.contents:
message = "The \"" + element + "\" element does not exist."
else:
- universe.contents[element].set(facet, value)
- message = ("You have successfully (re)set the \"" + facet
- + "\" facet of element \"" + element
- + "\". Try \"show element " +
- element + "\" for verification.")
+ try:
+ universe.contents[element].set(facet, value)
+ except ValueError:
+ message = ("Value \"%s\" of type \"%s\" cannot be coerced "
+ "to the correct datatype for facet \"%s\"." %
+ (value, type(value), facet))
+ else:
+ message = ("You have successfully (re)set the \"" + facet
+ + "\" facet of element \"" + element
+ + "\". Try \"show element " +
+ element + "\" for verification.")
actor.send(message)