Run black reformatter on code
This commit is contained in:
parent
4582eb4085
commit
bd3e31bf3c
178 changed files with 4511 additions and 3385 deletions
|
|
@ -165,7 +165,9 @@ def check_location(storage):
|
|||
correct = storage.location.lstrip("/")
|
||||
raise ImproperlyConfigured(
|
||||
"{}.location cannot begin with a leading slash. Found '{}'. Use '{}' instead.".format(
|
||||
storage.__class__.__name__, storage.location, correct,
|
||||
storage.__class__.__name__,
|
||||
storage.location,
|
||||
correct,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,11 @@ class S3Boto3StorageTests(S3Boto3TestCase):
|
|||
|
||||
obj = self.storage.bucket.Object.return_value
|
||||
obj.upload_fileobj.assert_called_with(
|
||||
content, ExtraArgs={"ContentType": "text/plain", "ACL": self.storage.default_acl,}
|
||||
content,
|
||||
ExtraArgs={
|
||||
"ContentType": "text/plain",
|
||||
"ACL": self.storage.default_acl,
|
||||
},
|
||||
)
|
||||
|
||||
def test_storage_save_with_acl(self):
|
||||
|
|
@ -136,7 +140,11 @@ class S3Boto3StorageTests(S3Boto3TestCase):
|
|||
|
||||
obj = self.storage.bucket.Object.return_value
|
||||
obj.upload_fileobj.assert_called_with(
|
||||
content, ExtraArgs={"ContentType": "text/plain", "ACL": "private",}
|
||||
content,
|
||||
ExtraArgs={
|
||||
"ContentType": "text/plain",
|
||||
"ACL": "private",
|
||||
},
|
||||
)
|
||||
|
||||
def test_content_type(self):
|
||||
|
|
@ -151,7 +159,11 @@ class S3Boto3StorageTests(S3Boto3TestCase):
|
|||
|
||||
obj = self.storage.bucket.Object.return_value
|
||||
obj.upload_fileobj.assert_called_with(
|
||||
content, ExtraArgs={"ContentType": "image/jpeg", "ACL": self.storage.default_acl,}
|
||||
content,
|
||||
ExtraArgs={
|
||||
"ContentType": "image/jpeg",
|
||||
"ACL": self.storage.default_acl,
|
||||
},
|
||||
)
|
||||
|
||||
def test_storage_save_gzipped(self):
|
||||
|
|
@ -379,7 +391,10 @@ class S3Boto3StorageTests(S3Boto3TestCase):
|
|||
self.assertEqual(uploaded_content, written_content)
|
||||
multipart.complete.assert_called_once_with(
|
||||
MultipartUpload={
|
||||
"Parts": [{"ETag": "123", "PartNumber": 1}, {"ETag": "456", "PartNumber": 2},]
|
||||
"Parts": [
|
||||
{"ETag": "123", "PartNumber": 1},
|
||||
{"ETag": "456", "PartNumber": 2},
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -394,7 +409,10 @@ class S3Boto3StorageTests(S3Boto3TestCase):
|
|||
)
|
||||
self.storage._get_or_create_bucket("testbucketname")
|
||||
Bucket.create.assert_called_once_with(
|
||||
ACL="public-read", CreateBucketConfiguration={"LocationConstraint": "sa-east-1",}
|
||||
ACL="public-read",
|
||||
CreateBucketConfiguration={
|
||||
"LocationConstraint": "sa-east-1",
|
||||
},
|
||||
)
|
||||
|
||||
def test_auto_creating_bucket_with_acl(self):
|
||||
|
|
@ -409,22 +427,28 @@ class S3Boto3StorageTests(S3Boto3TestCase):
|
|||
)
|
||||
self.storage._get_or_create_bucket("testbucketname")
|
||||
Bucket.create.assert_called_once_with(
|
||||
ACL="public-read", CreateBucketConfiguration={"LocationConstraint": "sa-east-1",}
|
||||
ACL="public-read",
|
||||
CreateBucketConfiguration={
|
||||
"LocationConstraint": "sa-east-1",
|
||||
},
|
||||
)
|
||||
|
||||
def test_storage_exists(self):
|
||||
self.assertTrue(self.storage.exists("file.txt"))
|
||||
self.storage.connection.meta.client.head_object.assert_called_with(
|
||||
Bucket=self.storage.bucket_name, Key="file.txt",
|
||||
Bucket=self.storage.bucket_name,
|
||||
Key="file.txt",
|
||||
)
|
||||
|
||||
def test_storage_exists_false(self):
|
||||
self.storage.connection.meta.client.head_object.side_effect = ClientError(
|
||||
{"Error": {"Code": "404", "Message": "Not Found"}}, "HeadObject",
|
||||
{"Error": {"Code": "404", "Message": "Not Found"}},
|
||||
"HeadObject",
|
||||
)
|
||||
self.assertFalse(self.storage.exists("file.txt"))
|
||||
self.storage.connection.meta.client.head_object.assert_called_with(
|
||||
Bucket=self.storage.bucket_name, Key="file.txt",
|
||||
Bucket=self.storage.bucket_name,
|
||||
Key="file.txt",
|
||||
)
|
||||
|
||||
def test_storage_exists_doesnt_create_bucket(self):
|
||||
|
|
@ -445,8 +469,14 @@ class S3Boto3StorageTests(S3Boto3TestCase):
|
|||
# 4.txt
|
||||
pages = [
|
||||
{
|
||||
"CommonPrefixes": [{"Prefix": "some"}, {"Prefix": "other"},],
|
||||
"Contents": [{"Key": "2.txt"}, {"Key": "4.txt"},],
|
||||
"CommonPrefixes": [
|
||||
{"Prefix": "some"},
|
||||
{"Prefix": "other"},
|
||||
],
|
||||
"Contents": [
|
||||
{"Key": "2.txt"},
|
||||
{"Key": "4.txt"},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
|
|
@ -465,7 +495,14 @@ class S3Boto3StorageTests(S3Boto3TestCase):
|
|||
# some/path/1.txt
|
||||
# some/2.txt
|
||||
pages = [
|
||||
{"CommonPrefixes": [{"Prefix": "some/path"},], "Contents": [{"Key": "some/2.txt"},],},
|
||||
{
|
||||
"CommonPrefixes": [
|
||||
{"Prefix": "some/path"},
|
||||
],
|
||||
"Contents": [
|
||||
{"Key": "some/2.txt"},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
paginator = mock.MagicMock()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Building menu tests.
|
|||
"""
|
||||
|
||||
from evennia.commands.default.tests import BaseEvenniaCommandTest
|
||||
from . building_menu import BuildingMenu, CmdNoMatch
|
||||
from .building_menu import BuildingMenu, CmdNoMatch
|
||||
|
||||
|
||||
class Submenu(BuildingMenu):
|
||||
|
|
|
|||
|
|
@ -151,8 +151,9 @@ def realtime_to_gametime(secs=0, mins=0, hrs=0, days=1, weeks=1, months=1, yrs=0
|
|||
|
||||
"""
|
||||
if days <= 0 or weeks <= 0 or months <= 0:
|
||||
raise ValueError("realtime_to_gametime: days/weeks/months cannot be set <= 0, "
|
||||
"they start from 1.")
|
||||
raise ValueError(
|
||||
"realtime_to_gametime: days/weeks/months cannot be set <= 0, " "they start from 1."
|
||||
)
|
||||
|
||||
# days/weeks/months start from 1, we need to adjust them to work mathematically.
|
||||
days, weeks, months = days - 1, weeks - 1, months - 1
|
||||
|
|
|
|||
|
|
@ -31,17 +31,27 @@ class TestEventHandler(BaseEvenniaTest):
|
|||
def setUp(self):
|
||||
"""Create the event handler."""
|
||||
super().setUp()
|
||||
self.handler = create_script("evennia.contrib.base_systems.ingame_python.scripts.EventHandler")
|
||||
self.handler = create_script(
|
||||
"evennia.contrib.base_systems.ingame_python.scripts.EventHandler"
|
||||
)
|
||||
|
||||
# Copy old events if necessary
|
||||
if OLD_EVENTS:
|
||||
self.handler.ndb.events = dict(OLD_EVENTS)
|
||||
|
||||
# Alter typeclasses
|
||||
self.char1.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter")
|
||||
self.char2.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter")
|
||||
self.room1.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom")
|
||||
self.room2.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom")
|
||||
self.char1.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter"
|
||||
)
|
||||
self.char2.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter"
|
||||
)
|
||||
self.room1.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom"
|
||||
)
|
||||
self.room2.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom"
|
||||
)
|
||||
self.exit.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventExit")
|
||||
|
||||
def tearDown(self):
|
||||
|
|
@ -253,17 +263,27 @@ class TestCmdCallback(BaseEvenniaCommandTest):
|
|||
def setUp(self):
|
||||
"""Create the callback handler."""
|
||||
super().setUp()
|
||||
self.handler = create_script("evennia.contrib.base_systems.ingame_python.scripts.EventHandler")
|
||||
self.handler = create_script(
|
||||
"evennia.contrib.base_systems.ingame_python.scripts.EventHandler"
|
||||
)
|
||||
|
||||
# Copy old events if necessary
|
||||
if OLD_EVENTS:
|
||||
self.handler.ndb.events = dict(OLD_EVENTS)
|
||||
|
||||
# Alter typeclasses
|
||||
self.char1.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter")
|
||||
self.char2.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter")
|
||||
self.room1.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom")
|
||||
self.room2.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom")
|
||||
self.char1.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter"
|
||||
)
|
||||
self.char2.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter"
|
||||
)
|
||||
self.room1.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom"
|
||||
)
|
||||
self.room2.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom"
|
||||
)
|
||||
self.exit.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventExit")
|
||||
|
||||
def tearDown(self):
|
||||
|
|
@ -432,17 +452,27 @@ class TestDefaultCallbacks(BaseEvenniaCommandTest):
|
|||
def setUp(self):
|
||||
"""Create the callback handler."""
|
||||
super().setUp()
|
||||
self.handler = create_script("evennia.contrib.base_systems.ingame_python.scripts.EventHandler")
|
||||
self.handler = create_script(
|
||||
"evennia.contrib.base_systems.ingame_python.scripts.EventHandler"
|
||||
)
|
||||
|
||||
# Copy old events if necessary
|
||||
if OLD_EVENTS:
|
||||
self.handler.ndb.events = dict(OLD_EVENTS)
|
||||
|
||||
# Alter typeclasses
|
||||
self.char1.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter")
|
||||
self.char2.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter")
|
||||
self.room1.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom")
|
||||
self.room2.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom")
|
||||
self.char1.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter"
|
||||
)
|
||||
self.char2.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventCharacter"
|
||||
)
|
||||
self.room1.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom"
|
||||
)
|
||||
self.room2.swap_typeclass(
|
||||
"evennia.contrib.base_systems.ingame_python.typeclasses.EventRoom"
|
||||
)
|
||||
self.exit.swap_typeclass("evennia.contrib.base_systems.ingame_python.typeclasses.EventExit")
|
||||
|
||||
def tearDown(self):
|
||||
|
|
|
|||
|
|
@ -11,7 +11,11 @@ from evennia import DefaultCharacter, DefaultExit, DefaultObject, DefaultRoom
|
|||
from evennia import ScriptDB
|
||||
from evennia.utils.utils import delay, inherits_from, lazy_property
|
||||
from evennia.contrib.base_systems.ingame_python.callbackhandler import CallbackHandler
|
||||
from evennia.contrib.base_systems.ingame_python.utils import register_events, time_event, phrase_event
|
||||
from evennia.contrib.base_systems.ingame_python.utils import (
|
||||
register_events,
|
||||
time_event,
|
||||
phrase_event,
|
||||
)
|
||||
|
||||
# Character help
|
||||
CHARACTER_CAN_DELETE = """
|
||||
|
|
|
|||
|
|
@ -173,7 +173,9 @@ def time_event(obj, event_name, number, parameters):
|
|||
"""
|
||||
seconds, usual, key = get_next_wait(parameters)
|
||||
script = create_script(
|
||||
"evennia.contrib.base_systems.ingame_python.scripts.TimeEventScript", interval=seconds, obj=obj
|
||||
"evennia.contrib.base_systems.ingame_python.scripts.TimeEventScript",
|
||||
interval=seconds,
|
||||
obj=obj,
|
||||
)
|
||||
script.key = key
|
||||
script.desc = "event on {}".format(key)
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ _GUEST_ENABLED = settings.GUEST_ENABLED
|
|||
_ACCOUNT = class_from_module(settings.BASE_ACCOUNT_TYPECLASS)
|
||||
_GUEST = class_from_module(settings.BASE_GUEST_TYPECLASS)
|
||||
|
||||
_ACCOUNT_HELP = (
|
||||
"Enter a new or existing login name.")
|
||||
_ACCOUNT_HELP = "Enter a new or existing login name."
|
||||
_PASSWORD_HELP = (
|
||||
"Password should be a minimum of 8 characters (preferably longer) and "
|
||||
"can contain a mix of letters, spaces, digits and @/./+/-/_/'/, only."
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ class CmdDelCom(CmdChannel):
|
|||
account_caller = True
|
||||
|
||||
def func(self):
|
||||
"""Implementing the command. """
|
||||
"""Implementing the command."""
|
||||
|
||||
caller = self.caller
|
||||
|
||||
|
|
@ -207,8 +207,7 @@ class CmdAllCom(CmdChannel):
|
|||
args = self.args
|
||||
if not args:
|
||||
subscribed, available = self.list_channels()
|
||||
self.msg(
|
||||
"\n|wAvailable channels:\n{table}")
|
||||
self.msg("\n|wAvailable channels:\n{table}")
|
||||
return
|
||||
return
|
||||
|
||||
|
|
@ -353,7 +352,7 @@ class CmdCBoot(CmdChannel):
|
|||
self.msg(string)
|
||||
return
|
||||
|
||||
success, err = self.boot_user(target, quiet='quiet' in self.switches)
|
||||
success, err = self.boot_user(target, quiet="quiet" in self.switches)
|
||||
if success:
|
||||
self.msg(f"Booted {target.key} from {channel.key}")
|
||||
logger.log_sec(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue