Apply black
This commit is contained in:
parent
0ba91ee07f
commit
89d1336cda
15 changed files with 64 additions and 22 deletions
|
|
@ -4,6 +4,7 @@ General Character commands usually available to all characters
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from evennia.typeclasses.attributes import NickTemplateInvalid
|
from evennia.typeclasses.attributes import NickTemplateInvalid
|
||||||
from evennia.utils import utils
|
from evennia.utils import utils
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,9 @@ with which to test the system:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from evennia import DefaultCharacter, DefaultObject, default_cmds
|
from evennia import DefaultCharacter, DefaultObject, default_cmds
|
||||||
from evennia.commands.default.muxcommand import MuxCommand
|
from evennia.commands.default.muxcommand import MuxCommand
|
||||||
from evennia.utils import at_search_result, evtable, inherits_from, iter_to_str
|
from evennia.utils import at_search_result, evtable, inherits_from, iter_to_str
|
||||||
|
|
|
||||||
|
|
@ -123,8 +123,9 @@ from evennia import (
|
||||||
create_object,
|
create_object,
|
||||||
create_script,
|
create_script,
|
||||||
)
|
)
|
||||||
from evennia.utils import inherits_from
|
|
||||||
from evennia.typeclasses.attributes import AttributeProperty
|
from evennia.typeclasses.attributes import AttributeProperty
|
||||||
|
from evennia.utils import inherits_from
|
||||||
|
|
||||||
|
|
||||||
def create_wilderness(name="default", mapprovider=None, preserve_items=False):
|
def create_wilderness(name="default", mapprovider=None, preserve_items=False):
|
||||||
"""
|
"""
|
||||||
|
|
@ -218,7 +219,7 @@ class WildernessScript(DefaultScript):
|
||||||
# Stores a dictionary of items on the map with their coordinates
|
# Stores a dictionary of items on the map with their coordinates
|
||||||
# The key is the item, the value are the coordinates as (x, y) tuple.
|
# The key is the item, the value are the coordinates as (x, y) tuple.
|
||||||
itemcoordinates = AttributeProperty()
|
itemcoordinates = AttributeProperty()
|
||||||
|
|
||||||
# Determines whether or not rooms are recycled despite containing non-player objects
|
# Determines whether or not rooms are recycled despite containing non-player objects
|
||||||
# True means that leaving behind a non-player object will prevent the room from being recycled
|
# True means that leaving behind a non-player object will prevent the room from being recycled
|
||||||
# in order to preserve the object
|
# in order to preserve the object
|
||||||
|
|
@ -243,7 +244,7 @@ class WildernessScript(DefaultScript):
|
||||||
# allows quick retrieval if a new room is needed without having to
|
# allows quick retrieval if a new room is needed without having to
|
||||||
# create it.
|
# create it.
|
||||||
self.db.unused_rooms = []
|
self.db.unused_rooms = []
|
||||||
|
|
||||||
def at_server_start(self):
|
def at_server_start(self):
|
||||||
"""
|
"""
|
||||||
Called after the server is started or reloaded.
|
Called after the server is started or reloaded.
|
||||||
|
|
@ -300,7 +301,11 @@ class WildernessScript(DefaultScript):
|
||||||
Returns:
|
Returns:
|
||||||
[Object, ]: list of Objects at coordinates
|
[Object, ]: list of Objects at coordinates
|
||||||
"""
|
"""
|
||||||
result = [ item for item, item_coords in self.itemcoordinates.items() if item_coords == coordinates and item is not None ]
|
result = [
|
||||||
|
item
|
||||||
|
for item, item_coords in self.itemcoordinates.items()
|
||||||
|
if item_coords == coordinates and item is not None
|
||||||
|
]
|
||||||
return list(result)
|
return list(result)
|
||||||
|
|
||||||
def move_obj(self, obj, new_coordinates):
|
def move_obj(self, obj, new_coordinates):
|
||||||
|
|
@ -335,7 +340,13 @@ class WildernessScript(DefaultScript):
|
||||||
# Should we preserve rooms with any objects?
|
# Should we preserve rooms with any objects?
|
||||||
if self.preserve_items:
|
if self.preserve_items:
|
||||||
# Yes - check if ANY objects besides the exits are in old_room
|
# Yes - check if ANY objects besides the exits are in old_room
|
||||||
if len([ob for ob in old_room.contents if not inherits_from(ob, WildernessExit)]):
|
if len(
|
||||||
|
[
|
||||||
|
ob
|
||||||
|
for ob in old_room.contents
|
||||||
|
if not inherits_from(ob, WildernessExit)
|
||||||
|
]
|
||||||
|
):
|
||||||
# There is, so we'll create a new room
|
# There is, so we'll create a new room
|
||||||
room = self._create_room(new_coordinates, obj)
|
room = self._create_room(new_coordinates, obj)
|
||||||
else:
|
else:
|
||||||
|
|
@ -423,7 +434,7 @@ class WildernessScript(DefaultScript):
|
||||||
"""
|
"""
|
||||||
Moves a room back to storage. If room is not a WildernessRoom or there
|
Moves a room back to storage. If room is not a WildernessRoom or there
|
||||||
is something left inside the room, then this does nothing.
|
is something left inside the room, then this does nothing.
|
||||||
|
|
||||||
Implementation note: If `preserve_items` is False (the default) then any
|
Implementation note: If `preserve_items` is False (the default) then any
|
||||||
objects left in the rooms will be moved to None. You may want to implement
|
objects left in the rooms will be moved to None. You may want to implement
|
||||||
your own cleanup or recycling routine for these objects.
|
your own cleanup or recycling routine for these objects.
|
||||||
|
|
@ -625,11 +636,11 @@ class WildernessRoom(DefaultRoom):
|
||||||
|
|
||||||
name += " {0}".format(self.coordinates)
|
name += " {0}".format(self.coordinates)
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def get_display_desc(self, looker, **kwargs):
|
def get_display_desc(self, looker, **kwargs):
|
||||||
"""
|
"""
|
||||||
Displays the description of the room. This is a core evennia hook.
|
Displays the description of the room. This is a core evennia hook.
|
||||||
|
|
||||||
Allows the room's description to be customized in an ndb value,
|
Allows the room's description to be customized in an ndb value,
|
||||||
avoiding having to write to the database on moving.
|
avoiding having to write to the database on moving.
|
||||||
"""
|
"""
|
||||||
|
|
@ -641,6 +652,7 @@ class WildernessRoom(DefaultRoom):
|
||||||
# Otherwise, use the normal description hook.
|
# Otherwise, use the normal description hook.
|
||||||
return super().get_display_desc(looker, **kwargs)
|
return super().get_display_desc(looker, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class WildernessExit(DefaultExit):
|
class WildernessExit(DefaultExit):
|
||||||
"""
|
"""
|
||||||
This is an Exit object used inside a WildernessRoom. Instead of changing
|
This is an Exit object used inside a WildernessRoom. Instead of changing
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.test import override_settings
|
from django.test import override_settings
|
||||||
|
|
||||||
from evennia import DefaultCharacter
|
from evennia import DefaultCharacter
|
||||||
from evennia.commands.default import account
|
from evennia.commands.default import account
|
||||||
from evennia.utils import inherits_from
|
from evennia.utils import inherits_from
|
||||||
|
|
|
||||||
|
|
@ -149,9 +149,10 @@ Extra Installation Instructions:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
from string import punctuation
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from string import punctuation
|
||||||
|
|
||||||
|
import inflect
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from evennia.commands.cmdset import CmdSet
|
from evennia.commands.cmdset import CmdSet
|
||||||
|
|
@ -159,9 +160,13 @@ from evennia.commands.command import Command
|
||||||
from evennia.objects.models import ObjectDB
|
from evennia.objects.models import ObjectDB
|
||||||
from evennia.objects.objects import DefaultCharacter, DefaultObject
|
from evennia.objects.objects import DefaultCharacter, DefaultObject
|
||||||
from evennia.utils import ansi, logger
|
from evennia.utils import ansi, logger
|
||||||
from evennia.utils.utils import iter_to_str, lazy_property, make_iter, variable_from_module
|
from evennia.utils.utils import (
|
||||||
|
iter_to_str,
|
||||||
|
lazy_property,
|
||||||
|
make_iter,
|
||||||
|
variable_from_module,
|
||||||
|
)
|
||||||
|
|
||||||
import inflect
|
|
||||||
_INFLECT = inflect.engine()
|
_INFLECT = inflect.engine()
|
||||||
|
|
||||||
_AT_SEARCH_RESULT = variable_from_module(*settings.SEARCH_AT_RESULT.rsplit(".", 1))
|
_AT_SEARCH_RESULT = variable_from_module(*settings.SEARCH_AT_RESULT.rsplit(".", 1))
|
||||||
|
|
@ -1525,6 +1530,7 @@ class ContribRPObject(DefaultObject):
|
||||||
"""
|
"""
|
||||||
Get the ‘characters’ component of the object description. Called by return_appearance.
|
Get the ‘characters’ component of the object description. Called by return_appearance.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _filter_visible(obj_list):
|
def _filter_visible(obj_list):
|
||||||
return (obj for obj in obj_list if obj != looker and obj.access(looker, "view"))
|
return (obj for obj in obj_list if obj != looker and obj.access(looker, "view"))
|
||||||
|
|
||||||
|
|
@ -1533,7 +1539,7 @@ class ContribRPObject(DefaultObject):
|
||||||
char.get_display_name(looker, pose=pose, **kwargs) for char in characters
|
char.get_display_name(looker, pose=pose, **kwargs) for char in characters
|
||||||
)
|
)
|
||||||
|
|
||||||
return f"\n{character_names}" if character_names else ""
|
return f"\n{character_names}" if character_names else ""
|
||||||
|
|
||||||
def get_display_things(self, looker, pose=True, **kwargs):
|
def get_display_things(self, looker, pose=True, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
@ -1562,9 +1568,9 @@ class ContribRPObject(DefaultObject):
|
||||||
if not pose:
|
if not pose:
|
||||||
pose = ""
|
pose = ""
|
||||||
posed_things[pose].append(thing)
|
posed_things[pose].append(thing)
|
||||||
|
|
||||||
display_strings = []
|
display_strings = []
|
||||||
|
|
||||||
for pose, thinglist in posed_things.items():
|
for pose, thinglist in posed_things.items():
|
||||||
grouped_things = defaultdict(list)
|
grouped_things = defaultdict(list)
|
||||||
for thing in thinglist:
|
for thing in thinglist:
|
||||||
|
|
@ -1588,7 +1594,7 @@ class ContribRPObject(DefaultObject):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
return "\n" + "\n".join(display_strings)
|
return "\n" + "\n".join(display_strings)
|
||||||
|
|
||||||
|
|
||||||
class ContribRPRoom(ContribRPObject):
|
class ContribRPRoom(ContribRPObject):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ EvAdventure character generation.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from evennia import create_object
|
from evennia import create_object
|
||||||
from evennia.objects.models import ObjectDB
|
from evennia.objects.models import ObjectDB
|
||||||
from evennia.prototypes.spawner import spawn
|
from evennia.prototypes.spawner import spawn
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,10 @@ Test chargen.
|
||||||
|
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
from parameterized import parameterized
|
||||||
|
|
||||||
from evennia import create_object
|
from evennia import create_object
|
||||||
from evennia.utils.test_resources import BaseEvenniaTest
|
from evennia.utils.test_resources import BaseEvenniaTest
|
||||||
from parameterized import parameterized
|
|
||||||
|
|
||||||
from .. import chargen, enums, objects
|
from .. import chargen, enums, objects
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ from django.conf import settings
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from evennia.locks.lockhandler import check_lockstring, validate_lockstring
|
from evennia.locks.lockhandler import check_lockstring, validate_lockstring
|
||||||
from evennia.objects.models import ObjectDB
|
from evennia.objects.models import ObjectDB
|
||||||
from evennia.scripts.scripts import DefaultScript
|
from evennia.scripts.scripts import DefaultScript
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,13 @@ call the handler's `save()` and `restore()` methods when the server reboots.
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
|
from twisted.internet.defer import inlineCallbacks
|
||||||
|
|
||||||
from evennia.scripts.scripts import ExtendedLoopingCall
|
from evennia.scripts.scripts import ExtendedLoopingCall
|
||||||
from evennia.server.models import ServerConfig
|
from evennia.server.models import ServerConfig
|
||||||
from evennia.utils import inherits_from, variable_from_module
|
from evennia.utils import inherits_from, variable_from_module
|
||||||
from evennia.utils.dbserialize import dbserialize, dbunserialize, pack_dbobj
|
from evennia.utils.dbserialize import dbserialize, dbunserialize, pack_dbobj
|
||||||
from evennia.utils.logger import log_err, log_trace
|
from evennia.utils.logger import log_err, log_trace
|
||||||
from twisted.internet.defer import inlineCallbacks
|
|
||||||
|
|
||||||
_GA = object.__getattribute__
|
_GA = object.__getattribute__
|
||||||
_SA = object.__setattr__
|
_SA = object.__setattr__
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import shlex
|
||||||
|
|
||||||
from django.db.models import Count, ExpressionWrapper, F, FloatField, Q
|
from django.db.models import Count, ExpressionWrapper, F, FloatField, Q
|
||||||
from django.db.models.functions import Cast
|
from django.db.models.functions import Cast
|
||||||
|
|
||||||
from evennia.typeclasses.attributes import Attribute
|
from evennia.typeclasses.attributes import Attribute
|
||||||
from evennia.typeclasses.tags import Tag
|
from evennia.typeclasses.tags import Tag
|
||||||
from evennia.utils import idmapper
|
from evennia.utils import idmapper
|
||||||
|
|
|
||||||
|
|
@ -273,12 +273,22 @@ from django.conf import settings
|
||||||
|
|
||||||
# i18n
|
# i18n
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from evennia import CmdSet, Command
|
from evennia import CmdSet, Command
|
||||||
from evennia.commands import cmdhandler
|
from evennia.commands import cmdhandler
|
||||||
from evennia.utils import logger
|
from evennia.utils import logger
|
||||||
from evennia.utils.ansi import strip_ansi
|
from evennia.utils.ansi import strip_ansi
|
||||||
from evennia.utils.evtable import EvColumn, EvTable
|
from evennia.utils.evtable import EvColumn, EvTable
|
||||||
from evennia.utils.utils import crop, dedent, is_iter, m_len, make_iter, mod_import, pad, to_str
|
from evennia.utils.utils import (
|
||||||
|
crop,
|
||||||
|
dedent,
|
||||||
|
is_iter,
|
||||||
|
m_len,
|
||||||
|
make_iter,
|
||||||
|
mod_import,
|
||||||
|
pad,
|
||||||
|
to_str,
|
||||||
|
)
|
||||||
|
|
||||||
# read from protocol NAWS later?
|
# read from protocol NAWS later?
|
||||||
_MAX_TEXT_WIDTH = settings.CLIENT_DEFAULT_WIDTH
|
_MAX_TEXT_WIDTH = settings.CLIENT_DEFAULT_WIDTH
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ from copy import copy, deepcopy
|
||||||
from textwrap import TextWrapper
|
from textwrap import TextWrapper
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from evennia.utils.ansi import ANSIString
|
from evennia.utils.ansi import ANSIString
|
||||||
from evennia.utils.utils import display_len as d_len
|
from evennia.utils.utils import display_len as d_len
|
||||||
from evennia.utils.utils import is_iter, justify
|
from evennia.utils.utils import is_iter, justify
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,12 @@ from datetime import datetime, timedelta
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from parameterized import parameterized
|
||||||
|
from twisted.internet import task
|
||||||
|
|
||||||
from evennia.utils import utils
|
from evennia.utils import utils
|
||||||
from evennia.utils.ansi import ANSIString
|
from evennia.utils.ansi import ANSIString
|
||||||
from evennia.utils.test_resources import BaseEvenniaTest
|
from evennia.utils.test_resources import BaseEvenniaTest
|
||||||
from parameterized import parameterized
|
|
||||||
from twisted.internet import task
|
|
||||||
|
|
||||||
|
|
||||||
class TestIsIter(TestCase):
|
class TestIsIter(TestCase):
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,13 @@ from django.core.validators import validate_email as django_validate_email
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.html import strip_tags
|
from django.utils.html import strip_tags
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from evennia.utils import logger
|
|
||||||
from simpleeval import simple_eval
|
from simpleeval import simple_eval
|
||||||
from twisted.internet import reactor, threads
|
from twisted.internet import reactor, threads
|
||||||
from twisted.internet.defer import returnValue # noqa - used as import target
|
from twisted.internet.defer import returnValue # noqa - used as import target
|
||||||
from twisted.internet.task import deferLater
|
from twisted.internet.task import deferLater
|
||||||
|
|
||||||
|
from evennia.utils import logger
|
||||||
|
|
||||||
_MULTIMATCH_TEMPLATE = settings.SEARCH_MULTIMATCH_TEMPLATE
|
_MULTIMATCH_TEMPLATE = settings.SEARCH_MULTIMATCH_TEMPLATE
|
||||||
_EVENNIA_DIR = settings.EVENNIA_DIR
|
_EVENNIA_DIR = settings.EVENNIA_DIR
|
||||||
_GAME_DIR = settings.GAME_DIR
|
_GAME_DIR = settings.GAME_DIR
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@ Unit tests for verb conjugation.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from parameterized import parameterized
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from parameterized import parameterized
|
||||||
|
|
||||||
from . import conjugate, pronouns
|
from . import conjugate, pronouns
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue