summaryrefslogtreecommitdiff
path: root/alot/commands
diff options
context:
space:
mode:
authorLucas Hoffmann <l-m-h@web.de>2016-07-14 13:30:52 +0200
committerLucas Hoffmann <l-m-h@web.de>2016-12-09 11:26:15 +0100
commitd89bbe11537abfceb3d0c7b62b9325fceaf51e32 (patch)
tree7bb9697a7a2aac29da8f529cdca44ee050023dc2 /alot/commands
parente2de9282a33a8906077a3d223d025367071bce6b (diff)
Use logging's native string interpolation
Diffstat (limited to 'alot/commands')
-rw-r--r--alot/commands/__init__.py6
-rw-r--r--alot/commands/envelope.py9
-rw-r--r--alot/commands/globals.py24
-rw-r--r--alot/commands/search.py8
-rw-r--r--alot/commands/thread.py18
5 files changed, 32 insertions, 33 deletions
diff --git a/alot/commands/__init__.py b/alot/commands/__init__.py
index 095c068d..d19508ab 100644
--- a/alot/commands/__init__.py
+++ b/alot/commands/__init__.py
@@ -168,7 +168,7 @@ def commandfactory(cmdline, mode='global'):
# split commandname and parameters
if not cmdline:
return None
- logging.debug('mode:%s got commandline "%s"' % (mode, cmdline))
+ logging.debug('mode:%s got commandline "%s"', mode, cmdline)
# allow to shellescape without a space after '!'
if cmdline.startswith('!'):
cmdline = 'shellescape \'%s\'' % cmdline[1:]
@@ -178,7 +178,7 @@ def commandfactory(cmdline, mode='global'):
except ValueError as e:
raise CommandParseError(e.message)
args = map(lambda x: alot.helper.string_decode(x, 'utf-8'), args)
- logging.debug('ARGS: %s' % args)
+ logging.debug('ARGS: %s', args)
cmdname = args[0]
args = args[1:]
@@ -195,7 +195,7 @@ def commandfactory(cmdline, mode='global'):
parms = vars(parser.parse_args(args))
parms.update(forcedparms)
- logging.debug('cmd parms %s' % parms)
+ logging.debug('cmd parms %s', parms)
# create Command
cmd = cmdclass(**parms)
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index e14d2f55..712c2c76 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -56,7 +56,7 @@ class AttachCommand(Command):
ui.notify('no files specified, abort')
return
- logging.info("attaching: %s" % files)
+ logging.info("attaching: %s", files)
for path in files:
envelope.attach(path)
ui.current_buffer.rebuild()
@@ -193,8 +193,7 @@ class SendCommand(Command):
# don't do anything if another SendCommand is in the middle of
# sending the message and we were triggered accidentally
if self.envelope.sending:
- msg = 'sending this message already!'
- logging.debug(msg)
+ logging.debug('sending this message already!')
return
clearme = ui.notify(u'constructing mail (GPG, attachments)\u2026',
@@ -314,7 +313,7 @@ class EditCommand(Command):
if '*' in blacklist:
blacklist = set(self.envelope.headers.keys())
edit_headers = edit_headers - blacklist
- logging.info('editable headers: %s' % edit_headers)
+ logging.info('editable headers: %s', edit_headers)
def openEnvelopeFromTmpfile():
# This parses the input from the tempfile.
@@ -565,7 +564,7 @@ class EncryptCommand(Command):
recipient = match.group(1)
self.encrypt_keys.append(recipient)
- logging.debug("encryption keys: " + str(self.encrypt_keys))
+ logging.debug("encryption keys: %s", self.encrypt_keys)
keys = yield get_keys(ui, self.encrypt_keys,
signed_only=self.trusted)
if self.trusted:
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index af3500ca..6e4ac673 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -125,7 +125,7 @@ class PromptCommand(Command):
completer=cmpl,
history=ui.commandprompthistory,
)
- logging.debug('CMDLINE: %s' % cmdline)
+ logging.debug('CMDLINE: %s', cmdline)
# interpret and apply commandline
if cmdline:
@@ -193,13 +193,13 @@ class ExternalCommand(Command):
if touchhook is not None:
logging.debug('calling hook: touch_external_cmdlist')
res = touchhook(cmd, shell=shell, spawn=spawn, thread=thread)
- logging.debug('got: %s' % res)
+ logging.debug('got: %s', res)
cmd, shell, self.in_thread = res
# otherwise if spawn requested and X11 is running
elif spawn:
if 'DISPLAY' in os.environ:
term_cmd = settings.get('terminal_cmd', '')
- logging.info('spawn in terminal: %s' % term_cmd)
+ logging.info('spawn in terminal: %s', term_cmd)
termcmdlist = split_commandstring(term_cmd)
cmd = termcmdlist + cmd
else:
@@ -214,7 +214,7 @@ class ExternalCommand(Command):
Command.__init__(self, **kwargs)
def apply(self, ui):
- logging.debug('cmdlist: %s' % self.cmdlist)
+ logging.debug('cmdlist: %s', self.cmdlist)
callerbuffer = ui.current_buffer
# set standard input for subcommand
@@ -236,7 +236,7 @@ class ExternalCommand(Command):
logging.info('refocussing')
ui.buffer_focus(callerbuffer)
- logging.info('calling external command: %s' % self.cmdlist)
+ logging.info('calling external command: %s', self.cmdlist)
def thread_code(*args):
try:
@@ -297,7 +297,7 @@ class EditCommand(ExternalCommand):
editor_cmdstring = '/usr/bin/editor'
editor_cmdstring = os.environ.get('EDITOR', editor_cmdstring)
editor_cmdstring = settings.get('editor_cmd') or editor_cmdstring
- logging.debug('using editor_cmd: %s' % editor_cmdstring)
+ logging.debug('using editor_cmd: %s', editor_cmdstring)
self.cmdlist = None
if '%s' in editor_cmdstring:
@@ -549,8 +549,8 @@ class FlushCommand(Command):
ui.mainloop.set_alarm_in(timeout, f)
if not ui.db_was_locked:
if not self.silent:
- ui.notify(
- 'index locked, will try again in %d secs' % timeout)
+ ui.notify('index locked, will try again in %d secs'
+ % timeout)
ui.db_was_locked = True
ui.update()
return
@@ -620,7 +620,7 @@ class HelpCommand(Command):
('relative', 70))
ui.show_as_root_until_keypress(overlay, 'esc')
else:
- logging.debug('HELP %s' % self.commandname)
+ logging.debug('HELP %s', self.commandname)
parser = commands.lookup_parser(self.commandname, ui.mode)
if parser:
ui.notify(parser.format_help(), block=True)
@@ -828,7 +828,7 @@ class ComposeCommand(Command):
if settings.get('ask_subject') and \
'Subject' not in self.envelope.headers:
subject = yield ui.prompt('Subject')
- logging.debug('SUBJECT: "%s"' % subject)
+ logging.debug('SUBJECT: "%s"', subject)
if subject is None:
raise CommandCanceled()
@@ -847,7 +847,7 @@ class ComposeCommand(Command):
for gpath in self.attach:
for a in glob.glob(gpath):
self.envelope.attach(a)
- logging.debug('attaching: ' + a)
+ logging.debug('attaching: %s', a)
# set encryption if needed
if self.encrypt or account.encrypt_by_default == u"all":
@@ -893,7 +893,7 @@ class ComposeCommand(Command):
recipient = match.group(1)
encrypt_keys.append(recipient)
- logging.debug("encryption keys: " + str(encrypt_keys))
+ logging.debug("encryption keys: %s", encrypt_keys)
keys = yield get_keys(ui, encrypt_keys, block_error=self.encrypt,
signed_only=trusted_only)
if keys:
diff --git a/alot/commands/search.py b/alot/commands/search.py
index 0001a0bd..7a2184ae 100644
--- a/alot/commands/search.py
+++ b/alot/commands/search.py
@@ -33,7 +33,7 @@ class OpenThreadCommand(Command):
self.thread = ui.current_buffer.get_selected_thread()
if self.thread:
query = ui.current_buffer.querystring
- logging.info('open thread view for %s' % self.thread)
+ logging.info('open thread view for %s', self.thread)
sb = buffers.ThreadBuffer(ui, self.thread)
ui.buffer_open(sb)
@@ -185,13 +185,13 @@ class TagCommand(Command):
if not self.allm:
testquery = "(%s) AND thread:%s" % (testquery,
thread.get_thread_id())
- logging.debug('all? %s' % self.allm)
- logging.debug('q: %s' % testquery)
+ logging.debug('all? %s', self.allm)
+ logging.debug('q: %s', testquery)
hitcount_before = ui.dbman.count_messages(testquery)
def remove_thread():
- logging.debug('remove thread from result list: %s' % thread)
+ logging.debug('remove thread from result list: %s', thread)
if threadline_widget in searchbuffer.threadlist:
# remove this thread from result list
searchbuffer.threadlist.remove(threadline_widget)
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 1cdd6b38..f5c6141d 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -70,7 +70,7 @@ def determine_sender(mail, action='reply'):
break
candidate_addresses = getaddresses(mail.get_all(candidate_header, []))
- logging.debug('candidate addresses: %s' % candidate_addresses)
+ logging.debug('candidate addresses: %s', candidate_addresses)
# pick the most important account that has an address in candidates
# and use that accounts realname and the address found here
for account in my_accounts:
@@ -99,8 +99,8 @@ def determine_sender(mail, action='reply'):
account = my_accounts[0]
realname = account.realname
address = account.address
- logging.debug('using realname: "%s"' % realname)
- logging.debug('using address: %s' % address)
+ logging.debug('using realname: "%s"', realname)
+ logging.debug('using address: %s', address)
from_value = address if realname == '' else '%s <%s>' % (realname, address)
return from_value, account
@@ -232,7 +232,7 @@ class ReplyCommand(Command):
envelope.add('Cc', decode_header(cc))
to = ', '.join(recipients)
- logging.debug('reply to: %s' % to)
+ logging.debug('reply to: %s', to)
if self.listreply:
# To choose the target of the reply --list
@@ -244,7 +244,7 @@ class ReplyCommand(Command):
# to deal with the one in sent
if to is None:
to = mail['To']
- logging.debug('mail list reply to: %s' % to)
+ logging.debug('mail list reply to: %s', to)
# Cleaning the 'To' in this case
if envelope.get('To') is not None:
envelope.__delitem__('To')
@@ -261,7 +261,7 @@ class ReplyCommand(Command):
# check if any recipient address matches a known mailing list
if any([addr in lists for n, addr in getaddresses(allrecipients)]):
followupto = ', '.join(allrecipients)
- logging.debug('mail followup to: %s' % followupto)
+ logging.debug('mail followup to: %s', followupto)
envelope.add('Mail-Followup-To', decode_header(followupto))
# set In-Reply-To header
@@ -540,7 +540,7 @@ class ChangeDisplaymodeCommand(Command):
def apply(self, ui):
tbuffer = ui.current_buffer
- logging.debug('matching lines %s...' % (self.query))
+ logging.debug('matching lines %s...', self.query)
if self.query is None:
messagetrees = [tbuffer.get_selected_messagetree()]
else:
@@ -715,7 +715,7 @@ class PipeCommand(Command):
# do teh monkey
for mail in pipestrings:
if self.background:
- logging.debug('call in background: %s' % str(self.cmd))
+ logging.debug('call in background: %s', self.cmd)
proc = subprocess.Popen(self.cmd,
shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
@@ -726,7 +726,7 @@ class PipeCommand(Command):
else:
logging.debug('stop urwid screen')
ui.mainloop.screen.stop()
- logging.debug('call: %s' % str(self.cmd))
+ logging.debug('call: %s', self.cmd)
# if proc.stdout is defined later calls to communicate
# seem to be non-blocking!
proc = subprocess.Popen(self.cmd, shell=True,