Docstring, comment, indent/whitespace edits

use of dict() to improve dictionary readability and shorten code
This commit is contained in:
BlauFeuer 2017-03-24 00:20:07 -04:00 committed by Griatch
parent 338899b8b1
commit 99a24a9647

View file

@ -50,11 +50,11 @@ _GA = object.__getattribute__
# #
# Game Object creation # Game Object creation
#
def create_object(typeclass=None, key=None, location=None,
home=None, permissions=None, locks=None, def create_object(typeclass=None, key=None, location=None, home=None,
aliases=None, tags=None, destination=None, report_to=None, nohome=False): permissions=None, locks=None, aliases=None, tags=None,
destination=None, report_to=None, nohome=False):
""" """
Create a new in-game object. Create a new in-game object.
@ -113,10 +113,9 @@ def create_object(typeclass=None, key=None, location=None,
db_destination=destination, db_home=home, db_destination=destination, db_home=home,
db_typeclass_path=typeclass.path) db_typeclass_path=typeclass.path)
# store the call signature for the signal # store the call signature for the signal
new_object._createdict = {"key":key, "location":location, "destination":destination, new_object._createdict = dict(key=key, location=location, destination=destination, home=home,
"home":home, "typeclass":typeclass.path, "permissions":permissions, typeclass=typeclass.path, permissions=permissions, locks=locks,
"locks":locks, "aliases":aliases, "tags": tags, aliases=aliases, tags=tags, report_to=report_to, nohome=nohome)
"report_to":report_to, "nohome":nohome}
# this will trigger the save signal which in turn calls the # this will trigger the save signal which in turn calls the
# at_first_save hook on the typeclass, where the _createdict can be # at_first_save hook on the typeclass, where the _createdict can be
# used. # used.
@ -129,7 +128,6 @@ object = create_object
# #
# Script creation # Script creation
#
def create_script(typeclass=None, key=None, obj=None, player=None, locks=None, def create_script(typeclass=None, key=None, obj=None, player=None, locks=None,
interval=None, start_delay=None, repeats=None, interval=None, start_delay=None, repeats=None,
@ -194,12 +192,9 @@ def create_script(typeclass=None, key=None, obj=None, player=None, locks=None,
new_script = typeclass(**kwarg) new_script = typeclass(**kwarg)
# store the call signature for the signal # store the call signature for the signal
new_script._createdict = {"key":key, "obj":obj, "player":player, new_script._createdict = dict(key=key, obj=obj, player=player, locks=locks, interval=interval,
"locks":locks, "interval":interval, start_delay=start_delay, repeats=repeats, persistent=persistent,
"start_delay":start_delay, "repeats":repeats, autostart=autostart, report_to=report_to)
"persistent":persistent, "autostart":autostart,
"report_to":report_to}
# this will trigger the save signal which in turn calls the # this will trigger the save signal which in turn calls the
# at_first_save hook on the typeclass, where the _createdict # at_first_save hook on the typeclass, where the _createdict
# can be used. # can be used.
@ -227,6 +222,7 @@ def create_help_entry(key, entrytext, category="General", locks=None, aliases=No
entrytext (str): The body of te help entry entrytext (str): The body of te help entry
category (str, optional): The help category of the entry. category (str, optional): The help category of the entry.
locks (str, optional): A lockstring to restrict access. locks (str, optional): A lockstring to restrict access.
aliases (list of str): List of alternative (likely shorter) keynames.
Returns: Returns:
help (HelpEntry): A newly created help entry. help (HelpEntry): A newly created help entry.
@ -260,10 +256,8 @@ help_entry = create_help_entry
# #
# Comm system methods # Comm system methods
#
def create_message(senderobj, message, channels=None, def create_message(senderobj, message, channels=None, receivers=None, locks=None, header=None):
receivers=None, locks=None, header=None):
""" """
Create a new communication Msg. Msgs represent a unit of Create a new communication Msg. Msgs represent a unit of
database-persistent communication between entites. database-persistent communication between entites.
@ -325,7 +319,7 @@ def create_channel(key, aliases=None, desc=None,
key (str): This must be unique. key (str): This must be unique.
Kwargs: 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. desc (str): A description of the channel, for use in listings.
locks (str): Lockstring. locks (str): Lockstring.
keep_log (bool): Log channel throughput. keep_log (bool): Log channel throughput.
@ -346,8 +340,7 @@ def create_channel(key, aliases=None, desc=None,
new_channel = typeclass(db_key=key) new_channel = typeclass(db_key=key)
# store call signature for the signal # store call signature for the signal
new_channel._createdict = {"key":key, "aliases":aliases, new_channel._createdict = dict(key=key, aliases=aliases, desc=desc, locks=locks, keep_log=keep_log)
"desc":desc, "locks":locks, "keep_log":keep_log}
# this will trigger the save signal which in turn calls the # this will trigger the save signal which in turn calls the
# at_first_save hook on the typeclass, where the _createdict can be # 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 channel = create_channel
# #
# Player creation methods # Player creation methods
# #
def create_player(key, email, password, def create_player(key, email, password,
typeclass=None, typeclass=None,
is_superuser=False, is_superuser=False,
@ -426,8 +419,7 @@ def create_player(key, email, password,
is_staff=is_superuser, is_superuser=is_superuser, is_staff=is_superuser, is_superuser=is_superuser,
last_login=now, date_joined=now) last_login=now, date_joined=now)
new_player.set_password(password) new_player.set_password(password)
new_player._createdict = {"locks":locks, "permissions":permissions, new_player._createdict = dict(locks=locks, permissions=permissions, report_to=report_to)
"report_to":report_to}
# saving will trigger the signal that calls the # saving will trigger the signal that calls the
# at_first_save hook on the typeclass, where the _createdict # at_first_save hook on the typeclass, where the _createdict
# can be used. # can be used.