##// END OF EJS Templates
py3: use global next() function instead of .next() method...
Mads Kiilerich -
r8057:e26c0616 default
parent child Browse files
Show More
@@ -418,22 +418,22 b' class DiffProcessor(object):'
418 for chunk in diff_data['chunks']:
418 for chunk in diff_data['chunks']:
419 lineiter = iter(chunk)
419 lineiter = iter(chunk)
420 try:
420 try:
421 peekline = lineiter.next()
421 peekline = next(lineiter)
422 while True:
422 while True:
423 # find a first del line
423 # find a first del line
424 while peekline['action'] != 'del':
424 while peekline['action'] != 'del':
425 peekline = lineiter.next()
425 peekline = next(lineiter)
426 delline = peekline
426 delline = peekline
427 peekline = lineiter.next()
427 peekline = next(lineiter)
428 # if not followed by add, eat all following del lines
428 # if not followed by add, eat all following del lines
429 if peekline['action'] != 'add':
429 if peekline['action'] != 'add':
430 while peekline['action'] == 'del':
430 while peekline['action'] == 'del':
431 peekline = lineiter.next()
431 peekline = next(lineiter)
432 continue
432 continue
433 # found an add - make sure it is the only one
433 # found an add - make sure it is the only one
434 addline = peekline
434 addline = peekline
435 try:
435 try:
436 peekline = lineiter.next()
436 peekline = next(lineiter)
437 except StopIteration:
437 except StopIteration:
438 # add was last line - ok
438 # add was last line - ok
439 _highlight_inline_diff(delline, addline)
439 _highlight_inline_diff(delline, addline)
@@ -560,7 +560,7 b' def _parse_lines(diff_lines):'
560
560
561 chunks = []
561 chunks = []
562 try:
562 try:
563 line = diff_lines.next()
563 line = next(diff_lines)
564
564
565 while True:
565 while True:
566 lines = []
566 lines = []
@@ -591,7 +591,7 b' def _parse_lines(diff_lines):'
591 'line': line,
591 'line': line,
592 })
592 })
593
593
594 line = diff_lines.next()
594 line = next(diff_lines)
595
595
596 while old_line < old_end or new_line < new_end:
596 while old_line < old_end or new_line < new_end:
597 if not line:
597 if not line:
@@ -624,7 +624,7 b' def _parse_lines(diff_lines):'
624 'line': line[1:],
624 'line': line[1:],
625 })
625 })
626
626
627 line = diff_lines.next()
627 line = next(diff_lines)
628
628
629 if _newline_marker.match(line):
629 if _newline_marker.match(line):
630 # we need to append to lines, since this is not
630 # we need to append to lines, since this is not
@@ -635,7 +635,7 b' def _parse_lines(diff_lines):'
635 'action': 'context',
635 'action': 'context',
636 'line': line,
636 'line': line,
637 })
637 })
638 line = diff_lines.next()
638 line = next(diff_lines)
639 if old_line > old_end:
639 if old_line > old_end:
640 raise Exception('error parsing diff - more than %s "-" lines at -%s+%s' % (old_end, old_line, new_line))
640 raise Exception('error parsing diff - more than %s "-" lines at -%s+%s' % (old_end, old_line, new_line))
641 if new_line > new_end:
641 if new_line > new_end:
@@ -387,7 +387,7 b' def pygmentize_annotation(repo_name, fil'
387 if cs in color_dict:
387 if cs in color_dict:
388 col = color_dict[cs]
388 col = color_dict[cs]
389 else:
389 else:
390 col = color_dict[cs] = cgenerator.next()
390 col = color_dict[cs] = next(cgenerator)
391 return "color: rgb(%s)! important;" % (', '.join(col))
391 return "color: rgb(%s)! important;" % (', '.join(col))
392
392
393 def url_func(changeset):
393 def url_func(changeset):
@@ -146,7 +146,7 b' class WhooshResultWrapper(object):'
146 docnum = self.matcher.id()
146 docnum = self.matcher.id()
147 chunks = [offsets for offsets in self.get_chunks()]
147 chunks = [offsets for offsets in self.get_chunks()]
148 docs_id.append([docnum, chunks])
148 docs_id.append([docnum, chunks])
149 self.matcher.next()
149 self.matcher.next() # this looks like a py2 iterator ... but it isn't
150 return docs_id
150 return docs_id
151
151
152 def __str__(self):
152 def __str__(self):
@@ -63,14 +63,14 b' class ResultIter:'
63
63
64 def __init__(self, result, meter, description):
64 def __init__(self, result, meter, description):
65 self._result_close = getattr(result, 'close', None) or (lambda: None)
65 self._result_close = getattr(result, 'close', None) or (lambda: None)
66 self._next = iter(result).next
66 self._next = iter(result).__next__
67 self._meter = meter
67 self._meter = meter
68 self._description = description
68 self._description = description
69
69
70 def __iter__(self):
70 def __iter__(self):
71 return self
71 return self
72
72
73 def next(self):
73 def __next__(self):
74 chunk = self._next()
74 chunk = self._next()
75 self._meter.measure(chunk)
75 self._meter.measure(chunk)
76 return chunk
76 return chunk
@@ -178,7 +178,7 b' class BufferedGenerator(object):'
178 def __iter__(self):
178 def __iter__(self):
179 return self
179 return self
180
180
181 def next(self):
181 def __next__(self):
182 while not len(self.data) and not self.worker.EOF.is_set():
182 while not len(self.data) and not self.worker.EOF.is_set():
183 self.worker.data_added.clear()
183 self.worker.data_added.clear()
184 self.worker.data_added.wait(0.2)
184 self.worker.data_added.wait(0.2)
@@ -389,7 +389,7 b' class SubprocessIOChunker(object):'
389 def __iter__(self):
389 def __iter__(self):
390 return self
390 return self
391
391
392 def next(self):
392 def __next__(self):
393 if self.process:
393 if self.process:
394 returncode = self.process.poll()
394 returncode = self.process.poll()
395 if (returncode is not None # process has terminated
395 if (returncode is not None # process has terminated
@@ -399,7 +399,7 b' class SubprocessIOChunker(object):'
399 self.error.stop()
399 self.error.stop()
400 err = ''.join(self.error)
400 err = ''.join(self.error)
401 raise EnvironmentError("Subprocess exited due to an error:\n" + err)
401 raise EnvironmentError("Subprocess exited due to an error:\n" + err)
402 return self.output.next()
402 return next(self.output)
403
403
404 def throw(self, type, value=None, traceback=None):
404 def throw(self, type, value=None, traceback=None):
405 if self.output.length or not self.output.done_reading:
405 if self.output.length or not self.output.done_reading:
@@ -178,7 +178,7 b' def _add_files(vcs, dest_dir, files_no=3'
178 :param vcs:
178 :param vcs:
179 :param dest_dir:
179 :param dest_dir:
180 """
180 """
181 added_file = '%ssetup.py' % _RandomNameSequence().next()
181 added_file = '%ssetup.py' % next(_RandomNameSequence())
182 open(os.path.join(dest_dir, added_file), 'a').close()
182 open(os.path.join(dest_dir, added_file), 'a').close()
183 Command(dest_dir).execute(vcs, 'add', added_file)
183 Command(dest_dir).execute(vcs, 'add', added_file)
184
184
@@ -263,9 +263,9 b' class TestVCSOperations(base.TestControl'
263 @pytest.fixture(scope="module")
263 @pytest.fixture(scope="module")
264 def testfork(self):
264 def testfork(self):
265 # create fork so the repo stays untouched
265 # create fork so the repo stays untouched
266 git_fork_name = u'%s_fork%s' % (base.GIT_REPO, _RandomNameSequence().next())
266 git_fork_name = u'%s_fork%s' % (base.GIT_REPO, next(_RandomNameSequence()))
267 fixture.create_fork(base.GIT_REPO, git_fork_name)
267 fixture.create_fork(base.GIT_REPO, git_fork_name)
268 hg_fork_name = u'%s_fork%s' % (base.HG_REPO, _RandomNameSequence().next())
268 hg_fork_name = u'%s_fork%s' % (base.HG_REPO, next(_RandomNameSequence()))
269 fixture.create_fork(base.HG_REPO, hg_fork_name)
269 fixture.create_fork(base.HG_REPO, hg_fork_name)
270 return {'git': git_fork_name, 'hg': hg_fork_name}
270 return {'git': git_fork_name, 'hg': hg_fork_name}
271
271
@@ -319,7 +319,7 b' class TestVCSOperations(base.TestControl'
319 Session().commit()
319 Session().commit()
320
320
321 # Create an empty server repo using the API
321 # Create an empty server repo using the API
322 repo_name = u'new_%s_%s' % (vt.repo_type, _RandomNameSequence().next())
322 repo_name = u'new_%s_%s' % (vt.repo_type, next(_RandomNameSequence()))
323 usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN)
323 usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN)
324 params = {
324 params = {
325 "id": 7,
325 "id": 7,
@@ -202,7 +202,7 b" if __name__ == '__main__':"
202 backend = 'hg'
202 backend = 'hg'
203
203
204 if METHOD == 'pull':
204 if METHOD == 'pull':
205 seq = tempfile._RandomNameSequence().next()
205 seq = next(tempfile._RandomNameSequence())
206 test_clone_with_credentials(repo=sys.argv[1], method='clone',
206 test_clone_with_credentials(repo=sys.argv[1], method='clone',
207 backend=backend)
207 backend=backend)
208 s = time.time()
208 s = time.time()
General Comments 0
You need to be logged in to leave comments. Login now