From 29ac57f565ac94021dee46b365daa56a3d27333e Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Tue, 10 Oct 2017 18:24:34 -0700 Subject: String format modernization, part 1 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. --- paramiko/sftp_attr.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'paramiko/sftp_attr.py') diff --git a/paramiko/sftp_attr.py b/paramiko/sftp_attr.py index 5597948a..ea12b2f6 100644 --- a/paramiko/sftp_attr.py +++ b/paramiko/sftp_attr.py @@ -82,7 +82,7 @@ class SFTPAttributes (object): return attr def __repr__(self): - return '' % self._debug_str() + return ''.format(self._debug_str()) # ...internals... @classmethod @@ -146,15 +146,15 @@ class SFTPAttributes (object): def _debug_str(self): out = '[ ' if self.st_size is not None: - out += 'size=%d ' % self.st_size + out += 'size={} '.format(self.st_size) if (self.st_uid is not None) and (self.st_gid is not None): - out += 'uid=%d gid=%d ' % (self.st_uid, self.st_gid) + out += 'uid={} gid={} '.format(self.st_uid, self.st_gid) if self.st_mode is not None: out += 'mode=' + oct(self.st_mode) + ' ' if (self.st_atime is not None) and (self.st_mtime is not None): - out += 'atime=%d mtime=%d ' % (self.st_atime, self.st_mtime) + out += 'atime={} mtime={} '.format(self.st_atime, self.st_mtime) for k, v in self.attr.items(): - out += '"%s"=%r ' % (str(k), v) + out += '"{}"={!r} '.format(str(k), v) out += ']' return out @@ -222,8 +222,12 @@ class SFTPAttributes (object): if size is None: size = 0 + # TODO: not sure this actually worked as expected beforehand, leaving + # it untouched for the time being, re: .format() upgrade, until someone + # has time to doublecheck return '%s 1 %-8d %-8d %8d %-12s %s' % ( - ks, uid, gid, size, datestr, filename) + ks, uid, gid, size, datestr, filename, + ) def asbytes(self): return b(str(self)) -- cgit v1.2.1