summaryrefslogtreecommitdiff
path: root/paramiko/hostkeys.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2017-10-10 18:24:34 -0700
committerJeff Forcier <jeff@bitprophet.org>2017-10-10 18:24:38 -0700
commit29ac57f565ac94021dee46b365daa56a3d27333e (patch)
treedda22abe6f5eba8118b225c55fac2f7a09237e4e /paramiko/hostkeys.py
parent9019b25497c2b143e06da6a393e24b67bfc848f0 (diff)
downloadparamiko-1070-remove-python26-and-33.tar.gz
String format modernization, part 11070-remove-python26-and-33
Choosing to skip it in some edge/corner cases where it's more harmful than helpful. Also choosing to replace many non-%s specifiers with regular old {} since I don't see why one would normally care. Again, eschewing that in spots where it seems like it might matter.
Diffstat (limited to 'paramiko/hostkeys.py')
-rw-r--r--paramiko/hostkeys.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/paramiko/hostkeys.py b/paramiko/hostkeys.py
index d023b33d..7bd75bb5 100644
--- a/paramiko/hostkeys.py
+++ b/paramiko/hostkeys.py
@@ -300,7 +300,7 @@ class HostKeys (MutableMapping):
salt = decodebytes(b(salt))
assert len(salt) == sha1().digest_size
hmac = HMAC(salt, b(hostname), sha1).digest()
- hostkey = '|1|%s|%s' % (u(encodebytes(salt)), u(encodebytes(hmac)))
+ hostkey = '|1|{}|{}'.format(u(encodebytes(salt)), u(encodebytes(hmac)))
return hostkey.replace('\n', '')
@@ -338,8 +338,9 @@ class HostKeyEntry:
fields = line.split(' ')
if len(fields) < 3:
# Bad number of fields
- log.info("Not enough fields found in known_hosts in line %s (%r)" %
- (lineno, line))
+ log.info("Not enough fields found in known_hosts in line {} ({!r})".format(
+ lineno, line
+ ))
return None
fields = fields[:3]
@@ -359,7 +360,7 @@ class HostKeyEntry:
elif keytype == 'ssh-ed25519':
key = Ed25519Key(data=decodebytes(key))
else:
- log.info("Unable to handle key of type %s" % (keytype,))
+ log.info("Unable to handle key of type {}".format(keytype))
return None
except binascii.Error as e:
@@ -374,11 +375,12 @@ class HostKeyEntry:
included.
"""
if self.valid:
- return '%s %s %s\n' % (
+ return '{} {} {}\n'.format(
','.join(self.hostnames),
self.key.get_name(),
- self.key.get_base64())
+ self.key.get_base64(),
+ )
return None
def __repr__(self):
- return '<HostKeyEntry %r: %r>' % (self.hostnames, self.key)
+ return '<HostKeyEntry {!r}: {!r}>'.format(self.hostnames, self.key)