diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-01-21 09:53:40 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-01-21 09:53:40 +0100 |
commit | f9b1260a6c4dec2c3b4291c7a206e04ec6b691bd (patch) | |
tree | c7ac236bff044dd8ef73ac84d75315793f8884ca | |
parent | 4d467ddda9266627f9c857142ea602d853b57c5e (diff) |
Use super() where applicable.
-rw-r--r-- | alot/addressbook/abook.py | 2 | ||||
-rw-r--r-- | alot/addressbook/external.py | 2 | ||||
-rw-r--r-- | alot/commands/envelope.py | 20 | ||||
-rw-r--r-- | alot/commands/globals.py | 31 | ||||
-rw-r--r-- | alot/commands/namedqueries.py | 2 | ||||
-rw-r--r-- | alot/commands/search.py | 4 | ||||
-rw-r--r-- | alot/commands/thread.py | 32 | ||||
-rw-r--r-- | alot/completion/abooks.py | 2 | ||||
-rw-r--r-- | alot/completion/accounts.py | 3 | ||||
-rw-r--r-- | alot/completion/argparse.py | 2 | ||||
-rw-r--r-- | alot/completion/command.py | 2 | ||||
-rw-r--r-- | alot/completion/commandline.py | 2 | ||||
-rw-r--r-- | alot/completion/commandname.py | 2 | ||||
-rw-r--r-- | alot/completion/contacts.py | 2 | ||||
-rw-r--r-- | alot/completion/cryptokey.py | 2 | ||||
-rw-r--r-- | alot/completion/multipleselection.py | 2 | ||||
-rw-r--r-- | alot/completion/namedquery.py | 2 | ||||
-rw-r--r-- | alot/completion/query.py | 2 | ||||
-rw-r--r-- | alot/completion/stringlist.py | 2 | ||||
-rw-r--r-- | alot/completion/tag.py | 2 | ||||
-rw-r--r-- | alot/completion/tags.py | 2 |
21 files changed, 70 insertions, 52 deletions
diff --git a/alot/addressbook/abook.py b/alot/addressbook/abook.py index 6e2aa756..705a646d 100644 --- a/alot/addressbook/abook.py +++ b/alot/addressbook/abook.py @@ -13,7 +13,7 @@ class AbookAddressBook(AddressBook): :param path: path to abook addressbook file :type path: str """ - AddressBook.__init__(self, **kwargs) + super().__init__(**kwargs) DEFAULTSPATH = os.path.join(os.path.dirname(__file__), '..', 'defaults') self._spec = os.path.join(DEFAULTSPATH, 'abook_contacts.spec') diff --git a/alot/addressbook/external.py b/alot/addressbook/external.py index eea70cbc..cd300a42 100644 --- a/alot/addressbook/external.py +++ b/alot/addressbook/external.py @@ -34,7 +34,7 @@ class ExternalAddressbook(AddressBook): according to the search string. :type external_filtering: bool """ - AddressBook.__init__(self, **kwargs) + super().__init__(**kwargs) self.commandline = commandline self.regex = regex self.reflags = reflags diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index 457fe48a..fa45f669 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -44,7 +44,7 @@ class AttachCommand(Command): :param path: files to attach (globable string) :type path: str """ - Command.__init__(self, **kwargs) + super().__init__(**kwargs) self.path = path def apply(self, ui): @@ -74,7 +74,7 @@ class UnattachCommand(Command): :param hint: which attached file to remove :type hint: str """ - Command.__init__(self, **kwargs) + super().__init__(**kwargs) self.hint = hint def apply(self, ui): @@ -98,7 +98,7 @@ class RefineCommand(Command): :param key: key of the header to change :type key: str """ - Command.__init__(self, **kwargs) + super().__init__(**kwargs) self.key = key async def apply(self, ui): @@ -162,7 +162,7 @@ class SendCommand(Command): will be ignored in case the mail parameter is set. :type envelope: alot.db.envelope.envelope """ - Command.__init__(self, **kwargs) + super().__init__(**kwargs) self.mail = mail self.envelope = envelope self.envelope_buffer = None @@ -328,7 +328,7 @@ class EditCommand(Command): self.force_spawn = spawn self.refocus = refocus self.edit_only_body = False - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): ebuffer = ui.current_buffer @@ -435,7 +435,7 @@ class SetCommand(Command): self.key = key self.value = ' '.join(value) self.reset = not append - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): envelope = ui.current_buffer.envelope @@ -462,7 +462,7 @@ class UnsetCommand(Command): :type key: str """ self.key = key - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): del ui.current_buffer.envelope[self.key] @@ -510,7 +510,7 @@ class SignCommand(Command): """ self.action = action self.keyid = keyid - Command.__init__(self, **kwargs) + super().__init__(**kwargs) def apply(self, ui): sign = None @@ -597,7 +597,7 @@ class EncryptCommand(Command): self.encrypt_keys = keyids self.action = action self.trusted = trusted - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): envelope = ui.current_buffer.envelope @@ -671,7 +671,7 @@ class TagCommand(Command): assert isinstance(tags, str), 'tags should be a unicode string' self.tagsstring = tags self.action = action - Command.__init__(self, **kwargs) + super().__init__(**kwargs) def apply(self, ui): ebuffer = ui.current_buffer diff --git a/alot/commands/globals.py b/alot/commands/globals.py index ee49667d..3e53a450 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -97,7 +97,7 @@ class SearchCommand(Command): """ self.query = ' '.join(query) self.order = sort - Command.__init__(self, **kwargs) + super().__init__(**kwargs) def apply(self, ui): if self.query: @@ -131,7 +131,7 @@ class PromptCommand(Command): :type startwith: str """ self.startwith = startwith - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): logging.info('open command shell') @@ -230,7 +230,7 @@ class ExternalCommand(Command): self.refocus = refocus self.in_thread = thread self.on_success = on_success - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): logging.debug('cmdlist: %s', self.cmdlist) @@ -341,9 +341,8 @@ class EditCommand(ExternalCommand): self.cmdlist = split_commandstring(editor_cmdstring) + [path] logging.debug({'spawn: ': self.spawn, 'in_thread': self.thread}) - ExternalCommand.__init__(self, self.cmdlist, - spawn=self.spawn, thread=self.thread, - **kwargs) + super().__init__(self.cmdlist, spawn = self.spawn, thread = self.thread, + **kwargs) async def apply(self, ui): if self.cmdlist is None: @@ -368,7 +367,7 @@ class RepeatCommand(Command): """repeat the command executed last time""" def __init__(self, **kwargs): - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): if ui.last_commandline is not None: @@ -389,7 +388,7 @@ class CallCommand(Command): :param command: python command string to call :type command: str """ - Command.__init__(self, **kwargs) + super().__init__(**kwargs) self.command = command async def apply(self, ui): @@ -431,7 +430,7 @@ class BufferCloseCommand(Command): self.buffer = buffer self.force = force self.redraw = redraw - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): async def one_buffer(prompt=True): @@ -503,7 +502,7 @@ class BufferFocusCommand(Command): self.buffer = buffer self.index = index self.offset = offset - Command.__init__(self, **kwargs) + super().__init__(**kwargs) def apply(self, ui): if self.buffer is None: @@ -530,7 +529,7 @@ class OpenBufferlistCommand(Command): :type filtfun: callable (str->bool) """ self.filtfun = filtfun - Command.__init__(self, **kwargs) + super().__init__(**kwargs) def apply(self, ui): blists = ui.get_buffers_of_type(buffers.BufferlistBuffer) @@ -549,7 +548,7 @@ class TagListCommand(Command): """opens taglist buffer""" def __init__(self, tags=None, **kwargs): self.tags = tags - Command.__init__(self, **kwargs) + super().__init__(**kwargs) def apply(self, ui): tags = frozenset(self.tags) if self.tags else ui.dbman.get_all_tags() @@ -572,7 +571,7 @@ class NamedQueriesCommand(Command): :type filtfun: callable (str->bool) """ self.filtfun = filtfun - Command.__init__(self, **kwargs) + super().__init__(**kwargs) def apply(self, ui): ui.buffer_open(buffers.NamedQueriesBuffer(ui.dbman, self.filtfun)) @@ -589,7 +588,7 @@ class HelpCommand(Command): :param commandname: command to document :type commandname: str """ - Command.__init__(self, **kwargs) + super().__init__(**kwargs) self.commandname = commandname def apply(self, ui): @@ -709,7 +708,7 @@ class ComposeCommand(Command): :type encrypt: bool """ - Command.__init__(self, **kwargs) + super().__init__(**kwargs) self.envelope = envelope self.template = template @@ -998,7 +997,7 @@ class MoveCommand(Command): self.movement = '' else: self.movement = ' '.join(movement) - Command.__init__(self, **kwargs) + super().__init__(**kwargs) def apply(self, ui): if self.movement in ['up', 'down', 'page up', 'page down']: diff --git a/alot/commands/namedqueries.py b/alot/commands/namedqueries.py index f10724a8..e2bc301b 100644 --- a/alot/commands/namedqueries.py +++ b/alot/commands/namedqueries.py @@ -18,7 +18,7 @@ class NamedqueriesSelectCommand(Command): """search for messages with selected query""" def __init__(self, filt=None, **kwargs): self._filt = filt - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): query_name = ui.current_buffer.get_selected_query() diff --git a/alot/commands/search.py b/alot/commands/search.py index 762e9ec8..14f267cd 100644 --- a/alot/commands/search.py +++ b/alot/commands/search.py @@ -56,7 +56,7 @@ class RefineCommand(Command): else: self.querystring = ' '.join(query) self.sort_order = sort - Command.__init__(self, **kwargs) + super().__init__(**kwargs) def apply(self, ui): if self.querystring or self.sort_order: @@ -141,7 +141,7 @@ class TagCommand(Command): self.tagsstring = tags self.action = action self.allm = allmessages - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): searchbuffer = ui.current_buffer diff --git a/alot/commands/thread.py b/alot/commands/thread.py index 7523f46b..84b1c611 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -151,7 +151,7 @@ class ReplyCommand(Command): self.groupreply = all self.listreply = listreply self.force_spawn = spawn - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): # get message to reply to if not given in constructor @@ -325,7 +325,7 @@ class ForwardCommand(Command): self.message = message self.inline = not attach self.force_spawn = spawn - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): # get message to forward if not given in constructor @@ -406,7 +406,7 @@ class BounceMailCommand(Command): :type message: `alot.db.message.Message` """ self.message = message - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): # get mail to bounce @@ -473,7 +473,7 @@ class EditNewCommand(Command): """ self.message = message self.force_spawn = spawn - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): if not self.message: @@ -556,7 +556,7 @@ class ChangeDisplaymodeCommand(Command): self.fold = fold self.weight = weight self.cycle_alt = cycle_alt - Command.__init__(self, **kwargs) + super().__init__(**kwargs) def apply(self, ui): tbuffer = ui.current_buffer @@ -681,7 +681,7 @@ class PipeCommand(Command): :param done_msg: notification message to show upon success :type done_msg: str """ - Command.__init__(self, **kwargs) + super().__init__(**kwargs) if isinstance(cmd, str): cmd = split_commandstring(cmd) self.cmd = cmd @@ -825,13 +825,13 @@ class PrintCommand(PipeCommand): noop_msg = 'no print command specified. Set "print_cmd" in the '\ 'global section.' - PipeCommand.__init__(self, [cmd], all=all, separately=separately, - background=True, - shell=False, - format='raw' if raw else 'decoded', - add_tags=add_tags, - noop_msg=noop_msg, confirm_msg=confirm_msg, - done_msg=ok_msg, **kwargs) + super().__init__([cmd], all=all, separately=separately, + background=True, + shell=False, + format='raw' if raw else 'decoded', + add_tags=add_tags, + noop_msg=noop_msg, confirm_msg=confirm_msg, + done_msg=ok_msg, **kwargs) @registerCommand(MODE, 'save', arguments=[ @@ -848,7 +848,7 @@ class SaveAttachmentCommand(Command): directory. :type path: str """ - Command.__init__(self, **kwargs) + super().__init__(**kwargs) self.all = all self.path = path @@ -903,7 +903,7 @@ class OpenAttachmentCommand(Command): :param attachment: attachment to open :type attachment: :class:`~alot.db.attachment.Attachment` """ - Command.__init__(self, **kwargs) + super().__init__(**kwargs) self.attachment = attachment async def apply(self, ui): @@ -1085,7 +1085,7 @@ class TagCommand(Command): self.tagsstring = tags self.all = all self.action = action - Command.__init__(self, **kwargs) + super().__init__(**kwargs) async def apply(self, ui): if self.all: diff --git a/alot/completion/abooks.py b/alot/completion/abooks.py index c5bfe3e8..bc5584e8 100644 --- a/alot/completion/abooks.py +++ b/alot/completion/abooks.py @@ -22,6 +22,8 @@ class AbooksCompleter(Completer): self.abooks = abooks self.addressesonly = addressesonly + super().__init__() + def complete(self, original, pos): if not self.abooks: return [] diff --git a/alot/completion/accounts.py b/alot/completion/accounts.py index 3250a7c9..8bfd7e8d 100644 --- a/alot/completion/accounts.py +++ b/alot/completion/accounts.py @@ -14,5 +14,4 @@ class AccountCompleter(StringlistCompleter): accounts = settings.get_accounts() resultlist = [formataddr((a.realname, str(a.address))) for a in accounts] - StringlistCompleter.__init__(self, resultlist, match_anywhere=True, - **kwargs) + super().__init__(resultlist, match_anywhere = True, **kwargs) diff --git a/alot/completion/argparse.py b/alot/completion/argparse.py index ac15b2c6..6a480e7e 100644 --- a/alot/completion/argparse.py +++ b/alot/completion/argparse.py @@ -17,6 +17,8 @@ class ArgparseOptionCompleter(Completer): self.parser = parser self.actions = parser._optionals._actions + super().__init__() + def complete(self, original, pos): pref = original[:pos] diff --git a/alot/completion/command.py b/alot/completion/command.py index a320bf93..72c82ea3 100644 --- a/alot/completion/command.py +++ b/alot/completion/command.py @@ -40,6 +40,8 @@ class CommandCompleter(Completer): self.currentbuffer = currentbuffer self._commandnamecompleter = CommandNameCompleter(mode) + super().__init__() + @cached_property def _querycompleter(self): return QueryCompleter(self.dbman) diff --git a/alot/completion/commandline.py b/alot/completion/commandline.py index 0092c8e7..866ed66f 100644 --- a/alot/completion/commandline.py +++ b/alot/completion/commandline.py @@ -23,6 +23,8 @@ class CommandLineCompleter(Completer): """ self._commandcompleter = CommandCompleter(dbman, mode, currentbuffer) + super().__init__() + @staticmethod def get_context(line, pos): """ diff --git a/alot/completion/commandname.py b/alot/completion/commandname.py index 5c946eb6..6f71459b 100644 --- a/alot/completion/commandname.py +++ b/alot/completion/commandname.py @@ -17,6 +17,8 @@ class CommandNameCompleter(Completer): """ self.mode = mode + super().__init__() + def complete(self, original, pos): commandprefix = original[:pos] logging.debug('original="%s" prefix="%s"', original, commandprefix) diff --git a/alot/completion/contacts.py b/alot/completion/contacts.py index ae4e71cd..55304081 100644 --- a/alot/completion/contacts.py +++ b/alot/completion/contacts.py @@ -19,3 +19,5 @@ class ContactsCompleter(MultipleSelectionCompleter): """ self._completer = AbooksCompleter(abooks, addressesonly=addressesonly) self._separator = ', ' + + super().__init__() diff --git a/alot/completion/cryptokey.py b/alot/completion/cryptokey.py index 0631eee3..0ab2ed29 100644 --- a/alot/completion/cryptokey.py +++ b/alot/completion/cryptokey.py @@ -21,4 +21,4 @@ class CryptoKeyCompleter(StringlistCompleter): resultlist.append(s.keyid) for u in k.uids: resultlist.append(u.email) - StringlistCompleter.__init__(self, resultlist, match_anywhere=True) + super().__init__(resultlist, match_anywhere = True) diff --git a/alot/completion/multipleselection.py b/alot/completion/multipleselection.py index 45de5a28..28b7d38d 100644 --- a/alot/completion/multipleselection.py +++ b/alot/completion/multipleselection.py @@ -25,6 +25,8 @@ class MultipleSelectionCompleter(Completer): self._completer = completer self._separator = separator + super().__init__() + def relevant_part(self, original, pos): """Calculate the subword of `original` that `pos` is in.""" start = original.rfind(self._separator, 0, pos) diff --git a/alot/completion/namedquery.py b/alot/completion/namedquery.py index bcad5d2c..e166541b 100644 --- a/alot/completion/namedquery.py +++ b/alot/completion/namedquery.py @@ -15,4 +15,4 @@ class NamedQueryCompleter(StringlistCompleter): """ # mapping of alias to query string (dict str -> str) nqueries = dbman.get_named_queries() - StringlistCompleter.__init__(self, list(nqueries)) + super().__init__(list(nqueries)) diff --git a/alot/completion/query.py b/alot/completion/query.py index d073fde3..88bf3ae4 100644 --- a/alot/completion/query.py +++ b/alot/completion/query.py @@ -34,6 +34,8 @@ class QueryCompleter(Completer): self._tagcompleter = TagCompleter(dbman) self._nquerycompleter = NamedQueryCompleter(dbman) + super().__init__() + def complete(self, original, pos): mypart, start, end, mypos = self.relevant_part(original, pos) myprefix = mypart[:mypos] diff --git a/alot/completion/stringlist.py b/alot/completion/stringlist.py index 9d7fa3d3..c69a385f 100644 --- a/alot/completion/stringlist.py +++ b/alot/completion/stringlist.py @@ -20,6 +20,8 @@ class StringlistCompleter(Completer): self.flags = re.IGNORECASE if ignorecase else 0 self.match_anywhere = match_anywhere + super().__init__() + def complete(self, original, pos): pref = original[:pos] diff --git a/alot/completion/tag.py b/alot/completion/tag.py index fd6ed119..7b876841 100644 --- a/alot/completion/tag.py +++ b/alot/completion/tag.py @@ -14,4 +14,4 @@ class TagCompleter(StringlistCompleter): :type dbman: :class:`~alot.db.DBManager` """ resultlist = dbman.get_all_tags() - StringlistCompleter.__init__(self, resultlist) + super().__init__(resultlist) diff --git a/alot/completion/tags.py b/alot/completion/tags.py index b151e6f5..38b0a0cd 100644 --- a/alot/completion/tags.py +++ b/alot/completion/tags.py @@ -16,3 +16,5 @@ class TagsCompleter(MultipleSelectionCompleter): """ self._completer = TagCompleter(dbman) self._separator = ',' + + super().__init__() |