Docstring, comment, indent/whitespace edits
use of dict() to improve dictionary readability and shorten code
This commit is contained in:
parent
338899b8b1
commit
99a24a9647
1 changed files with 20 additions and 28 deletions
|
|
@ -50,11 +50,11 @@ _GA = object.__getattribute__
|
|||
|
||||
#
|
||||
# Game Object creation
|
||||
#
|
||||
|
||||
def create_object(typeclass=None, key=None, location=None,
|
||||
home=None, permissions=None, locks=None,
|
||||
aliases=None, tags=None, destination=None, report_to=None, nohome=False):
|
||||
|
||||
def create_object(typeclass=None, key=None, location=None, home=None,
|
||||
permissions=None, locks=None, aliases=None, tags=None,
|
||||
destination=None, report_to=None, nohome=False):
|
||||
"""
|
||||
|
||||
Create a new in-game object.
|
||||
|
|
@ -110,26 +110,24 @@ def create_object(typeclass=None, key=None, location=None,
|
|||
|
||||
# create new instance
|
||||
new_object = typeclass(db_key=key, db_location=location,
|
||||
db_destination=destination, db_home=home,
|
||||
db_typeclass_path=typeclass.path)
|
||||
db_destination=destination, db_home=home,
|
||||
db_typeclass_path=typeclass.path)
|
||||
# store the call signature for the signal
|
||||
new_object._createdict = {"key":key, "location":location, "destination":destination,
|
||||
"home":home, "typeclass":typeclass.path, "permissions":permissions,
|
||||
"locks":locks, "aliases":aliases, "tags": tags,
|
||||
"report_to":report_to, "nohome":nohome}
|
||||
new_object._createdict = dict(key=key, location=location, destination=destination, home=home,
|
||||
typeclass=typeclass.path, permissions=permissions, locks=locks,
|
||||
aliases=aliases, tags=tags, report_to=report_to, nohome=nohome)
|
||||
# this will trigger the save signal which in turn calls the
|
||||
# at_first_save hook on the typeclass, where the _createdict can be
|
||||
# used.
|
||||
new_object.save()
|
||||
return new_object
|
||||
|
||||
#alias for create_object
|
||||
# alias for create_object
|
||||
object = create_object
|
||||
|
||||
|
||||
#
|
||||
# Script creation
|
||||
#
|
||||
|
||||
def create_script(typeclass=None, key=None, obj=None, player=None, locks=None,
|
||||
interval=None, start_delay=None, repeats=None,
|
||||
|
|
@ -194,19 +192,16 @@ def create_script(typeclass=None, key=None, obj=None, player=None, locks=None,
|
|||
new_script = typeclass(**kwarg)
|
||||
|
||||
# store the call signature for the signal
|
||||
new_script._createdict = {"key":key, "obj":obj, "player":player,
|
||||
"locks":locks, "interval":interval,
|
||||
"start_delay":start_delay, "repeats":repeats,
|
||||
"persistent":persistent, "autostart":autostart,
|
||||
"report_to":report_to}
|
||||
|
||||
new_script._createdict = dict(key=key, obj=obj, player=player, locks=locks, interval=interval,
|
||||
start_delay=start_delay, repeats=repeats, persistent=persistent,
|
||||
autostart=autostart, report_to=report_to)
|
||||
# this will trigger the save signal which in turn calls the
|
||||
# at_first_save hook on the typeclass, where the _createdict
|
||||
# can be used.
|
||||
new_script.save()
|
||||
return new_script
|
||||
|
||||
#alias
|
||||
# alias
|
||||
script = create_script
|
||||
|
||||
|
||||
|
|
@ -227,6 +222,7 @@ def create_help_entry(key, entrytext, category="General", locks=None, aliases=No
|
|||
entrytext (str): The body of te help entry
|
||||
category (str, optional): The help category of the entry.
|
||||
locks (str, optional): A lockstring to restrict access.
|
||||
aliases (list of str): List of alternative (likely shorter) keynames.
|
||||
|
||||
Returns:
|
||||
help (HelpEntry): A newly created help entry.
|
||||
|
|
@ -260,10 +256,8 @@ help_entry = create_help_entry
|
|||
|
||||
#
|
||||
# Comm system methods
|
||||
#
|
||||
|
||||
def create_message(senderobj, message, channels=None,
|
||||
receivers=None, locks=None, header=None):
|
||||
def create_message(senderobj, message, channels=None, receivers=None, locks=None, header=None):
|
||||
"""
|
||||
Create a new communication Msg. Msgs represent a unit of
|
||||
database-persistent communication between entites.
|
||||
|
|
@ -325,7 +319,7 @@ def create_channel(key, aliases=None, desc=None,
|
|||
key (str): This must be unique.
|
||||
|
||||
Kwargs:
|
||||
aliases (list): List of alternative (likely shorter) keynames.
|
||||
aliases (list of str): List of alternative (likely shorter) keynames.
|
||||
desc (str): A description of the channel, for use in listings.
|
||||
locks (str): Lockstring.
|
||||
keep_log (bool): Log channel throughput.
|
||||
|
|
@ -346,8 +340,7 @@ def create_channel(key, aliases=None, desc=None,
|
|||
new_channel = typeclass(db_key=key)
|
||||
|
||||
# store call signature for the signal
|
||||
new_channel._createdict = {"key":key, "aliases":aliases,
|
||||
"desc":desc, "locks":locks, "keep_log":keep_log}
|
||||
new_channel._createdict = dict(key=key, aliases=aliases, desc=desc, locks=locks, keep_log=keep_log)
|
||||
|
||||
# this will trigger the save signal which in turn calls the
|
||||
# at_first_save hook on the typeclass, where the _createdict can be
|
||||
|
|
@ -358,11 +351,11 @@ def create_channel(key, aliases=None, desc=None,
|
|||
channel = create_channel
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Player creation methods
|
||||
#
|
||||
|
||||
|
||||
def create_player(key, email, password,
|
||||
typeclass=None,
|
||||
is_superuser=False,
|
||||
|
|
@ -426,8 +419,7 @@ def create_player(key, email, password,
|
|||
is_staff=is_superuser, is_superuser=is_superuser,
|
||||
last_login=now, date_joined=now)
|
||||
new_player.set_password(password)
|
||||
new_player._createdict = {"locks":locks, "permissions":permissions,
|
||||
"report_to":report_to}
|
||||
new_player._createdict = dict(locks=locks, permissions=permissions, report_to=report_to)
|
||||
# saving will trigger the signal that calls the
|
||||
# at_first_save hook on the typeclass, where the _createdict
|
||||
# can be used.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue