diff --git a/bin/player-account-step1.patch b/bin/player-account-step1.patch index ede1d2e9b5..1f540c7c99 100644 --- a/bin/player-account-step1.patch +++ b/bin/player-account-step1.patch @@ -4,7 +4,6 @@ index ec5fc29..62b7936 100644 +++ b/evennia/comms/migrations/0015_auto_20170706_2041.py @@ -2,7 +2,12 @@ # Generated by Django 1.11.2 on 2017-07-06 20:41 - from __future__ import unicode_literals -from django.db import migrations +from django.db import migrations, connection @@ -60,7 +59,6 @@ index b27c75c..6e40252 100644 +++ b/evennia/objects/migrations/0007_objectdb_db_account.py @@ -2,21 +2,31 @@ # Generated by Django 1.11.2 on 2017-07-05 17:27 - from __future__ import unicode_literals -from django.db import migrations, models +from django.db import migrations, models, connection @@ -104,7 +102,6 @@ index 80161a1..10fb225 100644 +++ b/evennia/objects/migrations/0009_remove_objectdb_db_player.py @@ -2,7 +2,12 @@ # Generated by Django 1.11.2 on 2017-07-06 20:41 - from __future__ import unicode_literals -from django.db import migrations +from django.db import migrations, connection @@ -144,7 +141,6 @@ index 99baf70..23f6df9 100644 +++ b/evennia/scripts/migrations/0009_scriptdb_db_account.py @@ -2,21 +2,31 @@ # Generated by Django 1.11.2 on 2017-07-05 17:27 - from __future__ import unicode_literals -from django.db import migrations, models +from django.db import migrations, models, connection @@ -188,7 +184,6 @@ index d3746a5..20fa63f 100644 +++ b/evennia/scripts/migrations/0011_remove_scriptdb_db_player.py @@ -2,7 +2,12 @@ # Generated by Django 1.11.2 on 2017-07-06 20:41 - from __future__ import unicode_literals -from django.db import migrations +from django.db import migrations, connection diff --git a/evennia/accounts/accounts.py b/evennia/accounts/accounts.py index 4920f734a7..5214a58fe2 100644 --- a/evennia/accounts/accounts.py +++ b/evennia/accounts/accounts.py @@ -37,7 +37,6 @@ from evennia.commands.cmdsethandler import CmdSetHandler from evennia.utils.optionhandler import OptionHandler from django.utils.translation import ugettext as _ -from future.utils import with_metaclass from random import getrandbits __all__ = ("DefaultAccount",) @@ -113,7 +112,7 @@ class AccountSessionHandler(object): return len(self.get()) -class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)): +class DefaultAccount(AccountDB, metaclass=TypeclassBase): """ This is the base Typeclass for all Accounts. Accounts represent the person playing the game and tracks account info, password diff --git a/evennia/accounts/migrations/0008_auto_20190128_1820.py b/evennia/accounts/migrations/0008_auto_20190128_1820.py index dbef6f41fd..6ae6376197 100644 --- a/evennia/accounts/migrations/0008_auto_20190128_1820.py +++ b/evennia/accounts/migrations/0008_auto_20190128_1820.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2019-01-28 18:20 -from __future__ import unicode_literals import django.contrib.auth.validators from django.db import migrations, models diff --git a/evennia/commands/cmdset.py b/evennia/commands/cmdset.py index 95bbf9da22..596c01f745 100644 --- a/evennia/commands/cmdset.py +++ b/evennia/commands/cmdset.py @@ -26,8 +26,6 @@ Set theory. to affect the low-priority cmdset. Ex: A1,A3 + B1,B2,B4,B5 = B2,B4,B5 """ -from future.utils import listvalues, with_metaclass - from weakref import WeakKeyDictionary from django.utils.translation import ugettext as _ from evennia.utils.utils import inherits_from, is_iter @@ -57,7 +55,7 @@ class _CmdSetMeta(type): super().__init__(*args, **kwargs) -class CmdSet(with_metaclass(_CmdSetMeta, object)): +class CmdSet(object, metaclass=_CmdSetMeta): """ This class describes a unique cmdset that understands priorities. CmdSets can be merged and made to perform various set operations @@ -585,7 +583,7 @@ class CmdSet(with_metaclass(_CmdSetMeta, object)): unique[cmd.key] = cmd else: unique[cmd.key] = cmd - self.commands = listvalues(unique) + self.commands = list(unique.values()) def get_all_cmd_keys_and_aliases(self, caller=None): """ diff --git a/evennia/commands/cmdsethandler.py b/evennia/commands/cmdsethandler.py index d332c7fcd2..bc0b759031 100644 --- a/evennia/commands/cmdsethandler.py +++ b/evennia/commands/cmdsethandler.py @@ -64,7 +64,6 @@ example, you can have a 'On a boat' set, onto which you then tack on the 'Fishing' set. Fishing from a boat? No problem! """ from builtins import object -from future.utils import raise_ import sys from traceback import format_exc from importlib import import_module @@ -172,22 +171,22 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False): if not cmdsetclass: try: module = import_module(modpath, package="evennia") - except ImportError: + except ImportError as exc: if len(trace()) > 2: # error in module, make sure to not hide it. - exc = sys.exc_info() - raise_(exc[1], None, exc[2]) + _, _, tb = sys.exc_info() + raise exc.with_traceback(tb) else: # try next suggested path errstring += _("\n(Unsuccessfully tried '%s')." % python_path) continue try: cmdsetclass = getattr(module, classname) - except AttributeError: + except AttributeError as exc: if len(trace()) > 2: # Attribute error within module, don't hide it - exc = sys.exc_info() - raise_(exc[1], None, exc[2]) + _, _, tb = sys.exc_info() + raise exc.with_traceback(tb) else: errstring += _("\n(Unsuccessfully tried '%s')." % python_path) continue diff --git a/evennia/commands/command.py b/evennia/commands/command.py index ce9fbb1885..6858d24671 100644 --- a/evennia/commands/command.py +++ b/evennia/commands/command.py @@ -16,8 +16,6 @@ from evennia.utils.utils import is_iter, fill, lazy_property, make_iter from evennia.utils.evtable import EvTable from evennia.utils.ansi import ANSIString -from future.utils import with_metaclass - def _init_command(cls, **kwargs): """ @@ -99,7 +97,7 @@ class CommandMeta(type): # parsing errors. -class Command(with_metaclass(CommandMeta, object)): +class Command(object, metaclass=CommandMeta): """ Base command diff --git a/evennia/comms/comms.py b/evennia/comms/comms.py index 8c885d3458..309f3cd9ae 100644 --- a/evennia/comms/comms.py +++ b/evennia/comms/comms.py @@ -11,11 +11,11 @@ from evennia.comms.models import TempMsg, ChannelDB from evennia.comms.managers import ChannelManager from evennia.utils import create, logger from evennia.utils.utils import make_iter -from future.utils import with_metaclass + _CHANNEL_HANDLER = None -class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)): +class DefaultChannel(ChannelDB, metaclass=TypeclassBase): """ This is the base class for all Channel Comms. Inherit from this to create different types of communication channels. diff --git a/evennia/comms/migrations/0017_auto_20190128_1820.py b/evennia/comms/migrations/0017_auto_20190128_1820.py index 3937ff9da0..d07f3cfb65 100644 --- a/evennia/comms/migrations/0017_auto_20190128_1820.py +++ b/evennia/comms/migrations/0017_auto_20190128_1820.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2019-01-28 18:20 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/evennia/contrib/tutorial_world/objects.py b/evennia/contrib/tutorial_world/objects.py index 7a9fe096ba..a4580fb518 100644 --- a/evennia/contrib/tutorial_world/objects.py +++ b/evennia/contrib/tutorial_world/objects.py @@ -18,7 +18,6 @@ Weapon WeaponRack """ -from future.utils import listvalues import random @@ -528,7 +527,7 @@ class CmdShiftRoot(Command): self.obj.db.root_pos = root_pos # Check victory condition - if listvalues(root_pos).count(0) == 0: # no roots in middle position + if list(root_pos.values()).count(0) == 0: # no roots in middle position # This will affect the cmd: lock of CmdPressButton self.obj.db.button_exposed = True self.caller.msg("Holding aside the root you think you notice something behind it ...") diff --git a/evennia/help/migrations/0003_auto_20190128_1820.py b/evennia/help/migrations/0003_auto_20190128_1820.py index 659ec951cb..d87067fd22 100644 --- a/evennia/help/migrations/0003_auto_20190128_1820.py +++ b/evennia/help/migrations/0003_auto_20190128_1820.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2019-01-28 18:20 -from __future__ import unicode_literals - from django.db import migrations, models diff --git a/evennia/objects/migrations/0010_auto_20190128_1820.py b/evennia/objects/migrations/0010_auto_20190128_1820.py index 3b23d72e58..fa161894cf 100644 --- a/evennia/objects/migrations/0010_auto_20190128_1820.py +++ b/evennia/objects/migrations/0010_auto_20190128_1820.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2019-01-28 18:20 -from __future__ import unicode_literals from django.conf import settings import django.core.validators diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index fd76fae645..61dd3aed44 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -8,7 +8,6 @@ entities. import time import inflect from builtins import object -from future.utils import with_metaclass from collections import defaultdict from django.conf import settings @@ -179,7 +178,7 @@ class ObjectSessionHandler(object): # Base class to inherit from. -class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): +class DefaultObject(ObjectDB, metaclass=TypeclassBase): """ This is the root typeclass object, representing all entities that have an actual presence in-game. DefaultObjects generally have a diff --git a/evennia/scripts/migrations/0012_auto_20190128_1820.py b/evennia/scripts/migrations/0012_auto_20190128_1820.py index 6b1f71b159..80b3e3184e 100644 --- a/evennia/scripts/migrations/0012_auto_20190128_1820.py +++ b/evennia/scripts/migrations/0012_auto_20190128_1820.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2019-01-28 18:20 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/evennia/scripts/scripts.py b/evennia/scripts/scripts.py index b7e3296319..72f46d8e21 100644 --- a/evennia/scripts/scripts.py +++ b/evennia/scripts/scripts.py @@ -13,7 +13,6 @@ from evennia.typeclasses.models import TypeclassBase from evennia.scripts.models import ScriptDB from evennia.scripts.manager import ScriptManager from evennia.utils import create, logger -from future.utils import with_metaclass __all__ = ["DefaultScript", "DoNothing", "Store"] @@ -144,7 +143,7 @@ class ExtendedLoopingCall(LoopingCall): return None -class ScriptBase(with_metaclass(TypeclassBase, ScriptDB)): +class ScriptBase(ScriptDB, metaclass=TypeclassBase): """ Base class for scripts. Don't inherit from this, inherit from the class `DefaultScript` below instead. diff --git a/evennia/server/inputfuncs.py b/evennia/server/inputfuncs.py index 4eee991188..08427658b9 100644 --- a/evennia/server/inputfuncs.py +++ b/evennia/server/inputfuncs.py @@ -19,7 +19,6 @@ Evennia knows which modules to use for inputfuncs by settings.INPUT_FUNC_MODULES. """ -from future.utils import viewkeys import importlib from codecs import lookup as codecs_lookup diff --git a/evennia/server/migrations/0002_auto_20190128_2311.py b/evennia/server/migrations/0002_auto_20190128_2311.py index b6b8db0f55..5a3e46c009 100644 --- a/evennia/server/migrations/0002_auto_20190128_2311.py +++ b/evennia/server/migrations/0002_auto_20190128_2311.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2019-01-28 23:11 -from __future__ import unicode_literals from base64 import b64encode from django.db import migrations diff --git a/evennia/server/portal/irc.py b/evennia/server/portal/irc.py index 2b616f2ce1..e4273e4cc5 100644 --- a/evennia/server/portal/irc.py +++ b/evennia/server/portal/irc.py @@ -3,7 +3,6 @@ This connects to an IRC network/channel and launches an 'bot' onto it. The bot then pipes what is being said between the IRC channel and one or more Evennia channels. """ -from future.utils import viewkeys, viewvalues, viewitems import re from twisted.application import internet @@ -90,15 +89,15 @@ IRC_COLOR_MAP = dict(( )) # ansi->irc RE_ANSI_COLOR = re.compile(r"|".join( - [re.escape(key) for key in viewkeys(IRC_COLOR_MAP)]), re.DOTALL) + [re.escape(key) for key in IRC_COLOR_MAP.keys()]), re.DOTALL) RE_MXP = re.compile(r'\|lc(.*?)\|lt(.*?)\|le', re.DOTALL) RE_ANSI_ESCAPES = re.compile(r"(%s)" % "|".join(("{{", "%%", "\\\\")), re.DOTALL) # irc->ansi _CLR_LIST = [re.escape(val) - for val in sorted(viewvalues(IRC_COLOR_MAP), key=len, reverse=True) if val.strip()] + for val in sorted(IRC_COLOR_MAP.values(), key=len, reverse=True) if val.strip()] _CLR_LIST = _CLR_LIST[-2:] + _CLR_LIST[:-2] RE_IRC_COLOR = re.compile(r"|".join(_CLR_LIST), re.DOTALL) -ANSI_COLOR_MAP = dict((tup[1], tup[0]) for tup in viewitems(IRC_COLOR_MAP) if tup[1].strip()) +ANSI_COLOR_MAP = dict((tup[1], tup[0]) for tup in IRC_COLOR_MAP.items() if tup[1].strip()) def parse_ansi_to_irc(string): diff --git a/evennia/server/sessionhandler.py b/evennia/server/sessionhandler.py index cdb9a1ab1d..cfded91906 100644 --- a/evennia/server/sessionhandler.py +++ b/evennia/server/sessionhandler.py @@ -14,7 +14,6 @@ There are two similar but separate stores of sessions: """ import time from builtins import object -from future.utils import listvalues from django.conf import settings from evennia.commands.cmdhandler import CMD_LOGINSTART @@ -148,7 +147,7 @@ class SessionHandler(dict): """ if include_unloggedin: - return listvalues(self) + return list(self.values()) else: return [session for session in self.values() if session.logged_in] diff --git a/evennia/typeclasses/migrations/0011_auto_20190128_1820.py b/evennia/typeclasses/migrations/0011_auto_20190128_1820.py index 1d7bc4fb5d..d172e82124 100644 --- a/evennia/typeclasses/migrations/0011_auto_20190128_1820.py +++ b/evennia/typeclasses/migrations/0011_auto_20190128_1820.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2019-01-28 18:20 -from __future__ import unicode_literals from django.db import migrations, models import evennia.utils.picklefield diff --git a/evennia/typeclasses/migrations/0012_attrs_to_picklev4_may_be_slow.py b/evennia/typeclasses/migrations/0012_attrs_to_picklev4_may_be_slow.py index 2575ce064c..ed9de5ff2e 100644 --- a/evennia/typeclasses/migrations/0012_attrs_to_picklev4_may_be_slow.py +++ b/evennia/typeclasses/migrations/0012_attrs_to_picklev4_may_be_slow.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2019-01-30 20:56 -from __future__ import unicode_literals from copy import deepcopy from base64 import b64encode, b64decode diff --git a/evennia/utils/ansi.py b/evennia/utils/ansi.py index a10c6a4e2c..7eec5f95b3 100644 --- a/evennia/utils/ansi.py +++ b/evennia/utils/ansi.py @@ -25,7 +25,6 @@ from evennia.utils import utils from evennia.utils import logger from evennia.utils.utils import to_str -from future.utils import with_metaclass # ANSI definitions @@ -631,7 +630,7 @@ class ANSIMeta(type): super().__init__(*args, **kwargs) -class ANSIString(with_metaclass(ANSIMeta, str)): +class ANSIString(str, metaclass=ANSIMeta): """ Unicode-like object that is aware of ANSI codes. diff --git a/evennia/utils/evtable.py b/evennia/utils/evtable.py index 29c4340d00..90cf1d2f44 100644 --- a/evennia/utils/evtable.py +++ b/evennia/utils/evtable.py @@ -111,8 +111,6 @@ table string. """ -from future.utils import listitems - from django.conf import settings from textwrap import TextWrapper from copy import deepcopy, copy @@ -1464,7 +1462,7 @@ class EvTable(object): """ # this will replace default options with new ones without changing default - options = dict(listitems(self.options) + listitems(kwargs)) + options = dict(list(self.options.items()) + list(kwargs.items())) xpos = kwargs.get("xpos", None) column = EvColumn(*args, **options) @@ -1529,7 +1527,7 @@ class EvTable(object): """ # this will replace default options with new ones without changing default row = list(args) - options = dict(listitems(self.options) + listitems(kwargs)) + options = dict(list(self.options.items()) + list(kwargs.items())) ypos = kwargs.get("ypos", None) wtable = self.ncols diff --git a/evennia/utils/idmapper/models.py b/evennia/utils/idmapper/models.py index 57a7cbaacd..b8f2db0444 100644 --- a/evennia/utils/idmapper/models.py +++ b/evennia/utils/idmapper/models.py @@ -8,7 +8,6 @@ Also adds `cache_size()` for monitoring the size of the cache. """ from builtins import object -from future.utils import listitems, listvalues, with_metaclass import os import threading @@ -197,7 +196,7 @@ class SharedMemoryModelBase(ModelBase): return # dynamically create the wrapper properties for all fields not already handled # (manytomanyfields are always handlers) - for fieldname, field in ((fname, field) for fname, field in listitems(attrs) + for fieldname, field in ((fname, field) for fname, field in list(attrs.items()) if fname.startswith("db_") and type(field).__name__ != "ManyToManyField"): foreignkey = type(field).__name__ == "ForeignKey" wrappername = "dbid" if fieldname == "id" else fieldname.replace("db_", "", 1) @@ -208,7 +207,7 @@ class SharedMemoryModelBase(ModelBase): return super().__new__(cls, name, bases, attrs) -class SharedMemoryModel(with_metaclass(SharedMemoryModelBase, Model)): +class SharedMemoryModel(Model, metaclass=SharedMemoryModelBase): """ Base class for idmapped objects. Inherit from `this`. """ @@ -291,7 +290,7 @@ class SharedMemoryModel(with_metaclass(SharedMemoryModelBase, Model)): Return the objects so far cached by idmapper for this class. """ - return listvalues(cls.__dbclass__.__instance_cache__) + return list(cls.__dbclass__.__instance_cache__.values()) @classmethod def _flush_cached_by_key(cls, key, force=True): @@ -457,7 +456,7 @@ class WeakSharedMemoryModelBase(SharedMemoryModelBase): cls.__dbclass__.__instance_cache__ = WeakValueDictionary() -class WeakSharedMemoryModel(with_metaclass(WeakSharedMemoryModelBase, SharedMemoryModel)): +class WeakSharedMemoryModel(SharedMemoryModel, metaclass=WeakSharedMemoryModelBase): """ Uses a WeakValue dictionary for caching instead of a regular one diff --git a/evennia/utils/utils.py b/evennia/utils/utils.py index 6c45bd8d18..88b69258d1 100644 --- a/evennia/utils/utils.py +++ b/evennia/utils/utils.py @@ -6,9 +6,8 @@ They provide some useful string and conversion methods that might be of use when designing your own game. """ -from future.utils import viewkeys, raise_ - import os +import gc import sys import imp import types @@ -35,14 +34,6 @@ from evennia.utils import logger _MULTIMATCH_TEMPLATE = settings.SEARCH_MULTIMATCH_TEMPLATE _EVENNIA_DIR = settings.EVENNIA_DIR _GAME_DIR = settings.GAME_DIR - - -# ModuleNotFoundError only in py3.6, handle both -try: - from builtins import ModuleNotFoundError -except ImportError: - ModuleNotFoundError = ImportError - ENCODINGS = settings.ENCODINGS _GA = object.__getattribute__ _SA = object.__setattr__ @@ -1052,45 +1043,6 @@ def delay(timedelay, callback, *args, **kwargs): return _TASK_HANDLER.add(timedelay, callback, *args, **kwargs) -_TYPECLASSMODELS = None -_OBJECTMODELS = None - - -def clean_object_caches(obj): - """ - Clean all object caches on the given object. - - Args: - obj (Object instace): An object whose caches to clean. - - Notes: - This is only the contents cache these days. - - """ - global _TYPECLASSMODELS, _OBJECTMODELS - if not _TYPECLASSMODELS: - from evennia.typeclasses import models as _TYPECLASSMODELS - - if not obj: - return - # contents cache - try: - _SA(obj, "_contents_cache", None) - except AttributeError: - # if the cache cannot be reached, move on anyway - pass - - # on-object property cache - [_DA(obj, cname) for cname in viewkeys(obj.__dict__) - if cname.startswith("_cached_db_")] - try: - hashid = _GA(obj, "hashid") - _TYPECLASSMODELS._ATTRIBUTE_CACHE[hashid] = {} - except AttributeError: - # skip caching - pass - - _PPOOL = None _PCMD = None _PROC_ERR = "A process has ended with a probable error condition: process ended by signal 9." @@ -1693,10 +1645,6 @@ def get_evennia_pids(): return None, None -from gc import get_referents -from sys import getsizeof - - def deepsize(obj, max_depth=4): """ Get not only size of the given object, but also the size of @@ -1722,14 +1670,14 @@ def deepsize(obj, max_depth=4): def _recurse(o, dct, depth): if 0 <= max_depth < depth: return - for ref in get_referents(o): + for ref in gc.get_referents(o): idr = id(ref) if idr not in dct: - dct[idr] = (ref, getsizeof(ref, default=0)) + dct[idr] = (ref, sys.getsizeof(ref, default=0)) _recurse(ref, dct, depth + 1) sizedict = {} _recurse(obj, sizedict, 0) - size = getsizeof(obj) + sum([p[1] for p in sizedict.values()]) + size = sys.getsizeof(obj) + sum([p[1] for p in sizedict.values()]) return size diff --git a/requirements.txt b/requirements.txt index f9284a2859..772feeb36e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,6 @@ django >= 2.2.5, < 2.3 twisted >= 19.2.1, < 20.0.0 pillow == 5.2.0 pytz -future >= 0.15.2 django-sekizai inflect autobahn >= 17.9.3 diff --git a/win_requirements.txt b/win_requirements.txt index 99e5f6abfa..c3a7396ae3 100644 --- a/win_requirements.txt +++ b/win_requirements.txt @@ -8,7 +8,6 @@ django >= 2.2.5, < 2.3 twisted >= 19.2.1, < 20.0.0 pillow == 5.2.0 pytz -future >= 0.15.2 django-sekizai autobahn >= 17.9.3 inflect