[PATCH 03/10] pylint: check for trailing whitespace

2 views
Skip to first unread message

Rob Browning

unread,
Sep 17, 2021, 1:15:40 PM9/17/21
to bup-...@googlegroups.com, Johannes Berg
From: Johannes Berg <joha...@sipsolutions.net>

Signed-off-by: Johannes Berg <joha...@sipsolutions.net>
Reviewed-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 5 ++++-
lib/bup/bloom.py | 2 +-
lib/bup/client.py | 4 ++--
lib/bup/cmd/bloom.py | 2 +-
lib/bup/cmd/fsck.py | 6 +++---
lib/bup/cmd/fuse.py | 2 +-
lib/bup/cmd/midx.py | 12 ++++++------
lib/bup/cmd/restore.py | 8 ++++----
lib/bup/cmd/server.py | 10 +++++-----
lib/bup/cmd/web.py | 6 +++---
lib/bup/drecurse.py | 2 +-
lib/bup/hashsplit.py | 4 ++--
lib/bup/helpers.py | 2 +-
lib/bup/index.py | 8 ++++----
lib/bup/main.py | 4 ++--
lib/bup/midx.py | 4 ++--
lib/bup/vfs.py | 12 ++++++------
17 files changed, 48 insertions(+), 45 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index 74e7c1f9..0b67f81d 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -2,4 +2,7 @@

