Ran black on sources
This commit is contained in:
parent
49330826f3
commit
fd39935d19
9 changed files with 56 additions and 29 deletions
|
|
@ -638,8 +638,8 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
|
||||||
flags[new_name] = new_val
|
flags[new_name] = new_val
|
||||||
|
|
||||||
# If we're manually assign a display size, turn off auto-resizing
|
# If we're manually assign a display size, turn off auto-resizing
|
||||||
if new_name in ['SCREENWIDTH', 'SCREENHEIGHT']:
|
if new_name in ["SCREENWIDTH", "SCREENHEIGHT"]:
|
||||||
flags['AUTORESIZE'] = False
|
flags["AUTORESIZE"] = False
|
||||||
|
|
||||||
self.msg(
|
self.msg(
|
||||||
f"Option |w{new_name}|n was changed from '|w{old_val}|n' to"
|
f"Option |w{new_name}|n was changed from '|w{old_val}|n' to"
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@ Building and world design commands
|
||||||
import re
|
import re
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
import evennia
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from django.db.models import Max, Min, Q
|
from django.db.models import Max, Min, Q
|
||||||
|
|
||||||
|
import evennia
|
||||||
from evennia import InterruptCommand
|
from evennia import InterruptCommand
|
||||||
from evennia.commands.cmdhandler import (generate_cmdset_providers,
|
from evennia.commands.cmdhandler import generate_cmdset_providers, get_and_merge_cmdsets
|
||||||
get_and_merge_cmdsets)
|
|
||||||
from evennia.locks.lockhandler import LockException
|
from evennia.locks.lockhandler import LockException
|
||||||
from evennia.objects.models import ObjectDB
|
from evennia.objects.models import ObjectDB
|
||||||
from evennia.prototypes import menus as olc_menus
|
from evennia.prototypes import menus as olc_menus
|
||||||
|
|
@ -24,10 +24,18 @@ from evennia.utils.dbserialize import deserialize
|
||||||
from evennia.utils.eveditor import EvEditor
|
from evennia.utils.eveditor import EvEditor
|
||||||
from evennia.utils.evmore import EvMore
|
from evennia.utils.evmore import EvMore
|
||||||
from evennia.utils.evtable import EvTable
|
from evennia.utils.evtable import EvTable
|
||||||
from evennia.utils.utils import (class_from_module, crop, dbref, display_len,
|
from evennia.utils.utils import (
|
||||||
format_grid, get_all_typeclasses,
|
class_from_module,
|
||||||
inherits_from, interactive, list_to_string,
|
crop,
|
||||||
variable_from_module)
|
dbref,
|
||||||
|
display_len,
|
||||||
|
format_grid,
|
||||||
|
get_all_typeclasses,
|
||||||
|
inherits_from,
|
||||||
|
interactive,
|
||||||
|
list_to_string,
|
||||||
|
variable_from_module,
|
||||||
|
)
|
||||||
|
|
||||||
COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
|
COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
|
||||||
|
|
||||||
|
|
@ -170,7 +178,7 @@ class ObjManipCommand(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
def get_object_typeclass(
|
def get_object_typeclass(
|
||||||
self, obj_type: str = "object", typeclass: str = None, method: str = "cmd_create", **kwargs
|
self, obj_type: str = "object", typeclass: str = None, method: str = "cmd_create", **kwargs
|
||||||
) -> tuple[typing.Optional['Typeclass'], list[str]]:
|
) -> tuple[typing.Optional["Typeclass"], list[str]]:
|
||||||
"""
|
"""
|
||||||
This hook is called by build commands to determine which typeclass to use for a specific
|
This hook is called by build commands to determine which typeclass to use for a specific
|
||||||
purpose.
|
purpose.
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ Communication commands:
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
|
||||||
from evennia.accounts import bots
|
from evennia.accounts import bots
|
||||||
from evennia.accounts.models import AccountDB
|
from evennia.accounts.models import AccountDB
|
||||||
from evennia.comms.comms import DefaultChannel
|
from evennia.comms.comms import DefaultChannel
|
||||||
|
|
|
||||||
|
|
@ -1039,7 +1039,7 @@ class CmdSetHelp(CmdHelp):
|
||||||
old_entry.locks.add(lockstring)
|
old_entry.locks.add(lockstring)
|
||||||
except LockException as e:
|
except LockException as e:
|
||||||
old_entry.locks.add(existing_locks)
|
old_entry.locks.add(existing_locks)
|
||||||
self.msg(str(e) + " Locks not changed.")
|
self.msg(str(e) + " Locks not changed.")
|
||||||
else:
|
else:
|
||||||
self.msg(f"Locks for entry '{topicstr}'{aliastxt} changed to: {lockstring}")
|
self.msg(f"Locks for entry '{topicstr}'{aliastxt} changed to: {lockstring}")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,13 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Do we have a NAWS update?
|
# Do we have a NAWS update?
|
||||||
if (NAWS in data and
|
if (
|
||||||
len([data[i:i+1] for i in range(0, len(data))]) == 9 and
|
NAWS in data
|
||||||
# Is auto resizing on?
|
and len([data[i : i + 1] for i in range(0, len(data))]) == 9
|
||||||
self.protocol_flags.get('AUTORESIZE')):
|
and
|
||||||
|
# Is auto resizing on?
|
||||||
|
self.protocol_flags.get("AUTORESIZE")
|
||||||
|
):
|
||||||
self.sessionhandler.sync(self.sessionhandler.get(self.sessid))
|
self.sessionhandler.sync(self.sessionhandler.get(self.sessid))
|
||||||
|
|
||||||
super().dataReceived(data)
|
super().dataReceived(data)
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,9 @@ class TelnetOOB:
|
||||||
gmcp_cmdname = EVENNIA_TO_GMCP[cmdname]
|
gmcp_cmdname = EVENNIA_TO_GMCP[cmdname]
|
||||||
elif "_" in cmdname:
|
elif "_" in cmdname:
|
||||||
# enforce initial capitalization of each command part, leaving fully-capitalized sections intact
|
# enforce initial capitalization of each command part, leaving fully-capitalized sections intact
|
||||||
gmcp_cmdname = ".".join(word.capitalize() if not word.isupper() else word for word in cmdname.split("_"))
|
gmcp_cmdname = ".".join(
|
||||||
|
word.capitalize() if not word.isupper() else word for word in cmdname.split("_")
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
gmcp_cmdname = "Core.%s" % (cmdname if cmdname.istitle() else cmdname.capitalize())
|
gmcp_cmdname = "Core.%s" % (cmdname if cmdname.istitle() else cmdname.capitalize())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1366,7 +1366,9 @@ def funcparser_callable_conjugate(*args, caller=None, receiver=None, mapping=Non
|
||||||
return second_person_str if obj == receiver else third_person_str
|
return second_person_str if obj == receiver else third_person_str
|
||||||
|
|
||||||
|
|
||||||
def funcparser_callable_conjugate_for_pronouns(*args, caller=None, receiver=None, mapping=None, **kwargs):
|
def funcparser_callable_conjugate_for_pronouns(
|
||||||
|
*args, caller=None, receiver=None, mapping=None, **kwargs
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Usage: $pconj(word, [key])
|
Usage: $pconj(word, [key])
|
||||||
|
|
||||||
|
|
@ -1414,15 +1416,17 @@ def funcparser_callable_conjugate_for_pronouns(*args, caller=None, receiver=None
|
||||||
plural = False
|
plural = False
|
||||||
if hasattr(obj, "gender"):
|
if hasattr(obj, "gender"):
|
||||||
if callable(obj.gender):
|
if callable(obj.gender):
|
||||||
plural = (obj.gender() == "plural")
|
plural = obj.gender() == "plural"
|
||||||
else:
|
else:
|
||||||
plural = (obj.gender == "plural")
|
plural = obj.gender == "plural"
|
||||||
|
|
||||||
second_person_str, third_person_str = verb_actor_stance_components(verb, plural=plural)
|
second_person_str, third_person_str = verb_actor_stance_components(verb, plural=plural)
|
||||||
return second_person_str if obj == receiver else third_person_str
|
return second_person_str if obj == receiver else third_person_str
|
||||||
|
|
||||||
|
|
||||||
def funcparser_callable_pronoun(*args, caller=None, receiver=None, mapping=None, capitalize=False, **kwargs):
|
def funcparser_callable_pronoun(
|
||||||
|
*args, caller=None, receiver=None, mapping=None, capitalize=False, **kwargs
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Usage: $pron(word, [options], [key])
|
Usage: $pron(word, [options], [key])
|
||||||
|
|
|
||||||
|
|
@ -435,7 +435,11 @@ class TestDefaultCallables(TestCase):
|
||||||
("$You() $conj(smile) at him.", "You smile at him.", "Char1 smiles at him."),
|
("$You() $conj(smile) at him.", "You smile at him.", "Char1 smiles at him."),
|
||||||
("$You() $conj(smile) at $You(char1).", "You smile at You.", "Char1 smiles at Char1."),
|
("$You() $conj(smile) at $You(char1).", "You smile at You.", "Char1 smiles at Char1."),
|
||||||
("$You() $conj(smile) at $You(char2).", "You smile at Char2.", "Char1 smiles at You."),
|
("$You() $conj(smile) at $You(char2).", "You smile at Char2.", "Char1 smiles at You."),
|
||||||
("$You() $conj(smile) while $You(char2) $conj(waves, char2).", "You smile while Char2 waves.", "Char1 smiles while You wave."),
|
(
|
||||||
|
"$You() $conj(smile) while $You(char2) $conj(waves, char2).",
|
||||||
|
"You smile while Char2 waves.",
|
||||||
|
"Char1 smiles while You wave.",
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"$You(char2) $conj(smile) at $you(char1).",
|
"$You(char2) $conj(smile) at $you(char1).",
|
||||||
"Char2 smile at you.",
|
"Char2 smile at you.",
|
||||||
|
|
@ -519,7 +523,12 @@ class TestDefaultCallables(TestCase):
|
||||||
|
|
||||||
string = "Char1 raises $pron(your, char1) fist as Char2 raises $pron(yours, char2)"
|
string = "Char1 raises $pron(your, char1) fist as Char2 raises $pron(yours, char2)"
|
||||||
expected = "Char1 raises her fist as Char2 raises his"
|
expected = "Char1 raises her fist as Char2 raises his"
|
||||||
ret = self.parser.parse(string, caller=self.obj1, mapping={'char1': self.obj1, 'char2': self.obj2}, raise_errors=True)
|
ret = self.parser.parse(
|
||||||
|
string,
|
||||||
|
caller=self.obj1,
|
||||||
|
mapping={"char1": self.obj1, "char2": self.obj2},
|
||||||
|
raise_errors=True,
|
||||||
|
)
|
||||||
self.assertEqual(expected, ret)
|
self.assertEqual(expected, ret)
|
||||||
|
|
||||||
def test_pronoun_viewpoint(self):
|
def test_pronoun_viewpoint(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue