From: Rob Browning Date: Sat, 31 Mar 2018 21:42:53 +0000 (-0500) Subject: compat: add range and use it in the vfs X-Git-Tag: 0.30~94 X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=217eb3b7cc793f678e533993025d3be6747fe3e9 compat: add range and use it in the vfs Define range as range for py3 and xrange for py2, so that we'll have the same semantics both places. Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/compat.py b/lib/bup/compat.py index 8a14282..895a84a 100644 --- a/lib/bup/compat.py +++ b/lib/bup/compat.py @@ -11,6 +11,7 @@ py3 = py_maj >= 3 if py3: + range = range str_type = str def add_ex_tb(ex): @@ -26,6 +27,7 @@ if py3: else: # Python 2 + range = xrange str_type = basestring def add_ex_tb(ex): diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py index f231f4d..14293dc 100644 --- a/lib/bup/vfs.py +++ b/lib/bup/vfs.py @@ -54,6 +54,7 @@ from time import localtime, strftime import exceptions, re, sys from bup import client, git, metadata +from bup.compat import range from bup.git import BUP_CHUNKED, cp, get_commit_items, parse_commit, tree_decode from bup.helpers import debug2, last from bup.metadata import Metadata @@ -576,7 +577,7 @@ def _reverse_suffix_duplicates(strs): else: ndig = len(str(ndup - 1)) fmt = '%s-' + '%0' + str(ndig) + 'd' - for i in xrange(ndup - 1, -1, -1): + for i in range(ndup - 1, -1, -1): yield fmt % (name, i) def parse_rev(f):