Ran black on sources
This commit is contained in:
parent
7939e3cde3
commit
8b28900600
16 changed files with 115 additions and 77 deletions
|
|
@ -358,14 +358,18 @@ class CmdSet(object, metaclass=_CmdSetMeta):
|
|||
|
||||
"""
|
||||
perm = "perm" if self.permanent else "non-perm"
|
||||
options = ", ".join([
|
||||
"{}:{}".format(opt, "T" if getattr(self, opt) else "F")
|
||||
for opt in ("no_exits", "no_objs", "no_channels", "duplicates")
|
||||
if getattr(self, opt) is not None
|
||||
])
|
||||
options = ", ".join(
|
||||
[
|
||||
"{}:{}".format(opt, "T" if getattr(self, opt) else "F")
|
||||
for opt in ("no_exits", "no_objs", "no_channels", "duplicates")
|
||||
if getattr(self, opt) is not None
|
||||
]
|
||||
)
|
||||
options = (", " + options) if options else ""
|
||||
return f"<CmdSet {self.key}, {self.mergetype}, {perm}, prio {self.priority}{options}>: " + ", ".join(
|
||||
[str(cmd) for cmd in sorted(self.commands, key=lambda o: o.key)])
|
||||
return (
|
||||
f"<CmdSet {self.key}, {self.mergetype}, {perm}, prio {self.priority}{options}>: "
|
||||
+ ", ".join([str(cmd) for cmd in sorted(self.commands, key=lambda o: o.key)])
|
||||
)
|
||||
|
||||
def __iter__(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ class CmdSetHandler(object):
|
|||
|
||||
if mergelist:
|
||||
# current is a result of mergers
|
||||
mergelist="+".join(mergelist)
|
||||
mergelist = "+".join(mergelist)
|
||||
strings.append(f" <Merged {mergelist}>: {self.current}")
|
||||
else:
|
||||
# current is a single cmdset
|
||||
|
|
|
|||
|
|
@ -509,7 +509,7 @@ Command {self} has no defined `func()` - showing on-command variables:
|
|||
"SCREENWIDTH", {0: settings.CLIENT_DEFAULT_WIDTH}
|
||||
)[0]
|
||||
return settings.CLIENT_DEFAULT_WIDTH
|
||||
|
||||
|
||||
def client_height(self):
|
||||
"""
|
||||
Get the client screenheight for the session using this command.
|
||||
|
|
|
|||
|
|
@ -2516,12 +2516,14 @@ class CmdExamine(ObjManipCommand):
|
|||
|
||||
def _format_options(cmdset):
|
||||
"""helper for cmdset-option display"""
|
||||
|
||||
def _truefalse(string, value):
|
||||
if value is None:
|
||||
return ""
|
||||
if value:
|
||||
return f"{string}: T"
|
||||
return f"{string}: F"
|
||||
|
||||
options = ", ".join(
|
||||
_truefalse(opt, getattr(cmdset, opt))
|
||||
for opt in ("no_exits", "no_objs", "no_channels", "duplicates")
|
||||
|
|
@ -2538,7 +2540,8 @@ class CmdExamine(ObjManipCommand):
|
|||
continue
|
||||
options = _format_options(cmdset)
|
||||
stored.append(
|
||||
f"{cmdset.path} [{cmdset.key}] ({cmdset.mergetype}, prio {cmdset.priority}{options})")
|
||||
f"{cmdset.path} [{cmdset.key}] ({cmdset.mergetype}, prio {cmdset.priority}{options})"
|
||||
)
|
||||
output["Stored Cmdset(s)"] = "\n " + "\n ".join(stored)
|
||||
|
||||
# this gets all components of the currently merged set
|
||||
|
|
@ -2576,13 +2579,15 @@ class CmdExamine(ObjManipCommand):
|
|||
# the resulting merged cmdset
|
||||
options = _format_options(current_cmdset)
|
||||
merged = [
|
||||
f"<Current merged cmdset> ({current_cmdset.mergetype} prio {current_cmdset.priority}{options})"]
|
||||
f"<Current merged cmdset> ({current_cmdset.mergetype} prio {current_cmdset.priority}{options})"
|
||||
]
|
||||
|
||||
# the merge stack
|
||||
for cmdset in all_cmdsets:
|
||||
options = _format_options(cmdset)
|
||||
merged.append(
|
||||
f"{cmdset.path} [{cmdset.key}] ({cmdset.mergetype} prio {cmdset.priority}{options})")
|
||||
f"{cmdset.path} [{cmdset.key}] ({cmdset.mergetype} prio {cmdset.priority}{options})"
|
||||
)
|
||||
output["Merged Cmdset(s)"] = "\n " + "\n ".join(merged)
|
||||
|
||||
# list the commands available to this object
|
||||
|
|
|
|||
|
|
@ -833,7 +833,7 @@ class CmdPage(COMMAND_DEFAULT_CLASS):
|
|||
receiver = f"|n,{clr}".join([obj.name for obj in page.receivers])
|
||||
if sending:
|
||||
template = to_template
|
||||
sender = f"{sender} " if multi_send else ""
|
||||
sender = f"{sender} " if multi_send else ""
|
||||
receiver = f" {receiver}" if multi_recv else f" {receiver}"
|
||||
else:
|
||||
template = from_template
|
||||
|
|
@ -848,7 +848,6 @@ class CmdPage(COMMAND_DEFAULT_CLASS):
|
|||
receiver=receiver,
|
||||
message=page.message,
|
||||
)
|
||||
|
||||
)
|
||||
lastpages = "\n ".join(listing)
|
||||
|
||||
|
|
|
|||
|
|
@ -379,10 +379,13 @@ class CmdInventory(COMMAND_DEFAULT_CLASS):
|
|||
string = "You are not carrying anything."
|
||||
else:
|
||||
from evennia.utils.ansi import raw as raw_ansi
|
||||
|
||||
table = self.styled_table(border="header")
|
||||
for item in items:
|
||||
table.add_row(f"|C{item.name}|n",
|
||||
"{}|n".format(utils.crop(raw_ansi(item.db.desc), width=50) or ""))
|
||||
table.add_row(
|
||||
f"|C{item.name}|n",
|
||||
"{}|n".format(utils.crop(raw_ansi(item.db.desc), width=50) or ""),
|
||||
)
|
||||
string = f"|wYou are carrying:\n{table}"
|
||||
self.caller.msg(string)
|
||||
|
||||
|
|
|
|||
|
|
@ -222,8 +222,11 @@ class CmdHelp(Command):
|
|||
# system, but not be displayed in the table, or be displayed differently.
|
||||
for cmd in all_cmds:
|
||||
if self.should_list_cmd(cmd, caller):
|
||||
key = (cmd.auto_help_display_key
|
||||
if hasattr(cmd, "auto_help_display_key") else cmd.key)
|
||||
key = (
|
||||
cmd.auto_help_display_key
|
||||
if hasattr(cmd, "auto_help_display_key")
|
||||
else cmd.key
|
||||
)
|
||||
hdict_cmd[cmd.help_category].append(key)
|
||||
[hdict_topic[topic.help_category].append(topic.key) for topic in all_topics]
|
||||
# report back
|
||||
|
|
@ -271,10 +274,7 @@ class CmdHelp(Command):
|
|||
cmd = match[0]
|
||||
key = cmd.auto_help_display_key if hasattr(cmd, "auto_help_display_key") else cmd.key
|
||||
formatted = self.format_help_entry(
|
||||
key,
|
||||
cmd.get_help(caller, cmdset),
|
||||
aliases=cmd.aliases,
|
||||
suggested=suggestions,
|
||||
key, cmd.get_help(caller, cmdset), aliases=cmd.aliases, suggested=suggestions,
|
||||
)
|
||||
self.msg_help(formatted)
|
||||
return
|
||||
|
|
@ -294,10 +294,16 @@ class CmdHelp(Command):
|
|||
# try to see if a category name was entered
|
||||
if query in all_categories:
|
||||
self.msg_help(
|
||||
self.format_help_list({
|
||||
query: [
|
||||
cmd.auto_help_display_key if hasattr(cmd, "auto_help_display_key") else cmd.key
|
||||
for cmd in all_cmds if cmd.help_category == query]},
|
||||
self.format_help_list(
|
||||
{
|
||||
query: [
|
||||
cmd.auto_help_display_key
|
||||
if hasattr(cmd, "auto_help_display_key")
|
||||
else cmd.key
|
||||
for cmd in all_cmds
|
||||
if cmd.help_category == query
|
||||
]
|
||||
},
|
||||
{query: [topic.key for topic in all_topics if topic.help_category == query]},
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -971,8 +971,11 @@ class TestBuilding(CommandTest):
|
|||
self.call(building.CmdSetHome(), "Obj = Room2", "Home location of Obj was set to Room")
|
||||
|
||||
def test_list_cmdsets(self):
|
||||
self.call(building.CmdListCmdSets(), "",
|
||||
"<CmdSetHandler> stack:\n <CmdSet DefaultCharacter, Union, perm, prio 0>:")
|
||||
self.call(
|
||||
building.CmdListCmdSets(),
|
||||
"",
|
||||
"<CmdSetHandler> stack:\n <CmdSet DefaultCharacter, Union, perm, prio 0>:",
|
||||
)
|
||||
self.call(building.CmdListCmdSets(), "NotFound", "Could not find 'NotFound'")
|
||||
|
||||
def test_typeclass(self):
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ class TestOptionTransferTrue(TestCase):
|
|||
b.no_objs = False
|
||||
d.duplicates = False
|
||||
# higher-prio sets will change the option up the chain
|
||||
cmdset_f = d + c + b + a # reverse, high prio
|
||||
cmdset_f = d + c + b + a # reverse, high prio
|
||||
self.assertTrue(cmdset_f.no_exits)
|
||||
self.assertTrue(cmdset_f.no_objs)
|
||||
self.assertTrue(cmdset_f.no_channels)
|
||||
|
|
@ -407,7 +407,7 @@ class TestOptionTransferTrue(TestCase):
|
|||
c.priority = 1
|
||||
d.priority = 2
|
||||
c.no_exits = False
|
||||
c.no_channels = None # passthrough
|
||||
c.no_channels = None # passthrough
|
||||
b.no_objs = False
|
||||
d.duplicates = False
|
||||
# higher-prio sets will change the option up the chain
|
||||
|
|
@ -639,7 +639,7 @@ class TestOptionTransferFalse(TestCase):
|
|||
b.no_objs = True
|
||||
d.duplicates = True
|
||||
# higher-prio sets will change the option up the chain
|
||||
cmdset_f = d + c + b + a # reverse, high prio
|
||||
cmdset_f = d + c + b + a # reverse, high prio
|
||||
self.assertFalse(cmdset_f.no_exits)
|
||||
self.assertFalse(cmdset_f.no_objs)
|
||||
self.assertFalse(cmdset_f.no_channels)
|
||||
|
|
@ -663,7 +663,7 @@ class TestOptionTransferFalse(TestCase):
|
|||
b.no_objs = True
|
||||
d.duplicates = True
|
||||
# higher-prio sets will change the option up the chain
|
||||
cmdset_f = a + b + c + d # forward, high prio, never happens
|
||||
cmdset_f = a + b + c + d # forward, high prio, never happens
|
||||
self.assertFalse(cmdset_f.no_exits)
|
||||
self.assertFalse(cmdset_f.no_objs)
|
||||
self.assertFalse(cmdset_f.no_channels)
|
||||
|
|
@ -707,7 +707,7 @@ class TestOptionTransferFalse(TestCase):
|
|||
c.priority = 1
|
||||
d.priority = 2
|
||||
c.no_exits = True
|
||||
c.no_channels = None # passthrough
|
||||
c.no_channels = None # passthrough
|
||||
b.no_objs = True
|
||||
d.duplicates = True
|
||||
# higher-prio sets will change the option up the chain
|
||||
|
|
@ -908,6 +908,7 @@ class TestOptionTransferReplace(TestCase):
|
|||
"""
|
||||
Test option transfer through more complex merge types.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.cmdset_a = _CmdSetA()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue