From ec113885312849d02b44fdfa027574728357a965 Mon Sep 17 00:00:00 2001 From: BlauFeuer Date: Sat, 18 Feb 2017 19:56:44 -0500 Subject: [PATCH] Markup, whitespace, PEP 8 and docstring updates --- evennia/commands/command.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/evennia/commands/command.py b/evennia/commands/command.py index 79c6b48ce7e..2684f9e8da0 100644 --- a/evennia/commands/command.py +++ b/evennia/commands/command.py @@ -35,7 +35,7 @@ def _init_command(cls, **kwargs): if cls.aliases and not is_iter(cls.aliases): try: cls.aliases = [str(alias).strip().lower() - for alias in cls.aliases.split(',')] + for alias in cls.aliases.split(',')] except Exception: cls.aliases = [] cls.aliases = list(set(alias for alias in cls.aliases @@ -57,7 +57,7 @@ def _init_command(cls, **kwargs): if not hasattr(cls, 'locks'): # default if one forgets to define completely cls.locks = "cmd:all()" - if not "cmd:" in cls.locks: + if "cmd:" not in cls.locks: cls.locks = "cmd:all();" + cls.locks for lockstring in cls.locks.split(';'): if lockstring and not ':' in lockstring: @@ -197,7 +197,6 @@ def __eq__(self, cmd): try: # first assume input is a command (the most common case) return self._matchset.intersection(cmd._matchset) - #return cmd.key in self._matchset except AttributeError: # probably got a string return cmd in self._matchset @@ -211,9 +210,8 @@ def __ne__(self, cmd): """ try: return self._matchset.isdisjoint(cmd._matchset) - #return not cmd.key in self._matcheset except AttributeError: - return not cmd in self._matchset + return cmd not in self._matchset def __contains__(self, query): """ @@ -308,7 +306,7 @@ def access(self, srcobj, access_type="cmd", default=False): def msg(self, text=None, to_obj=None, from_obj=None, session=None, **kwargs): """ - This is a shortcut instad of calling msg() directly on an + This is a shortcut instead of calling msg() directly on an object - it will detect if caller is an Object or a Player and also appends self.session automatically if self.msg_all_sessions is False. @@ -398,17 +396,18 @@ def func(self): """ # a simple test command to show the available properties string = "-" * 50 - string += "\n{w%s{n - Command variables from evennia:\n" % self.key + string += "\n|w%s|n - Command variables from evennia:\n" % self.key string += "-" * 50 - string += "\nname of cmd (self.key): {w%s{n\n" % self.key - string += "cmd aliases (self.aliases): {w%s{n\n" % self.aliases - string += "cmd locks (self.locks): {w%s{n\n" % self.locks - string += "help category (self.help_category): {w%s{n\n" % self.help_category.capitalize() - string += "object calling (self.caller): {w%s{n\n" % self.caller - string += "object storing cmdset (self.obj): {w%s{n\n" % self.obj - string += "command string given (self.cmdstring): {w%s{n\n" % self.cmdstring + string += "\nname of cmd (self.key): |w%s|n\n" % self.key + string += "cmd aliases (self.aliases): |w%s|n\n" % self.aliases + string += "cmd locks (self.locks): |w%s|n\n" % self.locks + string += "help category (self.help_category): |w%s|n\n" % self.help_category.capitalize() + string += "object calling (self.caller): |w%s|n\n" % self.caller + string += "object storing cmdset (self.obj): |w%s|n\n" % self.obj + string += "command string given (self.cmdstring): |w%s|n\n" % self.cmdstring # show cmdset.key instead of cmdset to shorten output - string += fill("current cmdset (self.cmdset): {w%s{n\n" % (self.cmdset.key if self.cmdset.key else self.cmdset.__class__)) + string += fill("current cmdset (self.cmdset): |w%s|n\n" % + (self.cmdset.key if self.cmdset.key else self.cmdset.__class__)) self.caller.msg(string)