# -*- coding: utf-8 -*-
"""Miscellaneous functions for the mudpy engine."""
-# Copyright (c) 2004-2013 Jeremy Stanley <fungi@yuggoth.org>. Permission
+# Copyright (c) 2004-2014 Jeremy Stanley <fungi@yuggoth.org>. Permission
# to use, copy, modify, and distribute this software is granted under
# terms provided in the LICENSE file distributed with this software.
def reload(self):
"""Create a new element and replace this one."""
- new_element = Element(self.key, self.universe, self.origin.filename)
+ Element(self.key, self.universe, self.origin.filename)
del(self)
def destroy(self):
def set(self, facet, value):
"""Set values."""
if not self.has_facet(facet) or not self.get(facet) == value:
- # TODO: remove this check after the switch to py3k
- if repr(type(value)) == "<type 'unicode'>":
- value = str(value)
if not type(value) is str:
value = repr(value)
self.origin.data.set(self.key, facet, value)
newlist.append(value)
self.set(facet, newlist)
- def new_event(self, action, when=None):
- """Create, attach and enqueue an event element."""
-
- # if when isn't specified, that means now
- if not when:
- when = self.universe.get_time()
-
- # events are elements themselves
- event = Element("event:" + self.key + ":" + counter)
-
def send(
self,
message,
self.contents = {}
self.default_origins = {}
self.loglines = []
- self.pending_events_long = {}
- self.pending_events_short = {}
self.private_files = []
self.reload_flag = False
self.startdir = os.getcwd()
# clear out all read-only files
if hasattr(self, "files"):
- for data_filename in self.files.keys():
+ for data_filename in list(self.files.keys()):
if not self.files[data_filename].is_writeable():
del self.files[data_filename]
escape = False
# normalize any potentially composited unicode before we count it
- # TODO: remove this check after the switch to py3k
- try:
- text = unicodedata.normalize("NFKC", text)
- except TypeError:
- text = unicodedata.normalize("NFKC", unicode(text))
+ text = unicodedata.normalize("NFKC", text)
# iterate over each character from the begining of the text
for each_character in text: