Signed-off-by: Rob Browning <
r...@defaultvalue.org>
Tested-by: Rob Browning <
r...@defaultvalue.org>
---
.pylintrc | 1 +
lib/bup/shquote.py | 40 ++++++++++++++++++++--------------------
test/int/test_vfs.py | 30 +++++++++++++++---------------
test/int/test_vint.py | 12 ++++++------
4 files changed, 42 insertions(+), 41 deletions(-)
diff --git a/.pylintrc b/.pylintrc
index 1e2f6244..6a39ec9f 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -9,6 +9,7 @@ enable=
assert-on-string-literal,
assignment-from-no-return,
bad-classmethod-argument,
+ bad-indentation,
bare-except,
broad-exception-caught,
catching-non-exception,
diff --git a/lib/bup/shquote.py b/lib/bup/shquote.py
index 35e29e94..3aafec37 100644
--- a/lib/bup/shquote.py
+++ b/lib/bup/shquote.py
@@ -117,26 +117,26 @@ def quotify(qtype, word, terminate):
def quotify_list(words):
- """Return minimally-quoted bytes produced by quoting each word.
-
- This calculates the qtype for each word depending on whether the word
- already includes singlequote characters, doublequote characters, both,
- or neither.
-
- Args:
- words: the list of words to quote.
- Returns:
- The resulting bytes, with quoted words separated by ' '.
- """
- wordout = []
- for word in words:
- qtype = q
- if word and not re.search(br'[\s\"\']', word):
- qtype = b''
- elif q in word and qq not in word:
- qtype = qq
- wordout.append(quotify(qtype, word, True))
- return b' '.join(wordout)
+ """Return minimally-quoted bytes produced by quoting each word.
+
+ This calculates the qtype for each word depending on whether the word
+ already includes singlequote characters, doublequote characters, both,
+ or neither.
+
+ Args:
+ words: the list of words to quote.
+ Returns:
+ The resulting bytes, with quoted words separated by ' '.
+ """
+ wordout = []
+ for word in words:
+ qtype = q
+ if word and not re.search(br'[\s\"\']', word):
+ qtype = b''
+ elif q in word and qq not in word:
+ qtype = qq
+ wordout.append(quotify(qtype, word, True))
+ return b' '.join(wordout)
def what_to_add(qtype, origword, newword, terminate):
diff --git a/test/int/test_vfs.py b/test/int/test_vfs.py
index 248f5502..dac1085a 100644
--- a/test/int/test_vfs.py
+++ b/test/int/test_vfs.py
@@ -239,22 +239,22 @@ def validate_vfs_seeking_read(repo, item, expected_path, read_sizes):
for read_size in read_sizes:
with open(expected_path, 'rb') as expected:
+ ex_buf = expected.read(read_size)
+ act_buf = None
+ act_pos = 0
+ while ex_buf:
+ act_pos, act_buf = read_act(act_pos)
+ wvpassge(read_size, len(ex_buf))
+ wvpassge(read_size, len(act_buf))
+ wvpasseq(len(ex_buf), len(act_buf))
+ wvpass(ex_buf == act_buf)
+ if not act_buf:
+ break
ex_buf = expected.read(read_size)
- act_buf = None
- act_pos = 0
- while ex_buf:
- act_pos, act_buf = read_act(act_pos)
- wvpassge(read_size, len(ex_buf))
- wvpassge(read_size, len(act_buf))
- wvpasseq(len(ex_buf), len(act_buf))
- wvpass(ex_buf == act_buf)
- if not act_buf:
- break
- ex_buf = expected.read(read_size)
- else: # hit expected eof first
- act_pos, act_buf = read_act(act_pos)
- wvpasseq(b'', ex_buf)
- wvpasseq(b'', act_buf)
+ else: # hit expected eof first
+ act_pos, act_buf = read_act(act_pos)
+ wvpasseq(b'', ex_buf)
+ wvpasseq(b'', act_buf)
def test_read_and_seek(tmpdir):
# Write a set of randomly sized files containing random data whose
diff --git a/test/int/test_vint.py b/test/int/test_vint.py
index f8120896..332aadf2 100644
--- a/test/int/test_vint.py
+++ b/test/int/test_vint.py
@@ -14,12 +14,12 @@ def encode_and_decode_vuint(x):
def test_vuint():
- for x in (0, 1, 42, 128, 10**16, 10**100):
- WVPASSEQ(encode_and_decode_vuint(x), x)
- WVEXCEPT(Exception, vint.write_vuint, BytesIO(), -1)
- assert vint.read_vuint(BytesIO()) is None
- WVEXCEPT(EOFError, vint.read_vuint, BytesIO(b'\x80'))
- WVEXCEPT(EOFError, vint.read_vuint, BytesIO(b'\x80\x80'))
+ for x in (0, 1, 42, 128, 10**16, 10**100):
+ WVPASSEQ(encode_and_decode_vuint(x), x)
+ WVEXCEPT(Exception, vint.write_vuint, BytesIO(), -1)
+ assert vint.read_vuint(BytesIO()) is None
+ WVEXCEPT(EOFError, vint.read_vuint, BytesIO(b'\x80'))
+ WVEXCEPT(EOFError, vint.read_vuint, BytesIO(b'\x80\x80'))
def encode_and_decode_vint(x):
--
2.47.3