Apply black

This commit is contained in:
Griatch 2022-11-28 19:55:02 +01:00
parent 0ba91ee07f
commit 89d1336cda
15 changed files with 64 additions and 22 deletions

View file

@ -73,7 +73,9 @@ with which to test the system:
"""
from collections import defaultdict
from django.conf import settings
from evennia import DefaultCharacter, DefaultObject, default_cmds
from evennia.commands.default.muxcommand import MuxCommand
from evennia.utils import at_search_result, evtable, inherits_from, iter_to_str

View file

@ -123,8 +123,9 @@ from evennia import (
create_object,
create_script,
)
from evennia.utils import inherits_from
from evennia.typeclasses.attributes import AttributeProperty
from evennia.utils import inherits_from
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
# The key is the item, the value are the coordinates as (x, y) tuple.
itemcoordinates = AttributeProperty()
# 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
# 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
# create it.
self.db.unused_rooms = []
def at_server_start(self):
"""
Called after the server is started or reloaded.
@ -300,7 +301,11 @@ class WildernessScript(DefaultScript):
Returns:
[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)
def move_obj(self, obj, new_coordinates):
@ -335,7 +340,13 @@ class WildernessScript(DefaultScript):
# Should we preserve rooms with any objects?
if self.preserve_items:
# 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
room = self._create_room(new_coordinates, obj)
else:
@ -423,7 +434,7 @@ class WildernessScript(DefaultScript):
"""
Moves a room back to storage. If room is not a WildernessRoom or there
is something left inside the room, then this does nothing.
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
your own cleanup or recycling routine for these objects.
@ -625,11 +636,11 @@ class WildernessRoom(DefaultRoom):
name += " {0}".format(self.coordinates)
return name
def get_display_desc(self, looker, **kwargs):
"""
Displays the description of the room. This is a core evennia hook.
Allows the room's description to be customized in an ndb value,
avoiding having to write to the database on moving.
"""
@ -641,6 +652,7 @@ class WildernessRoom(DefaultRoom):
# Otherwise, use the normal description hook.
return super().get_display_desc(looker, **kwargs)
class WildernessExit(DefaultExit):
"""
This is an Exit object used inside a WildernessRoom. Instead of changing

View file

@ -1,6 +1,8 @@
from unittest.mock import patch
from django.conf import settings
from django.test import override_settings
from evennia import DefaultCharacter
from evennia.commands.default import account
from evennia.utils import inherits_from

View file

@ -149,9 +149,10 @@ Extra Installation Instructions:
"""
import re
from string import punctuation
from collections import defaultdict
from string import punctuation
import inflect
from django.conf import settings
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.objects import DefaultCharacter, DefaultObject
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()
_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.
"""
def _filter_visible(obj_list):
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
)
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):
"""
@ -1562,9 +1568,9 @@ class ContribRPObject(DefaultObject):
if not pose:
pose = ""
posed_things[pose].append(thing)
display_strings = []
for pose, thinglist in posed_things.items():
grouped_things = defaultdict(list)
for thing in thinglist:
@ -1588,7 +1594,7 @@ class ContribRPObject(DefaultObject):
return ""
return "\n" + "\n".join(display_strings)
class ContribRPRoom(ContribRPObject):
"""

View file

@ -3,6 +3,7 @@ EvAdventure character generation.
"""
from django.conf import settings
from evennia import create_object
from evennia.objects.models import ObjectDB
from evennia.prototypes.spawner import spawn

View file

@ -5,9 +5,10 @@ Test chargen.
from unittest.mock import MagicMock, patch
from parameterized import parameterized
from evennia import create_object
from evennia.utils.test_resources import BaseEvenniaTest
from parameterized import parameterized
from .. import chargen, enums, objects