changeset 8181:21f7b699d467

py3: automatic migration with 2to3 -f xrange
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 05 Feb 2020 23:03:08 +0100
parents c4c2df844424
children abb00ff224b6
files kallithea/lib/colored_formatter.py kallithea/lib/helpers.py kallithea/lib/timerproxy.py kallithea/lib/vcs/utils/progressbar.py kallithea/model/gist.py kallithea/tests/other/test_vcs_operations.py kallithea/tests/vcs/test_archives.py kallithea/tests/vcs/test_changesets.py kallithea/tests/vcs/test_getitem.py kallithea/tests/vcs/test_getslice.py kallithea/tests/vcs/test_inmemchangesets.py
diffstat 11 files changed, 19 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/colored_formatter.py	Thu Dec 26 04:07:03 2019 +0100
+++ b/kallithea/lib/colored_formatter.py	Wed Feb 05 23:03:08 2020 +0100
@@ -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"
--- a/kallithea/lib/helpers.py	Thu Dec 26 04:07:03 2019 +0100
+++ b/kallithea/lib/helpers.py	Wed Feb 05 23:03:08 2020 +0100
@@ -366,7 +366,7 @@
     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]
--- a/kallithea/lib/timerproxy.py	Thu Dec 26 04:07:03 2019 +0100
+++ b/kallithea/lib/timerproxy.py	Wed Feb 05 23:03:08 2020 +0100
@@ -20,7 +20,7 @@
 
 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):
--- a/kallithea/lib/vcs/utils/progressbar.py	Thu Dec 26 04:07:03 2019 +0100
+++ b/kallithea/lib/vcs/utils/progressbar.py	Wed Feb 05 23:03:08 2020 +0100
@@ -43,7 +43,7 @@
     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 @@
 
     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 @@
     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()
--- a/kallithea/model/gist.py	Thu Dec 26 04:07:03 2019 +0100
+++ b/kallithea/model/gist.py	Wed Feb 05 23:03:08 2020 +0100
@@ -50,7 +50,7 @@
     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):
--- a/kallithea/tests/other/test_vcs_operations.py	Thu Dec 26 04:07:03 2019 +0100
+++ b/kallithea/tests/other/test_vcs_operations.py	Wed Feb 05 23:03:08 2020 +0100
@@ -187,7 +187,7 @@
         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':
--- a/kallithea/tests/vcs/test_archives.py	Thu Dec 26 04:07:03 2019 +0100
+++ b/kallithea/tests/vcs/test_archives.py	Wed Feb 05 23:03:08 2020 +0100
@@ -18,7 +18,7 @@
     @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 <joe.doe@example.com>',
@@ -35,7 +35,7 @@
             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 @@
         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 @@
         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
 
--- a/kallithea/tests/vcs/test_changesets.py	Thu Dec 26 04:07:03 2019 +0100
+++ b/kallithea/tests/vcs/test_changesets.py	Wed Feb 05 23:03:08 2020 +0100
@@ -45,7 +45,7 @@
     @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 <joe.doe@example.com>',
@@ -143,7 +143,7 @@
     @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 <joe.doe@example.com>',
@@ -238,7 +238,7 @@
     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()
--- a/kallithea/tests/vcs/test_getitem.py	Thu Dec 26 04:07:03 2019 +0100
+++ b/kallithea/tests/vcs/test_getitem.py	Wed Feb 05 23:03:08 2020 +0100
@@ -9,7 +9,7 @@
     @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 <joe.doe@example.com>',
@@ -23,7 +23,7 @@
         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())
 
 
--- a/kallithea/tests/vcs/test_getslice.py	Thu Dec 26 04:07:03 2019 +0100
+++ b/kallithea/tests/vcs/test_getslice.py	Wed Feb 05 23:03:08 2020 +0100
@@ -9,7 +9,7 @@
     @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 <joe.doe@example.com>',
--- a/kallithea/tests/vcs/test_inmemchangesets.py	Thu Dec 26 04:07:03 2019 +0100
+++ b/kallithea/tests/vcs/test_inmemchangesets.py	Wed Feb 05 23:03:08 2020 +0100
@@ -300,7 +300,7 @@
     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)