diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2017-06-01 14:08:08 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-03-01 10:34:56 -0800 |
commit | 0dcb8ad0e829fddea92c5a76e2849e55617f7825 (patch) | |
tree | e77eb1fad21241bfde217175e3d9a33d5ce3b7ab /alot | |
parent | 06972159673c16919ddaf19ee839387af6e69a51 (diff) |
repalces uses of dict.iter* with non-iter versions
in python3 dict.{keys,items,values} return views, which are similar to
iterators without some of the caveats about modifying the underlying
object. The iter* and view* methods have been removed, instead one warps
dict.x in iter or list to get those types.
Diffstat (limited to 'alot')
-rw-r--r-- | alot/buffers.py | 2 | ||||
-rw-r--r-- | alot/commands/globals.py | 8 | ||||
-rw-r--r-- | alot/commands/thread.py | 2 | ||||
-rw-r--r-- | alot/db/envelope.py | 2 | ||||
-rw-r--r-- | alot/db/thread.py | 6 | ||||
-rw-r--r-- | alot/ui.py | 5 | ||||
-rw-r--r-- | alot/widgets/globals.py | 2 |
7 files changed, 13 insertions, 14 deletions
diff --git a/alot/buffers.py b/alot/buffers.py index e04ae342..bfff3897 100644 --- a/alot/buffers.py +++ b/alot/buffers.py @@ -147,7 +147,7 @@ class EnvelopeBuffer(Buffer): hidden = settings.get('envelope_headers_blacklist') # build lines lines = [] - for (k, vlist) in self.envelope.headers.iteritems(): + for (k, vlist) in self.envelope.headers.items(): if (k not in hidden) or self.all_headers: for value in vlist: lines.append((k, value)) diff --git a/alot/commands/globals.py b/alot/commands/globals.py index 228502e7..7e9b1bd9 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -381,7 +381,7 @@ class CallCommand(Command): hooks = settings.hooks if hooks: env = {'ui': ui, 'settings': settings} - for k, v in env.iteritems(): + for k, v in env.items(): if k not in hooks.__dict__: hooks.__dict__[k] = v @@ -628,7 +628,7 @@ class HelpCommand(Command): if modemaps: txt = (section_att, '\n%s-mode specific maps' % ui.mode) linewidgets.append(urwid.Text(txt)) - for (k, v) in modemaps.iteritems(): + for (k, v) in modemaps.items(): line = urwid.Columns([('fixed', keycolumnwidth, urwid.Text((text_att, k))), urwid.Text((text_att, v))]) @@ -636,7 +636,7 @@ class HelpCommand(Command): # global maps linewidgets.append(urwid.Text((section_att, '\nglobal maps'))) - for (k, v) in globalmaps.iteritems(): + for (k, v) in globalmaps.items(): if k not in modemaps: line = urwid.Columns( [('fixed', keycolumnwidth, urwid.Text((text_att, k))), @@ -779,7 +779,7 @@ class ComposeCommand(Command): return # set forced headers - for key, value in self.headers.iteritems(): + for key, value in self.headers.items(): self.envelope.add(key, value) # set forced headers for separate parameters diff --git a/alot/commands/thread.py b/alot/commands/thread.py index c8fb634c..1066a7e3 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -313,7 +313,7 @@ class ReplyCommand(Command): res = dict() for name, address in getaddresses(recipients): res[address] = name - urecipients = [formataddr((n, a)) for a, n in res.iteritems()] + urecipients = [formataddr((n, a)) for a, n in res.items()] return sorted(urecipients) diff --git a/alot/db/envelope.py b/alot/db/envelope.py index bb440a00..df13e7bd 100644 --- a/alot/db/envelope.py +++ b/alot/db/envelope.py @@ -272,7 +272,7 @@ class Envelope(object): headers['User-Agent'] = [uastring] # copy headers from envelope to mail - for k, vlist in headers.iteritems(): + for k, vlist in headers.items(): for v in vlist: outer_msg[k] = encode_header(k, v) diff --git a/alot/db/thread.py b/alot/db/thread.py index 3d9144db..25b75fb1 100644 --- a/alot/db/thread.py +++ b/alot/db/thread.py @@ -86,7 +86,7 @@ class Thread(object): """ tags = set(list(self._tags)) if intersection: - for m in self.get_messages().iterkeys(): + for m in self.get_messages().keys(): tags = tags.intersection(set(m.get_tags())) return tags @@ -157,7 +157,7 @@ class Thread(object): if self._authors is None: # Sort messages with date first (by date ascending), and those # without a date last. - msgs = sorted(self.get_messages().iterkeys(), + msgs = sorted(self.get_messages().keys(), key=lambda m: m.get_date() or datetime.max) orderby = settings.get('thread_authors_order_by') @@ -257,7 +257,7 @@ class Thread(object): """ mid = msg.get_message_id() msg_hash = self.get_messages() - for m in msg_hash.iterkeys(): + for m in msg_hash.keys(): if m.get_message_id() == mid: return msg_hash[m] return None @@ -529,9 +529,8 @@ class UI(object): :rtype: :class:`twisted.defer.Deferred` """ choices = choices or {'y': 'yes', 'n': 'no'} - choices_to_return = choices_to_return or {} - assert select is None or select in choices.itervalues() - assert cancel is None or cancel in choices.itervalues() + assert select is None or select in choices.values() + assert cancel is None or cancel in choices.values() assert msg_position in ['left', 'above'] d = defer.Deferred() # create return deferred diff --git a/alot/widgets/globals.py b/alot/widgets/globals.py index 1a8688fe..b6e662b2 100644 --- a/alot/widgets/globals.py +++ b/alot/widgets/globals.py @@ -54,7 +54,7 @@ class ChoiceWidget(urwid.Text): self.separator = separator items = [] - for k, v in choices.iteritems(): + for k, v in choices.items(): if v == select and select is not None: items += ['[', k, ']:', v] else: |