Use viewkeys from future.utils, with the following mapping:

dict.keys() -> viewkeys(dict)
This commit is contained in:
Ahmed Charles 2015-11-02 09:35:22 +00:00 committed by Griatch
parent 76dc0545c4
commit faacf58f56
3 changed files with 7 additions and 4 deletions

View file

@ -55,6 +55,7 @@ protocol), but tells the Evennia OOB Protocol that you want to send a
name.
"""
from future.utils import viewkeys
from django.conf import settings
from evennia.utils.utils import to_str
@ -353,7 +354,7 @@ def oob_list(session, mode, *args, **kwargs):
# "RESET",
"SEND")))
elif mode == "REPORTABLE_VARIABLES":
session.msg(oob=("REPORTABLE_VARIABLES", tuple(key for key in OOB_REPORTABLE.keys())))
session.msg(oob=("REPORTABLE_VARIABLES", tuple(key for key in viewkeys(OOB_REPORTABLE))))
elif mode == "REPORTED_VARIABLES":
# we need to check so as to use the right return value depending on if it is
# an Attribute (identified by tracking the db_value field) or a normal database field
@ -362,7 +363,7 @@ def oob_list(session, mode, *args, **kwargs):
reported = [rep[0].key if rep[1] == "db_value" else rep[1] for rep in reported]
session.msg(oob=("REPORTED_VARIABLES", reported))
elif mode == "SENDABLE_VARIABLES":
session.msg(oob=("SENDABLE_VARIABLES", tuple(key for key in OOB_REPORTABLE.keys())))
session.msg(oob=("SENDABLE_VARIABLES", tuple(key for key in viewkeys(OOB_REPORTABLE))))
elif mode == "CONFIGURABLE_VARIABLES":
# Not implemented (game specific)
oob_error(session, "Not implemented (game specific)")

View file

@ -4,6 +4,7 @@ The bot then pipes what is being said between the IRC channel and one or
more Evennia channels.
"""
from __future__ import print_function
from future.utils import viewkeys
import re
from twisted.application import internet
@ -79,7 +80,7 @@ IRC_COLOR_MAP = dict([
(r'{[w', IRC_COLOR + IRC_NORMAL + "," + IRC_GRAY), # light grey background
(r'{[x', IRC_COLOR + IRC_NORMAL + "," + IRC_BLACK) # pure black background
])
RE_IRC_COLOR = re.compile(r"|".join([re.escape(key) for key in IRC_COLOR_MAP.keys()]), re.DOTALL)
RE_IRC_COLOR = re.compile(r"|".join([re.escape(key) for key in viewkeys(IRC_COLOR_MAP)]), re.DOTALL)
RE_MXP = re.compile(r'\{lc(.*?)\{lt(.*?)\{le', re.DOTALL)
RE_ANSI_ESCAPES = re.compile(r"(%s)" % "|".join(("{{", "%%", "\\\\")), re.DOTALL)

View file

@ -7,6 +7,7 @@ be of use when designing your own game.
"""
from __future__ import division, print_function
from builtins import object, range
from future.utils import viewkeys
import os
import sys
@ -766,7 +767,7 @@ def clean_object_caches(obj):
pass
# on-object property cache
[_DA(obj, cname) for cname in obj.__dict__.keys()
[_DA(obj, cname) for cname in viewkeys(obj.__dict__)
if cname.startswith("_cached_db_")]
try:
hashid = _GA(obj, "hashid")