mirror of
https://github.com/evennia/evennia.git
synced 2025-10-29 19:35:56 +00:00
Unwrap several for statements from 2to3 conversion process.
This commit is contained in:
parent
8c318c6d38
commit
f2e800ddf1
@ -261,7 +261,7 @@ def rename_in_file(path, in_list, out_list, is_interactive):
|
||||
break
|
||||
elif ret == "a":
|
||||
# save result
|
||||
for iline, renamed_line in list(renamed.items()):
|
||||
for iline, renamed_line in renamed.items():
|
||||
org_lines[iline] = renamed_line
|
||||
|
||||
if FAKE_MODE:
|
||||
|
||||
@ -567,7 +567,7 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess
|
||||
returnValue(cmd)
|
||||
|
||||
# assign custom kwargs to found cmd object
|
||||
for key, val in list(kwargs.items()):
|
||||
for key, val in kwargs.items():
|
||||
setattr(cmd, key, val)
|
||||
|
||||
_COMMAND_NESTING[called_by] += 1
|
||||
|
||||
@ -440,7 +440,7 @@ class CmdObjects(COMMAND_DEFAULT_CLASS):
|
||||
typetable = EvTable("|wtypeclass|n", "|wcount|n", "|w%%|n", border="table", align="l")
|
||||
typetable.align = 'l'
|
||||
dbtotals = ObjectDB.objects.object_totals()
|
||||
for path, count in list(dbtotals.items()):
|
||||
for path, count in dbtotals.items():
|
||||
typetable.add_row(path, count, "%.2f" % ((float(count) / nobjs) * 100))
|
||||
|
||||
# last N table
|
||||
@ -487,7 +487,7 @@ class CmdAccounts(COMMAND_DEFAULT_CLASS):
|
||||
# typeclass table
|
||||
dbtotals = AccountDB.objects.object_totals()
|
||||
typetable = EvTable("|wtypeclass|n", "|wcount|n", "|w%%|n", border="cells", align="l")
|
||||
for path, count in list(dbtotals.items()):
|
||||
for path, count in dbtotals.items():
|
||||
typetable.add_row(path, count, "%.2f" % ((float(count) / naccounts) * 100))
|
||||
# last N table
|
||||
plyrs = AccountDB.objects.all().order_by("db_date_created")[max(0, naccounts - nlim):]
|
||||
|
||||
@ -105,7 +105,7 @@ def gametime_to_realtime(format=False, **kwargs):
|
||||
"""
|
||||
# Dynamically creates the list of units based on kwarg names and UNITs list
|
||||
rtime = 0
|
||||
for name, value in list(kwargs.items()):
|
||||
for name, value in kwargs.items():
|
||||
# Allow plural names (like mins instead of min)
|
||||
if name not in UNITS and name.endswith("s"):
|
||||
name = name[:-1]
|
||||
@ -197,7 +197,7 @@ def real_seconds_until(**kwargs):
|
||||
# For each keyword, add in the unit's
|
||||
units.append(1)
|
||||
higher_unit = None
|
||||
for unit, value in list(kwargs.items()):
|
||||
for unit, value in kwargs.items():
|
||||
# Get the unit's index
|
||||
if unit not in UNITS:
|
||||
raise ValueError("unknown unit".format(unit))
|
||||
|
||||
@ -36,7 +36,7 @@ class CallbackHandler(object):
|
||||
handler = type(self).script
|
||||
if handler:
|
||||
dicts = handler.get_callbacks(self.obj)
|
||||
for callback_name, in_list in list(dicts.items()):
|
||||
for callback_name, in_list in dicts.items():
|
||||
new_list = []
|
||||
for callback in in_list:
|
||||
callback = self.format_callback(callback)
|
||||
|
||||
@ -129,7 +129,7 @@ class EventHandler(DefaultScript):
|
||||
while not classes.empty():
|
||||
typeclass = classes.get()
|
||||
typeclass_name = typeclass.__module__ + "." + typeclass.__name__
|
||||
for key, etype in list(all_events.get(typeclass_name, {}).items()):
|
||||
for key, etype in all_events.get(typeclass_name, {}).items():
|
||||
if key in invalid:
|
||||
continue
|
||||
if etype[0] is None: # Invalidate
|
||||
@ -186,7 +186,7 @@ class EventHandler(DefaultScript):
|
||||
"""
|
||||
obj_callbacks = self.db.callbacks.get(obj, {})
|
||||
callbacks = {}
|
||||
for callback_name, callback_list in list(obj_callbacks.items()):
|
||||
for callback_name, callback_list in obj_callbacks.items():
|
||||
new_list = []
|
||||
for i, callback in enumerate(callback_list):
|
||||
callback = dict(callback)
|
||||
@ -362,7 +362,7 @@ class EventHandler(DefaultScript):
|
||||
self.db.locked[i] = (t_obj, t_callback_name, t_number - 1)
|
||||
|
||||
# Delete time-related callbacks associated with this object
|
||||
for script in list(obj.scripts.all()):
|
||||
for script in obj.scripts.all():
|
||||
if isinstance(script, TimecallbackScript):
|
||||
if script.obj is obj and script.db.callback_name == callback_name:
|
||||
if script.db.number == number:
|
||||
@ -576,7 +576,7 @@ class EventHandler(DefaultScript):
|
||||
|
||||
# Collect and freeze current locals
|
||||
locals = {}
|
||||
for key, value in list(self.ndb.current_locals.items()):
|
||||
for key, value in self.ndb.current_locals.items():
|
||||
try:
|
||||
dbserialize(value)
|
||||
except TypeError:
|
||||
|
||||
@ -65,7 +65,7 @@ def register_events(path_or_typeclass):
|
||||
|
||||
# If the script is started, add the event directly.
|
||||
# Otherwise, add it to the temporary storage.
|
||||
for name, tup in list(getattr(typeclass, "_events", {}).items()):
|
||||
for name, tup in getattr(typeclass, "_events", {}).items():
|
||||
if len(tup) == 4:
|
||||
variables, help_text, custom_call, custom_add = tup
|
||||
elif len(tup) == 3:
|
||||
|
||||
@ -689,7 +689,7 @@ class CrumblingWall(TutorialObject, DefaultExit):
|
||||
"crisscross the wall, making it hard to clearly see its stony surface. Maybe you could "
|
||||
"try to |wshift|n or |wmove|n them.\n"]
|
||||
# display the root positions to help with the puzzle
|
||||
for key, pos in list(self.db.root_pos.items()):
|
||||
for key, pos in self.db.root_pos.items():
|
||||
result.append("\n" + self._translate_position(key, pos))
|
||||
self.db.desc = "".join(result)
|
||||
|
||||
|
||||
@ -249,7 +249,7 @@ class WildernessScript(DefaultScript):
|
||||
"""
|
||||
Called when the script is started and also after server reloads.
|
||||
"""
|
||||
for coordinates, room in list(self.db.rooms.items()):
|
||||
for coordinates, room in self.db.rooms.items():
|
||||
room.ndb.wildernessscript = self
|
||||
room.ndb.active_coordinates = coordinates
|
||||
for item in list(self.db.itemcoordinates.keys()):
|
||||
|
||||
@ -959,7 +959,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||
self.attributes.batch_add(*cdict["attributes"])
|
||||
if cdict.get("nattributes"):
|
||||
# this should be a dict of nattrname:value
|
||||
for key, value in list(cdict["nattributes"].items()):
|
||||
for key, value in cdict["nattributes"].items():
|
||||
self.nattributes.add(key, value)
|
||||
|
||||
del self._createdict
|
||||
|
||||
@ -47,7 +47,7 @@ class TaskHandler(object):
|
||||
tasks = value
|
||||
|
||||
# At this point, `tasks` contains a dictionary of still-serialized tasks
|
||||
for task_id, value in list(tasks.items()):
|
||||
for task_id, value in tasks.items():
|
||||
date, callback, args, kwargs = dbunserialize(value)
|
||||
if isinstance(callback, tuple):
|
||||
# `callback` can be an object and name for instance methods
|
||||
@ -64,7 +64,7 @@ class TaskHandler(object):
|
||||
|
||||
def save(self):
|
||||
"""Save the tasks in ServerConfig."""
|
||||
for task_id, (date, callback, args, kwargs) in list(self.tasks.items()):
|
||||
for task_id, (date, callback, args, kwargs) in self.tasks.items():
|
||||
if task_id in self.to_save:
|
||||
continue
|
||||
|
||||
@ -127,7 +127,7 @@ class TaskHandler(object):
|
||||
else:
|
||||
safe_args.append(arg)
|
||||
|
||||
for key, value in list(kwargs.items()):
|
||||
for key, value in kwargs.items():
|
||||
try:
|
||||
dbserialize(value)
|
||||
except (TypeError, AttributeError):
|
||||
@ -187,7 +187,7 @@ class TaskHandler(object):
|
||||
|
||||
"""
|
||||
now = datetime.now()
|
||||
for task_id, (date, callbac, args, kwargs) in list(self.tasks.items()):
|
||||
for task_id, (date, callbac, args, kwargs) in self.tasks.items():
|
||||
seconds = max(0, (date - now).total_seconds())
|
||||
task.deferLater(reactor, seconds, self.do_task, task_id)
|
||||
|
||||
|
||||
@ -286,7 +286,7 @@ class TickerPool(object):
|
||||
if interval and interval in self.tickers:
|
||||
self.tickers[interval].stop()
|
||||
else:
|
||||
for ticker in list(self.tickers.values()):
|
||||
for ticker in self.tickers.values():
|
||||
ticker.stop()
|
||||
|
||||
|
||||
@ -395,7 +395,7 @@ class TickerHandler(object):
|
||||
store_key[2])} # a path given
|
||||
|
||||
# update the timers for the tickers
|
||||
for store_key, (args, kwargs) in list(to_save.items()):
|
||||
for store_key, (args, kwargs) in to_save.items():
|
||||
interval = store_key[1]
|
||||
# this is a mutable, so it's updated in-place in ticker_storage
|
||||
kwargs["_start_delay"] = start_delays.get(interval, None)
|
||||
|
||||
@ -995,7 +995,7 @@ def list_settings(keys):
|
||||
keys = [key.upper() for key in keys]
|
||||
confs = dict((key, var) for key, var in list(evsettings.__dict__.items())
|
||||
if key in keys)
|
||||
for key, val in list(confs.items()):
|
||||
for key, val in confs.items():
|
||||
table.add_row(key, str(val))
|
||||
print(table)
|
||||
|
||||
|
||||
@ -191,7 +191,7 @@ class Mssp(object):
|
||||
self.mssp_table.update(MSSPTable_CUSTOM)
|
||||
|
||||
varlist = ''
|
||||
for variable, value in list(self.mssp_table.items()):
|
||||
for variable, value in self.mssp_table.items():
|
||||
if callable(value):
|
||||
value = value()
|
||||
if utils.is_iter(value):
|
||||
|
||||
@ -188,7 +188,7 @@ class PortalSessionHandler(SessionHandler):
|
||||
# we set a watchdog to stop self.disconnect from deleting
|
||||
# sessions while we are looping over them.
|
||||
sessionhandler._disconnect_all = True
|
||||
for session in list(sessionhandler.values()):
|
||||
for session in sessionhandler.values():
|
||||
session.disconnect()
|
||||
del sessionhandler._disconnect_all
|
||||
|
||||
@ -336,7 +336,7 @@ class PortalSessionHandler(SessionHandler):
|
||||
send command.
|
||||
|
||||
"""
|
||||
for session in list(self.values()):
|
||||
for session in self.values():
|
||||
self.data_out(session, text=[[message], {}])
|
||||
|
||||
def data_in(self, session, **kwargs):
|
||||
|
||||
@ -117,7 +117,7 @@ class Session(object):
|
||||
sessdata (dict): Session data dictionary.
|
||||
|
||||
"""
|
||||
for propname, value in list(sessdata.items()):
|
||||
for propname, value in sessdata.items():
|
||||
setattr(self, propname, value)
|
||||
|
||||
def at_sync(self):
|
||||
|
||||
@ -195,7 +195,7 @@ class SessionHandler(dict):
|
||||
"Helper function to convert data to AMP-safe (picketable) values"
|
||||
if isinstance(data, dict):
|
||||
newdict = {}
|
||||
for key, part in list(data.items()):
|
||||
for key, part in data.items():
|
||||
newdict[key] = _validate(part)
|
||||
return newdict
|
||||
elif is_iter(data):
|
||||
@ -349,7 +349,7 @@ class ServerSessionHandler(SessionHandler):
|
||||
# lingering references.
|
||||
del sess
|
||||
|
||||
for sessid, sessdict in list(portalsessionsdata.items()):
|
||||
for sessid, sessdict in portalsessionsdata.items():
|
||||
sess = _ServerSession()
|
||||
sess.sessionhandler = self
|
||||
sess.load_sync_data(sessdict)
|
||||
@ -688,7 +688,7 @@ class ServerSessionHandler(SessionHandler):
|
||||
message (str): Message to send.
|
||||
|
||||
"""
|
||||
for session in list(self.values()):
|
||||
for session in self.values():
|
||||
self.data_out(session, text=message)
|
||||
|
||||
def data_out(self, session, **kwargs):
|
||||
|
||||
@ -382,7 +382,7 @@ class BatchCodeProcessor(object):
|
||||
"""
|
||||
# define the execution environment
|
||||
environdict = {"settings_module": settings, "DEBUG": debug}
|
||||
for key, value in list(extra_environ.items()):
|
||||
for key, value in extra_environ.items():
|
||||
environdict[key] = value
|
||||
|
||||
# initializing the django settings at the top of code
|
||||
|
||||
@ -965,7 +965,7 @@ class EvEditor(object):
|
||||
|
||||
# If the line begins by one of the given keywords
|
||||
indent = self._indent
|
||||
if any(line.startswith(kw) for kw in list(keywords.keys())):
|
||||
if any(line.startswith(kw) for kw in keywords.keys()):
|
||||
# Get the keyword and matching begin tags
|
||||
keyword = [kw for kw in keywords if line.startswith(kw)][0]
|
||||
begin_tags = keywords[keyword]
|
||||
|
||||
@ -259,7 +259,7 @@ class EvForm(object):
|
||||
break
|
||||
|
||||
# get rectangles and assign EvCells
|
||||
for key, (iy, leftix, rightix) in list(cell_coords.items()):
|
||||
for key, (iy, leftix, rightix) in cell_coords.items():
|
||||
# scan up to find top of rectangle
|
||||
dy_up = 0
|
||||
if iy > 0:
|
||||
@ -294,7 +294,7 @@ class EvForm(object):
|
||||
mapping[key] = (iyup, leftix, width, height, EvCell(data, width=width, height=height, **options))
|
||||
|
||||
# get rectangles and assign Tables
|
||||
for key, (iy, leftix, rightix) in list(table_coords.items()):
|
||||
for key, (iy, leftix, rightix) in table_coords.items():
|
||||
|
||||
# scan up to find top of rectangle
|
||||
dy_up = 0
|
||||
@ -340,7 +340,7 @@ class EvForm(object):
|
||||
|
||||
"""
|
||||
form = copy.copy(raw_form)
|
||||
for key, (iy0, ix0, width, height, cell_or_table) in list(mapping.items()):
|
||||
for key, (iy0, ix0, width, height, cell_or_table) in mapping.items():
|
||||
# rect is a list of <height> lines, each <width> wide
|
||||
rect = cell_or_table.get()
|
||||
for il, rectline in enumerate(rect):
|
||||
|
||||
@ -816,7 +816,7 @@ class EvCell(object):
|
||||
self.trim_vertical = kwargs.pop("trim_vertical", self.trim_vertical)
|
||||
|
||||
# fill all other properties
|
||||
for key, value in list(kwargs.items()):
|
||||
for key, value in kwargs.items():
|
||||
setattr(self, key, value)
|
||||
|
||||
# Handle sizes
|
||||
@ -1525,7 +1525,7 @@ class EvTable(object):
|
||||
"""
|
||||
self.width = kwargs.pop("width", self.width)
|
||||
self.height = kwargs.pop("height", self.height)
|
||||
for key, value in list(kwargs.items()):
|
||||
for key, value in kwargs.items():
|
||||
setattr(self, key, value)
|
||||
|
||||
hchar = kwargs.pop("header_line_char", self.header_line_char)
|
||||
|
||||
@ -238,7 +238,7 @@ def spawn(*prototypes, **kwargs):
|
||||
list(all_from_module(prototype_module).items()) if isinstance(val, dict)))
|
||||
# overload module's protparents with specifically given protparents
|
||||
protparents.update(kwargs.get("prototype_parents", {}))
|
||||
for key, prototype in list(protparents.items()):
|
||||
for key, prototype in protparents.items():
|
||||
_validate_prototype(key, prototype, protparents, [])
|
||||
|
||||
if "return_prototypes" in kwargs:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user