Docstring, comments, indent/whitespace edits
This commit is contained in:
parent
b0ac809229
commit
338899b8b1
1 changed files with 43 additions and 49 deletions
|
|
@ -34,6 +34,7 @@ _SESSID_MAX = 16 if _MULTISESSION_MODE in (1, 3) else 1
|
|||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
|
||||
class ObjectSessionHandler(object):
|
||||
"""
|
||||
Handles the get/setting of the sessid
|
||||
|
|
@ -133,7 +134,7 @@ class ObjectSessionHandler(object):
|
|||
Remove session from handler.
|
||||
|
||||
Args:
|
||||
sessid (Session or int): Session or session id to remove.
|
||||
session (Session or int): Session or session id to remove.
|
||||
|
||||
"""
|
||||
try:
|
||||
|
|
@ -167,10 +168,9 @@ class ObjectSessionHandler(object):
|
|||
return len(self._sessid_cache)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Base class to inherit from.
|
||||
#
|
||||
|
||||
|
||||
class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||
"""
|
||||
|
|
@ -241,7 +241,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
|
||||
"""
|
||||
con = self.contents_cache.get(exclude=exclude)
|
||||
#print "contents_get:", self, con, id(self), calledby()
|
||||
# print "contents_get:", self, con, id(self), calledby() # DEBUG
|
||||
return con
|
||||
contents = property(contents_get)
|
||||
|
||||
|
|
@ -370,7 +370,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
# do nick-replacement on search
|
||||
searchdata = self.nicks.nickreplace(searchdata, categories=("object", "player"), include_player=True)
|
||||
|
||||
if(global_search or (is_string and searchdata.startswith("#") and
|
||||
if (global_search or (is_string and searchdata.startswith("#") and
|
||||
len(searchdata) > 1 and searchdata[1:].isdigit())):
|
||||
# only allow exact matching if searching the entire database
|
||||
# or unique #dbrefs
|
||||
|
|
@ -474,11 +474,9 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
# nick replacement - we require full-word matching.
|
||||
# do text encoding conversion
|
||||
raw_string = to_unicode(raw_string)
|
||||
raw_string = self.nicks.nickreplace(raw_string,
|
||||
categories=("inputline", "channel"), include_player=True)
|
||||
raw_string = self.nicks.nickreplace(raw_string, categories=("inputline", "channel"), include_player=True)
|
||||
return cmdhandler.cmdhandler(self, raw_string, callertype="object", session=session, **kwargs)
|
||||
|
||||
|
||||
def msg(self, text=None, from_obj=None, session=None, options=None, **kwargs):
|
||||
"""
|
||||
Emits something to a session attached to the object.
|
||||
|
|
@ -594,8 +592,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
if mapping:
|
||||
substitutions = {t: sub.get_display_name(obj)
|
||||
if hasattr(sub, 'get_display_name')
|
||||
else str(sub)
|
||||
for t, sub in mapping.items()}
|
||||
else str(sub) for t, sub in mapping.items()}
|
||||
obj.msg(message.format(**substitutions), from_obj=from_obj, **kwargs)
|
||||
else:
|
||||
obj.msg(message, from_obj=from_obj, **kwargs)
|
||||
|
|
@ -643,7 +640,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
|
||||
"""
|
||||
def logerr(string="", err=None):
|
||||
"Simple log helper method"
|
||||
"""Simple log helper method"""
|
||||
logger.log_trace()
|
||||
self.msg("%s%s" % (string, "" if err is None else " (%s)" % err))
|
||||
return
|
||||
|
|
@ -685,7 +682,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
return False
|
||||
|
||||
if not quiet:
|
||||
#tell the old room we are leaving
|
||||
# tell the old room we are leaving
|
||||
try:
|
||||
self.announce_move_from(destination)
|
||||
except Exception as err:
|
||||
|
|
@ -780,7 +777,6 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
obj.msg(_(string))
|
||||
obj.move_to(home)
|
||||
|
||||
|
||||
def copy(self, new_key=None):
|
||||
"""
|
||||
Makes an identical copy of this object, identical except for a
|
||||
|
|
@ -804,15 +800,15 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
"""
|
||||
key = self.key
|
||||
num = 1
|
||||
for obj in (obj for obj in self.location.contents
|
||||
if obj.key.startswith(key) and
|
||||
obj.key.lstrip(key).isdigit()):
|
||||
for _ in (obj for obj in self.location.contents
|
||||
if obj.key.startswith(key) and obj.key.lstrip(key).isdigit()):
|
||||
num += 1
|
||||
return "%s%03i" % (key, num)
|
||||
new_key = new_key or find_clone_key()
|
||||
return ObjectDB.objects.copy_object(self, new_key=new_key)
|
||||
|
||||
delete_iter = 0
|
||||
|
||||
def delete(self):
|
||||
"""
|
||||
Deletes this object. Before deletion, this method makes sure
|
||||
|
|
@ -956,8 +952,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
|
||||
self.basetype_posthook_setup()
|
||||
|
||||
|
||||
## hooks called by the game engine
|
||||
# hooks called by the game engine #
|
||||
|
||||
def basetype_setup(self):
|
||||
"""
|
||||
|
|
@ -1119,9 +1114,8 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
|
||||
Args:
|
||||
result (bool): The outcome of the access call.
|
||||
accessing_obj (Object or Player): The entity trying to
|
||||
gain access. access_type (str): The type of access that
|
||||
was requested.
|
||||
accessing_obj (Object or Player): The entity trying to gain access.
|
||||
access_type (str): The type of access that was requested.
|
||||
|
||||
Kwargs:
|
||||
Not used by default, added for possible expandability in a
|
||||
|
|
@ -1141,14 +1135,14 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
destination (Object): The object we are moving to
|
||||
|
||||
Returns:
|
||||
shouldmove (bool): If we should move or not.
|
||||
(bool): If we should move or not.
|
||||
|
||||
Notes:
|
||||
If this method returns False/None, the move is cancelled
|
||||
before it is even started.
|
||||
|
||||
"""
|
||||
#return has_perm(self, destination, "can_move")
|
||||
# return has_perm(self, destination, "can_move")
|
||||
return True
|
||||
|
||||
def announce_move_from(self, destination):
|
||||
|
|
@ -1289,7 +1283,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
check for this. .
|
||||
|
||||
Consider this a pre-processing method before msg is passed on
|
||||
to the user sesssion. If this method returns False, the msg
|
||||
to the user session. If this method returns False, the msg
|
||||
will not be passed on.
|
||||
|
||||
Args:
|
||||
|
|
@ -1582,7 +1576,7 @@ class DefaultCharacter(DefaultObject):
|
|||
|
||||
#
|
||||
# Base Room object
|
||||
#
|
||||
|
||||
|
||||
class DefaultRoom(DefaultObject):
|
||||
"""
|
||||
|
|
@ -1648,7 +1642,7 @@ class ExitCommand(command.Command):
|
|||
|
||||
#
|
||||
# Base Exit object
|
||||
#
|
||||
|
||||
|
||||
class DefaultExit(DefaultObject):
|
||||
"""
|
||||
|
|
@ -1700,8 +1694,8 @@ class DefaultExit(DefaultObject):
|
|||
exit_cmdset.add(cmd)
|
||||
return exit_cmdset
|
||||
|
||||
|
||||
# Command hooks
|
||||
|
||||
def basetype_setup(self):
|
||||
"""
|
||||
Setup exit-security
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue