general.py update markup/PEP 8/typos/whitespace

This commit is contained in:
BlauFeuer 2017-02-12 19:18:04 -05:00 committed by GitHub
parent 1fb064c978
commit 2079504c07

View file

@ -1,5 +1,5 @@
""" """
General Character commands usually availabe to all characters General Character commands usually available to all characters
""" """
from django.conf import settings from django.conf import settings
from evennia.utils import utils, evtable from evennia.utils import utils, evtable
@ -28,7 +28,7 @@ class CmdHome(COMMAND_DEFAULT_CLASS):
arg_regex = r"$" arg_regex = r"$"
def func(self): def func(self):
"Implement the command" """Implement the command"""
caller = self.caller caller = self.caller
home = caller.home home = caller.home
if not home: if not home:
@ -39,6 +39,7 @@ class CmdHome(COMMAND_DEFAULT_CLASS):
caller.msg("There's no place like home ...") caller.msg("There's no place like home ...")
caller.move_to(home) caller.move_to(home)
class CmdLook(COMMAND_DEFAULT_CLASS): class CmdLook(COMMAND_DEFAULT_CLASS):
""" """
look at location or object look at location or object
@ -115,7 +116,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
locks = "cmd:all()" locks = "cmd:all()"
def func(self): def func(self):
"Create the nickname" """Create the nickname"""
caller = self.caller caller = self.caller
switches = self.switches switches = self.switches
@ -126,13 +127,13 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
if 'list' in switches or self.cmdstring in ("nicks", "@nicks"): if 'list' in switches or self.cmdstring in ("nicks", "@nicks"):
if not nicklist: if not nicklist:
string = "{wNo nicks defined.{n" string = "|wNo nicks defined.|n"
else: else:
table = evtable.EvTable("#", "Type", "Nick match", "Replacement") table = evtable.EvTable("#", "Type", "Nick match", "Replacement")
for inum, nickobj in enumerate(nicklist): for inum, nickobj in enumerate(nicklist):
_, _, nickvalue, replacement = nickobj.value _, _, nickvalue, replacement = nickobj.value
table.add_row(str(inum + 1), nickobj.db_category, nickvalue, replacement) table.add_row(str(inum + 1), nickobj.db_category, nickvalue, replacement)
string = "{wDefined Nicks:{n\n%s" % table string = "|wDefined Nicks:|n\n%s" % table
caller.msg(string) caller.msg(string)
return return
@ -182,15 +183,13 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
string += "\nNick removed: '|w%s|n' -> |w%s|n." % (old_nickstring, old_replstring) string += "\nNick removed: '|w%s|n' -> |w%s|n." % (old_nickstring, old_replstring)
else: else:
errstring += "\nNick '|w%s|n' was not deleted." % old_nickstring errstring += "\nNick '|w%s|n' was not deleted." % old_nickstring
elif replstring: elif replstring:
# creating new nick # creating new nick
errstring = "" errstring = ""
if oldnick: if oldnick:
string += "\nNick '{w%s{n' updated to map to '{w%s{n'." % (old_nickstring, replstring) string += "\nNick '|w%s|n' updated to map to '|w%s|n'." % (old_nickstring, replstring)
else: else:
string += "\nNick '{w%s{n' mapped to '{w%s{n'." % (nickstring, replstring) string += "\nNick '|w%s|n' mapped to '|w%s|n'." % (nickstring, replstring)
try: try:
caller.nicks.add(nickstring, replstring, category=nicktype) caller.nicks.add(nickstring, replstring, category=nicktype)
except NickTemplateInvalid: except NickTemplateInvalid:
@ -198,7 +197,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
return return
elif old_nickstring and old_replstring: elif old_nickstring and old_replstring:
# just looking at the nick # just looking at the nick
string += "\nNick '{w%s{n' maps to '{w%s{n'." % (old_nickstring, old_replstring) string += "\nNick '|w%s|n' maps to '|w%s|n'." % (old_nickstring, old_replstring)
errstring = "" errstring = ""
string = errstring if errstring else string string = errstring if errstring else string
caller.msg(string) caller.msg(string)
@ -220,15 +219,15 @@ class CmdInventory(COMMAND_DEFAULT_CLASS):
arg_regex = r"$" arg_regex = r"$"
def func(self): def func(self):
"check inventory" """check inventory"""
items = self.caller.contents items = self.caller.contents
if not items: if not items:
string = "You are not carrying anything." string = "You are not carrying anything."
else: else:
table = evtable.EvTable(border="header") table = evtable.EvTable(border="header")
for item in items: for item in items:
table.add_row("{C%s{n" % item.name, item.db.desc or "") table.add_row("|C%s|n" % item.name, item.db.desc or "")
string = "{wYou are carrying:\n%s" % table string = "|wYou are carrying:\n%s" % table
self.caller.msg(string) self.caller.msg(string)
@ -248,7 +247,7 @@ class CmdGet(COMMAND_DEFAULT_CLASS):
arg_regex = r"\s|$" arg_regex = r"\s|$"
def func(self): def func(self):
"implements the command." """implements the command."""
caller = self.caller caller = self.caller
@ -271,8 +270,8 @@ class CmdGet(COMMAND_DEFAULT_CLASS):
obj.move_to(caller, quiet=True) obj.move_to(caller, quiet=True)
caller.msg("You pick up %s." % obj.name) caller.msg("You pick up %s." % obj.name)
caller.location.msg_contents("%s picks up %s." % caller.location.msg_contents("%s picks up %s." %
(caller.name, (caller.name,
obj.name), obj.name),
exclude=caller) exclude=caller)
# calling hook method # calling hook method
obj.at_get(caller) obj.at_get(caller)
@ -294,7 +293,7 @@ class CmdDrop(COMMAND_DEFAULT_CLASS):
arg_regex = r"\s|$" arg_regex = r"\s|$"
def func(self): def func(self):
"Implement command" """Implement command"""
caller = self.caller caller = self.caller
if not self.args: if not self.args:
@ -312,7 +311,7 @@ class CmdDrop(COMMAND_DEFAULT_CLASS):
obj.move_to(caller.location, quiet=True) obj.move_to(caller.location, quiet=True)
caller.msg("You drop %s." % (obj.name,)) caller.msg("You drop %s." % (obj.name,))
caller.location.msg_contents("%s drops %s." % caller.location.msg_contents("%s drops %s." %
(caller.name, obj.name), (caller.name, obj.name),
exclude=caller) exclude=caller)
# Call the object script's at_drop() method. # Call the object script's at_drop() method.
obj.at_drop(caller) obj.at_drop(caller)
@ -333,7 +332,7 @@ class CmdGive(COMMAND_DEFAULT_CLASS):
arg_regex = r"\s|$" arg_regex = r"\s|$"
def func(self): def func(self):
"Implement give" """Implement give"""
caller = self.caller caller = self.caller
if not self.args or not self.rhs: if not self.args or not self.rhs:
@ -373,7 +372,7 @@ class CmdDesc(COMMAND_DEFAULT_CLASS):
arg_regex = r"\s|$" arg_regex = r"\s|$"
def func(self): def func(self):
"add the description" """add the description"""
if not self.args: if not self.args:
self.caller.msg("You must add a description.") self.caller.msg("You must add a description.")
@ -382,6 +381,7 @@ class CmdDesc(COMMAND_DEFAULT_CLASS):
self.caller.db.desc = self.args.strip() self.caller.db.desc = self.args.strip()
self.caller.msg("You set your description.") self.caller.msg("You set your description.")
class CmdSay(COMMAND_DEFAULT_CLASS): class CmdSay(COMMAND_DEFAULT_CLASS):
""" """
speak as your character speak as your character
@ -397,7 +397,7 @@ class CmdSay(COMMAND_DEFAULT_CLASS):
locks = "cmd:all()" locks = "cmd:all()"
def func(self): def func(self):
"Run the say command" """Run the say command"""
caller = self.caller caller = self.caller
@ -411,13 +411,11 @@ class CmdSay(COMMAND_DEFAULT_CLASS):
speech = caller.location.at_say(caller, speech) speech = caller.location.at_say(caller, speech)
# Feedback for the object doing the talking. # Feedback for the object doing the talking.
caller.msg('You say, "%s{n"' % speech) caller.msg('You say, "%s|n"' % speech)
# Build the string to emit to neighbors. # Build the string to emit to neighbors.
emit_string = '%s says, "%s{n"' % (caller.name, emit_string = '%s says, "%s|n"' % (caller.name, speech)
speech) caller.location.msg_contents(emit_string, exclude=caller, from_obj=caller)
caller.location.msg_contents(emit_string,
exclude=caller, from_obj=caller)
class CmdPose(COMMAND_DEFAULT_CLASS): class CmdPose(COMMAND_DEFAULT_CLASS):
@ -454,7 +452,7 @@ class CmdPose(COMMAND_DEFAULT_CLASS):
self.args = args self.args = args
def func(self): def func(self):
"Hook function" """Hook function"""
if not self.args: if not self.args:
msg = "What do you want to do?" msg = "What do you want to do?"
self.caller.msg(msg) self.caller.msg(msg)
@ -479,12 +477,11 @@ class CmdAccess(COMMAND_DEFAULT_CLASS):
arg_regex = r"$" arg_regex = r"$"
def func(self): def func(self):
"Load the permission groups" """Load the permission groups"""
caller = self.caller caller = self.caller
hierarchy_full = settings.PERMISSION_HIERARCHY hierarchy_full = settings.PERMISSION_HIERARCHY
string = "\n{wPermission Hierarchy{n (climbing):\n %s" % ", ".join(hierarchy_full) string = "\n|wPermission Hierarchy|n (climbing):\n %s" % ", ".join(hierarchy_full)
#hierarchy = [p.lower() for p in hierarchy_full]
if self.caller.player.is_superuser: if self.caller.player.is_superuser:
cperms = "<Superuser>" cperms = "<Superuser>"
@ -493,8 +490,8 @@ class CmdAccess(COMMAND_DEFAULT_CLASS):
cperms = ", ".join(caller.permissions.all()) cperms = ", ".join(caller.permissions.all())
pperms = ", ".join(caller.player.permissions.all()) pperms = ", ".join(caller.player.permissions.all())
string += "\n{wYour access{n:" string += "\n|wYour access|n:"
string += "\nCharacter {c%s{n: %s" % (caller.key, cperms) string += "\nCharacter |c%s|n: %s" % (caller.key, cperms)
if hasattr(caller, 'player'): if hasattr(caller, 'player'):
string += "\nPlayer {c%s{n: %s" % (caller.player.key, pperms) string += "\nPlayer |c%s|n: %s" % (caller.player.key, pperms)
caller.msg(string) caller.msg(string)