[MESSAGES CONTROL]
disable=all
-enable=unused-import,unused-wildcard-import
+enable=
+ trailing-whitespace,
+ unused-import,
+ unused-wildcard-import
diff --git a/lib/bup/bloom.py b/lib/bup/bloom.py
index f8ae3dd0..cb982141 100644
--- a/lib/bup/bloom.py
+++ b/lib/bup/bloom.py
@@ -148,7 +148,7 @@ class ShaBloom:
return self._init_failed()
ver = struct.unpack('!I', self.map[4:8])[0]
if ver < BLOOM_VERSION:
- log('Warning: ignoring old-style (v%d) bloom %r\n'
+ log('Warning: ignoring old-style (v%d) bloom %r\n'
% (ver, filename))
return self._init_failed()
if ver > BLOOM_VERSION:
diff --git a/lib/bup/client.py b/lib/bup/client.py
index 9372d609..6eeb7081 100644
--- a/lib/bup/client.py
+++ b/lib/bup/client.py
@@ -162,11 +162,11 @@ class Client:
def check_busy(self):
if self._busy:
raise ClientError('already busy with command %r' % self._busy)
-
+
def ensure_busy(self):
if not self._busy:
raise ClientError('expected to be busy, but not busy?!')
-
+
def _not_busy(self):
self._busy = None

diff --git a/lib/bup/cmd/bloom.py b/lib/bup/cmd/bloom.py
index 27d26b14..1896f5e3 100755
--- a/lib/bup/cmd/bloom.py
+++ b/lib/bup/cmd/bloom.py
@@ -124,7 +124,7 @@ def do_bloom(path, outfilename, k, force):
icount = 0
for name in add:
ix = git.open_idx(name)
- qprogress('bloom: writing %.2f%% (%d/%d objects)\r'
+ qprogress('bloom: writing %.2f%% (%d/%d objects)\r'
% (icount*100.0/add_count, icount, add_count))
b.add_idx(ix)
count += 1
diff --git a/lib/bup/cmd/fsck.py b/lib/bup/cmd/fsck.py
index 0725f539..10074c8e 100755
--- a/lib/bup/cmd/fsck.py
+++ b/lib/bup/cmd/fsck.py
@@ -107,7 +107,7 @@ def quick_verify(base):
if sum.digest() != wantsum:
raise ValueError('expected %r, got %r' % (hexlify(wantsum),
sum.hexdigest()))
-
+

def git_verify(base):
if opt.quick:
@@ -119,8 +119,8 @@ def git_verify(base):
return 0
else:
return run([b'git', b'verify-pack', b'--', base])
-
-
+
+
def do_pack(base, last, par2_exists, out):
code = 0
if par2_ok and par2_exists and (opt.repair or not opt.generate):
diff --git a/lib/bup/cmd/fuse.py b/lib/bup/cmd/fuse.py
index 63071197..b1be8ac0 100755
--- a/lib/bup/cmd/fuse.py
+++ b/lib/bup/cmd/fuse.py
@@ -43,7 +43,7 @@ class BupFs(fuse.Fuse):
self.repo = repo
self.verbose = verbose
self.fake_metadata = fake_metadata
-
+
def getattr(self, path):
path = argv_bytes(path)
if self.verbose > 0:
diff --git a/lib/bup/cmd/midx.py b/lib/bup/cmd/midx.py
index 0d429583..ba13b4a0 100755
--- a/lib/bup/cmd/midx.py
+++ b/lib/bup/cmd/midx.py
@@ -55,7 +55,7 @@ def check_midx(name):
sub = git.open_idx(os.path.join(os.path.dirname(name), subname))
for ecount,e in enumerate(sub):
if not (ecount % 1234):
- qprogress(' %d/%d: %s %d/%d\r'
+ qprogress(' %d/%d: %s %d/%d\r'
% (count, len(ix.idxnames),
git.shorten_hash(subname).decode('ascii'),
ecount, len(sub)))
@@ -87,7 +87,7 @@ def _do_midx(outdir, outfilename, infilenames, prefixstr,
assert(outdir)
sum = hexlify(Sha1(b'\0'.join(infilenames)).digest())
outfilename = b'%s/midx-%s.midx' % (outdir, sum)
-
+
inp = []
total = 0
allfilenames = []
@@ -181,11 +181,11 @@ def do_midx_dir(path, outfilename, prout, auto=False, force=False,
m = git.open_idx(mname)
contents[mname] = [(b'%s/%s' % (path,i)) for i in m.idxnames]
sizes[mname] = len(m)
-
+
# sort the biggest+newest midxes first, so that we can eliminate
# smaller (or older) redundant ones that come later in the list
midxs.sort(key=lambda ix: (-sizes[ix], -xstat.stat(ix).st_mtime))
-
+
for mname in midxs:
any = 0
for iname in contents[mname]:
@@ -205,12 +205,12 @@ def do_midx_dir(path, outfilename, prout, auto=False, force=False,
sizes[iname] = len(i)

all = [(sizes[n],n) for n in (midxs + idxs)]
-
+
# FIXME: what are the optimal values? Does this make sense?
DESIRED_HWM = force and 1 or 5
DESIRED_LWM = force and 1 or 2
existed = dict((name,1) for sz,name in all)
- debug1('midx: %d indexes; want no more than %d.\n'
+ debug1('midx: %d indexes; want no more than %d.\n'
% (len(all), DESIRED_HWM))
if len(all) <= DESIRED_HWM:
debug1('midx: nothing to do.\n')
diff --git a/lib/bup/cmd/restore.py b/lib/bup/cmd/restore.py
index 825493ff..aeb1c7ba 100755
--- a/lib/bup/cmd/restore.py
+++ b/lib/bup/cmd/restore.py
@@ -75,7 +75,7 @@ def apply_metadata(meta, name, restore_numeric_ids, owner_map):
m.uid = owner_map['uid'].get(m.uid, m.uid)
m.gid = owner_map['gid'].get(m.gid, m.gid)
m.apply_to_path(name, restore_numeric_ids = restore_numeric_ids)
-
+
def hardlink_compatible(prev_path, prev_item, new_item, top):
prev_candidate = top + prev_path
if not os.path.exists(prev_candidate):
@@ -101,7 +101,7 @@ def hardlink_if_possible(fullname, item, top, hardlinks):

# FIXME: we can probably replace the target_vfs_path with the
# relevant vfs item
-
+
# hardlinks tracks a list of (restore_path, vfs_path, meta)
# triples for each path we've written for a given hardlink_target.
# This allows us to handle the case where we restore a set of
@@ -148,7 +148,7 @@ def write_file_content_sparsely(repo, dest_path, vfs_file):
os.ftruncate(outfd, pos)
finally:
os.close(outfd)
-
+
def restore(repo, parent_path, name, item, top, sparse, numeric_ids, owner_map,
exclude_rxs, verbosity, hardlinks):
global total_restored
@@ -225,7 +225,7 @@ def main(argv):
opt.remote = argv_bytes(opt.remote)
if opt.outdir:
opt.outdir = argv_bytes(opt.outdir)
-
+
git.check_repo_or_die()

if not extra:
diff --git a/lib/bup/cmd/server.py b/lib/bup/cmd/server.py
index 7cb5a2a1..824a9b25 100755
--- a/lib/bup/cmd/server.py
+++ b/lib/bup/cmd/server.py
@@ -24,7 +24,7 @@ def do_help(conn, junk):
def _set_mode():
global dumb_server_mode
dumb_server_mode = os.path.exists(git.repo(b'bup-dumb-server'))
- debug1('bup server: serving in %s mode\n'
+ debug1('bup server: serving in %s mode\n'
% (dumb_server_mode and 'dumb' or 'smart'))


@@ -56,7 +56,7 @@ def set_dir(conn, arg):
_init_session(arg)
conn.ok()

-
+
def list_indexes(conn, junk):
_init_session()
suffix = b''
@@ -98,7 +98,7 @@ def receive_objects_v2(conn, junk):
n = struct.unpack('!I', ns)[0]
#debug2('expecting %d bytes\n' % n)
if not n:
- debug1('bup server: received %d object%s.\n'
+ debug1('bup server: received %d object%s.\n'
% (w.count, w.count!=1 and "s" or ''))
fullpath = w.close(run_midx=not dumb_server_mode)
if fullpath:
@@ -111,7 +111,7 @@ def receive_objects_v2(conn, junk):
suspended_w = w
conn.ok()
return
-
+
shar = conn.read(20)
crcr = struct.unpack('!I', conn.read(4))[0]
n -= 20 + 4
@@ -135,7 +135,7 @@ def receive_objects_v2(conn, junk):
nw, crc = w._raw_write((buf,), sha=shar)
_check(w, crcr, crc, 'object read: expected crc %d, got %d\n')
# NOTREACHED
-
+

def _check(w, expected, actual, msg):
if expected != actual:
diff --git a/lib/bup/cmd/web.py b/lib/bup/cmd/web.py
index ccac6faa..d83fb12f 100755
--- a/lib/bup/cmd/web.py
+++ b/lib/bup/cmd/web.py
@@ -90,7 +90,7 @@ def _dir_contents(repo, resolution, show_hidden=False):

return display_name, link + url_query, display_size

- dir_item = resolution[-1][1]
+ dir_item = resolution[-1][1]
for name, item in vfs.contents(repo, dir_item):
if not show_hidden:
if (name not in (b'.', b'..')) and name.startswith(b'.'):
@@ -118,7 +118,7 @@ class BupRequestHandler(tornado.web.RequestHandler):

def head(self, path):
return self._process_request(path)
-
+
def _process_request(self, path):
print('Handling request for %s' % path)
sys.stdout.flush()
@@ -173,7 +173,7 @@ class BupRequestHandler(tornado.web.RequestHandler):
ctype = self._guess_type(path)
self.set_header("Last-Modified", http_date_from_utc_ns(meta.mtime))
self.set_header("Content-Type", ctype)
-
+
self.set_header("Content-Length", str(meta.size))
assert len(file_item.oid) == 20
self.set_header("Etag", hexlify(file_item.oid))
diff --git a/lib/bup/drecurse.py b/lib/bup/drecurse.py
index ba41a127..b948b39e 100644
--- a/lib/bup/drecurse.py
+++ b/lib/bup/drecurse.py
@@ -24,7 +24,7 @@ class OsFile:
def __init__(self, path):
self.fd = None
self.fd = os.open(path, os.O_RDONLY|O_LARGEFILE|O_NOFOLLOW|os.O_NDELAY)
-
+
def __del__(self):
if self.fd:
fd = self.fd
diff --git a/lib/bup/hashsplit.py b/lib/bup/hashsplit.py
index 16ccbb15..ff00e54b 100644
--- a/lib/bup/hashsplit.py
+++ b/lib/bup/hashsplit.py
@@ -37,12 +37,12 @@ class Buf:
self.data = cat_bytes(self.data, self.start, remaining,
s, 0, len(s))
self.start = 0
-
+
def peek(self, count):
if count <= 256:
return self.data[self.start : self.start + count]
return buffer(self.data, self.start, count)
-
+
def eat(self, count):
self.start += count

diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py
index b0cff727..e2f543f6 100644
--- a/lib/bup/helpers.py
+++ b/lib/bup/helpers.py
@@ -161,7 +161,7 @@ def progress(s):

def qprogress(s):
"""Calls progress() only if we haven't printed progress in a while.
-
+
This avoids overloading the stderr buffer with excess junk.
"""
global _last_prog
diff --git a/lib/bup/index.py b/lib/bup/index.py
index a2abfa7a..fde4a67d 100644
--- a/lib/bup/index.py
+++ b/lib/bup/index.py
@@ -127,7 +127,7 @@ class Level:
(ofs,n) = (f.tell(), len(self.list))
if self.list:
count = len(self.list)
- #log('popping %r with %d entries\n'
+ #log('popping %r with %d entries\n'
# % (''.join(self.ename), count))
for e in self.list:
e.write(f)
@@ -402,7 +402,7 @@ class ExistingEntry(Entry):

def __iter__(self):
return self.iter()
-
+

class Reader:
def __init__(self, filename):
@@ -557,7 +557,7 @@ class Writer:

def _add(self, ename, entry):
if self.lastfile and self.lastfile <= ename:
- raise Error('%r must come before %r'
+ raise Error('%r must come before %r'
% (''.join(ename), ''.join(self.lastfile)))
self.lastfile = ename
self.level = _golevel(self.level, self.f, ename, entry,
@@ -634,7 +634,7 @@ def reduce_paths(paths):
paths = []
prev = None
for (rp, p) in xpaths:
- if prev and (prev == rp
+ if prev and (prev == rp
or (prev.endswith(b'/') and rp.startswith(prev))):
continue # already superceded by previous path
paths.append((rp, p))
diff --git a/lib/bup/main.py b/lib/bup/main.py
index 0234a1b6..5b6cad1f 100755
--- a/lib/bup/main.py
+++ b/lib/bup/main.py
@@ -82,7 +82,7 @@ def usage(msg=""):
for cmd,synopsis in sorted(common.items()):
log(' %-10s %s\n' % (cmd, synopsis))
log('\n')
-
+
log('Other available commands:\n')
cmds = set()
for c in sorted(os.listdir(cmdpath)):
@@ -98,7 +98,7 @@ def usage(msg=""):

log(columnate(sorted(cmds), ' '))
log('\n')
-
+
log("See 'bup help COMMAND' for more information on " +
"a specific command.\n")
if msg:
diff --git a/lib/bup/midx.py b/lib/bup/midx.py
index a18981da..84e7969b 100644
--- a/lib/bup/midx.py
+++ b/lib/bup/midx.py
@@ -34,9 +34,9 @@ class PackMidx:
return self._init_failed()
ver = struct.unpack('!I', self.map[4:8])[0]
if ver < MIDX_VERSION:
- log('Warning: ignoring old-style (v%d) midx %r\n'
+ log('Warning: ignoring old-style (v%d) midx %r\n'
% (ver, path_msg(filename)))
- self.force_keep = False # old stuff is boring
+ self.force_keep = False # old stuff is boring
return self._init_failed()
if ver > MIDX_VERSION:
log('Warning: ignoring too-new (v%d) midx %r\n'
diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py
index 015209d7..fd016b27 100644
--- a/lib/bup/vfs.py
+++ b/lib/bup/vfs.py
@@ -205,7 +205,7 @@ class _FileReader(object):
if not self._size:
self._size = _normal_or_chunked_file_size(self._repo, self.oid)
return self._size
-
+
def seek(self, ofs):
if ofs < 0 or ofs > self._compute_size():
raise IOError(EINVAL, 'Invalid seek offset: %d' % ofs)
@@ -264,7 +264,7 @@ def _decompose_path(path):
if not parts:
must_be_dir = True # e.g. path was effectively '.' or '/', etc.
return is_absolute, must_be_dir, parts
-
+

Item = namedtuple('Item', ('meta', 'oid'))
Chunky = namedtuple('Chunky', ('meta', 'oid'))
@@ -480,7 +480,7 @@ def tree_data_and_bupm(repo, oid):
"""Return (tree_bytes, bupm_oid) where bupm_oid will be None if the
tree has no metadata (i.e. older bup save, or non-bup tree).

- """
+ """
assert len(oid) == 20
it = repo.cat(hexlify(oid))
_, item_t, size = next(it)
@@ -639,7 +639,7 @@ def ordered_tree_entries(tree_data, bupm=None):
tree_ents = sorted(tree_ents, key=lambda x: x[0])
for ent in tree_ents:
yield ent
-
+
def tree_items(oid, tree_data, names=frozenset(), bupm=None):

def tree_item(ent_oid, kind, gitmode):
@@ -718,7 +718,7 @@ def tree_items_with_meta(repo, oid, tree_data, names):
yield item

_save_name_rx = re.compile(br'^\d\d\d\d-\d\d-\d\d-\d{6}(-\d+)?$')
-
+
def _reverse_suffix_duplicates(strs):
"""Yields the elements of strs, with any runs of duplicate values
suffixed with -N suffixes, where the zero padded integer N
@@ -1032,7 +1032,7 @@ def _resolve_path(repo, path, parent=None, want_meta=True, follow=True):
else:
future.extend(target_future)
hops += 1
-
+
def resolve(repo, path, parent=None, want_meta=True, follow=True):
"""Follow the path in the virtual filesystem and return a tuple
representing the location, if any, denoted by the path. Each
--
2.30.2

Reply all
Reply to author
Forward
0 new messages