Skip to content

Commit 2e66a61

Browse files
committed
sopel: replace obsolete tools.iteritems
1 parent 8931897 commit 2e66a61

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

sopel/bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def __setup_plugins_check_manual_url_callbacks(self, name):
349349
# nothing to check
350350
return
351351

352-
for key, callback in tools.iteritems(self.memory['url_callbacks']):
352+
for key, callback in self.memory['url_callbacks'].items():
353353
is_checked = getattr(
354354
callback, '_sopel_url_callbacks_checked', False)
355355
if is_checked:
@@ -1207,7 +1207,7 @@ def search_url_callbacks(self, url):
12071207
# nothing to search
12081208
return
12091209

1210-
for regex, function in tools.iteritems(self.memory['url_callbacks']):
1210+
for regex, function in self.memory['url_callbacks'].items():
12111211
match = regex.search(url)
12121212
if match:
12131213
yield function, match

sopel/coretasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from sopel.config import ConfigurationError
3737
from sopel.irc import isupport
3838
from sopel.irc.utils import CapReq, MyInfo
39-
from sopel.tools import events, Identifier, iteritems, SopelMemory, target, web
39+
from sopel.tools import events, Identifier, SopelMemory, target, web
4040

4141

4242
LOGGER = logging.getLogger(__name__)
@@ -447,7 +447,7 @@ def handle_names(bot, trigger):
447447

448448
for name in names:
449449
priv = 0
450-
for prefix, value in iteritems(mapping):
450+
for prefix, value in mapping.items():
451451
if prefix in name:
452452
priv = priv | value
453453
nick = Identifier(name.lstrip(''.join(mapping.keys())))
@@ -915,7 +915,7 @@ def acct_warn(bot, cap):
915915
if cap not in bot._cap_reqs:
916916
bot._cap_reqs[cap] = [CapReq('', 'coretasks', acct_warn)]
917917

918-
for cap, reqs in iteritems(bot._cap_reqs):
918+
for cap, reqs in bot._cap_reqs.items():
919919
# At this point, we know mandatory and prohibited don't co-exist, but
920920
# we need to call back for optionals if they're also prohibited
921921
prefix = ''

sopel/loader.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import sys
1818

1919
from sopel.config.core_section import COMMAND_DEFAULT_HELP_PREFIX
20-
from sopel.tools import itervalues
2120

2221

2322
LOGGER = logging.getLogger(__name__)
@@ -268,7 +267,7 @@ def clean_module(module, config):
268267
shutdowns = []
269268
jobs = []
270269
urls = []
271-
for obj in itervalues(vars(module)):
270+
for obj in vars(module).values():
272271
if callable(obj):
273272
is_sopel_callable = getattr(obj, '_sopel_callable', False) is True
274273
if getattr(obj, '__name__', None) == 'shutdown':

sopel/modules/remind.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import pytz
2121

22-
from sopel import plugin, tools
22+
from sopel import plugin
2323
from sopel.tools.time import format_time, get_timezone, validate_timezone
2424

2525

@@ -95,7 +95,7 @@ def dump_database(filename, data):
9595
If the file does not exist, it is created.
9696
"""
9797
with io.open(filename, 'w', encoding='utf-8') as database:
98-
for unixtime, reminders in tools.iteritems(data):
98+
for unixtime, reminders in data.items():
9999
for channel, nick, message in reminders:
100100
line = '%s\t%s\t%s\t%s\n' % (unixtime, channel, nick, message)
101101
database.write(line)

sopel/modules/safety.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def _clean_cache(bot):
240240
# clean up by age first
241241
cutoff = time.time() - (7 * 24 * 60 * 60) # 7 days ago
242242
old_keys = []
243-
for key, data in tools.iteritems(bot.memory['safety_cache']):
243+
for key, data in bot.memory['safety_cache'].items():
244244
if data['fetched'] <= cutoff:
245245
old_keys.append(key)
246246
for key in old_keys:

sopel/test_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def unregister_url_callback(self, pattern, callback):
114114
pass
115115

116116
def search_url_callbacks(self, url):
117-
for regex, function in tools.iteritems(self.memory['url_callbacks']):
117+
for regex, function in self.memory['url_callbacks'].items():
118118
match = regex.search(url)
119119
if match:
120120
yield function, match

sopel/tools/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
from . import time, web # NOQA
3333

3434

35+
# Kept for backward compatibility
36+
# TODO: consider removing that
3537
raw_input = input
3638
iteritems = dict.items
3739
itervalues = dict.values

0 commit comments

Comments
 (0)