# HG changeset patch # User Mads Kiilerich # Date 2020-02-05 23:03:08 # Node ID 21f7b699d4672426b8b2f1ea6ef5fa3c7de1cc3d # Parent c4c2df84442451413e9270e12caa1654bed7a8b4 py3: automatic migration with 2to3 -f xrange diff --git a/kallithea/lib/colored_formatter.py b/kallithea/lib/colored_formatter.py --- a/kallithea/lib/colored_formatter.py +++ b/kallithea/lib/colored_formatter.py @@ -15,7 +15,7 @@ import logging -BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38) +BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(30, 38) # Sequences RESET_SEQ = "\033[0m" diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py --- a/kallithea/lib/helpers.py +++ b/kallithea/lib/helpers.py @@ -366,7 +366,7 @@ def gen_color(n=10000): golden_ratio = 0.618033988749895 h = 0.22717784590367374 - for _unused in xrange(n): + for _unused in range(n): h += golden_ratio h %= 1 HSV_tuple = [h, 0.95, 0.95] diff --git a/kallithea/lib/timerproxy.py b/kallithea/lib/timerproxy.py --- a/kallithea/lib/timerproxy.py +++ b/kallithea/lib/timerproxy.py @@ -20,7 +20,7 @@ from sqlalchemy.interfaces import Connec log = logging.getLogger('timerproxy') -BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38) +BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(30, 38) def color_sql(sql): diff --git a/kallithea/lib/vcs/utils/progressbar.py b/kallithea/lib/vcs/utils/progressbar.py --- a/kallithea/lib/vcs/utils/progressbar.py +++ b/kallithea/lib/vcs/utils/progressbar.py @@ -43,7 +43,7 @@ class ProgressBar(object): def __iter__(self): start = self.step end = self.steps + 1 - for x in xrange(start, end): + for x in range(start, end): self.render(x) yield x @@ -359,7 +359,7 @@ def main(): print("Standard progress bar...") bar = ProgressBar(30) - for x in xrange(1, 31): + for x in range(1, 31): bar.render(x) time.sleep(0.02) bar.stream.write('\n') @@ -410,7 +410,7 @@ def main(): bar.width = 50 bar.elements.remove('steps') bar.elements += ['transfer', 'time', 'eta', 'speed'] - for x in xrange(0, bar.steps, 1024): + for x in range(0, bar.steps, 1024): bar.render(x) time.sleep(0.01) now = datetime.datetime.now() diff --git a/kallithea/model/gist.py b/kallithea/model/gist.py --- a/kallithea/model/gist.py +++ b/kallithea/model/gist.py @@ -50,7 +50,7 @@ def make_gist_access_id(): rnd = random.SystemRandom() # use cryptographically secure system PRNG alphabet = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjklmnpqrstuvwxyz' length = 20 - return u''.join(rnd.choice(alphabet) for _ in xrange(length)) + return u''.join(rnd.choice(alphabet) for _ in range(length)) class GistModel(object): diff --git a/kallithea/tests/other/test_vcs_operations.py b/kallithea/tests/other/test_vcs_operations.py --- a/kallithea/tests/other/test_vcs_operations.py +++ b/kallithea/tests/other/test_vcs_operations.py @@ -187,7 +187,7 @@ def _add_files(vcs, dest_dir, files_no=3 author_str = 'User <%s>' % email else: author_str = 'User ǝɯɐᴎ <%s>' % email - for i in xrange(files_no): + for i in range(files_no): cmd = """echo "added_line%s" >> %s""" % (i, added_file) Command(dest_dir).execute(cmd) if vcs == 'hg': diff --git a/kallithea/tests/vcs/test_archives.py b/kallithea/tests/vcs/test_archives.py --- a/kallithea/tests/vcs/test_archives.py +++ b/kallithea/tests/vcs/test_archives.py @@ -18,7 +18,7 @@ class ArchivesTestCaseMixin(_BackendTest @classmethod def _get_commits(cls): start_date = datetime.datetime(2010, 1, 1, 20) - for x in xrange(5): + for x in range(5): yield { 'message': 'Commit %d' % x, 'author': 'Joe Doe ', @@ -35,7 +35,7 @@ class ArchivesTestCaseMixin(_BackendTest self.tip.fill_archive(stream=f, kind='zip', prefix='repo') out = zipfile.ZipFile(path) - for x in xrange(5): + for x in range(5): node_path = '%d/file_%d.txt' % (x, x) decompressed = out.read('repo/' + node_path) assert decompressed == self.tip.get_node(node_path).content @@ -49,7 +49,7 @@ class ArchivesTestCaseMixin(_BackendTest outfile = tarfile.open(path, 'r|gz') outfile.extractall(outdir) - for x in xrange(5): + for x in range(5): node_path = '%d/file_%d.txt' % (x, x) assert open(os.path.join(outdir, 'repo/' + node_path), 'rb').read() == self.tip.get_node(node_path).content @@ -62,7 +62,7 @@ class ArchivesTestCaseMixin(_BackendTest outfile = tarfile.open(path, 'r|bz2') outfile.extractall(outdir) - for x in xrange(5): + for x in range(5): node_path = '%d/file_%d.txt' % (x, x) assert open(os.path.join(outdir, 'repo/' + node_path), 'rb').read() == self.tip.get_node(node_path).content diff --git a/kallithea/tests/vcs/test_changesets.py b/kallithea/tests/vcs/test_changesets.py --- a/kallithea/tests/vcs/test_changesets.py +++ b/kallithea/tests/vcs/test_changesets.py @@ -45,7 +45,7 @@ class _ChangesetsWithCommitsTestCaseixin @classmethod def _get_commits(cls): start_date = datetime.datetime(2010, 1, 1, 20) - for x in xrange(5): + for x in range(5): yield { 'message': 'Commit %d' % x, 'author': 'Joe Doe ', @@ -143,7 +143,7 @@ class _ChangesetsTestCaseMixin(_BackendT @classmethod def _get_commits(cls): start_date = datetime.datetime(2010, 1, 1, 20) - for x in xrange(5): + for x in range(5): yield { 'message': u'Commit %d' % x, 'author': u'Joe Doe ', @@ -238,7 +238,7 @@ class _ChangesetsTestCaseMixin(_BackendT def test_get_filenodes_generator(self): tip = self.repo.get_changeset() filepaths = [node.path for node in tip.get_filenodes_generator()] - assert filepaths == ['file_%d.txt' % x for x in xrange(5)] + assert filepaths == ['file_%d.txt' % x for x in range(5)] def test_size(self): tip = self.repo.get_changeset() diff --git a/kallithea/tests/vcs/test_getitem.py b/kallithea/tests/vcs/test_getitem.py --- a/kallithea/tests/vcs/test_getitem.py +++ b/kallithea/tests/vcs/test_getitem.py @@ -9,7 +9,7 @@ class GetitemTestCaseMixin(_BackendTestM @classmethod def _get_commits(cls): start_date = datetime.datetime(2010, 1, 1, 20) - for x in xrange(5): + for x in range(5): yield { 'message': 'Commit %d' % x, 'author': 'Joe Doe ', @@ -23,7 +23,7 @@ class GetitemTestCaseMixin(_BackendTestM assert self.repo[-1] == self.repo.get_changeset() def test__getitem__returns_correct_items(self): - changesets = [self.repo[x] for x in xrange(len(self.repo.revisions))] + changesets = [self.repo[x] for x in range(len(self.repo.revisions))] assert changesets == list(self.repo.get_changesets()) diff --git a/kallithea/tests/vcs/test_getslice.py b/kallithea/tests/vcs/test_getslice.py --- a/kallithea/tests/vcs/test_getslice.py +++ b/kallithea/tests/vcs/test_getslice.py @@ -9,7 +9,7 @@ class GetsliceTestCaseMixin(_BackendTest @classmethod def _get_commits(cls): start_date = datetime.datetime(2010, 1, 1, 20) - for x in xrange(5): + for x in range(5): yield { 'message': 'Commit %d' % x, 'author': 'Joe Doe ', diff --git a/kallithea/tests/vcs/test_inmemchangesets.py b/kallithea/tests/vcs/test_inmemchangesets.py --- a/kallithea/tests/vcs/test_inmemchangesets.py +++ b/kallithea/tests/vcs/test_inmemchangesets.py @@ -300,7 +300,7 @@ class InMemoryChangesetTestMixin(_Backen def test_multiple_commits(self): N = 3 # number of commits to perform last = None - for x in xrange(N): + for x in range(N): fname = 'file%s' % str(x).rjust(5, '0') content = 'foobar\n' * x node = FileNode(fname, content=content)