self.next()
def next(self):
- try:
- self.cur = self.i.next()
- except StopIteration:
- self.cur = None
+ self.cur = next(self.i, None)
return self.cur
for c in xrange(opt.cycles):
for n in xrange(opt.number):
if opt.existing:
- bin = objit.next()
+ bin = next(objit)
assert(m.exists(bin))
else:
bin = _helpers.random_sha()
print p.idxnames
assert(len(p) == total)
for pe, e in p, git.idxmerge(inp, final_progress=False):
- pin = pi.next()
+ pin = next(pi)
assert(i == pin)
assert(p.exists(i))
sha = idx.shatable[i * 20 : (i + 1) * 20]
if live_objects.exists(sha):
item_it = cat_pipe.get(sha.encode('hex'))
- type = item_it.next()
+ type = next(item_it)
writer.just_write(sha, type, ''.join(item_it))
ns.stale_files.append(idx_name)
def get_commit_items(id, cp):
commit_it = cp.get(id)
- assert(commit_it.next() == 'commit')
+ assert(next(commit_it) == 'commit')
commit_content = ''.join(commit_it)
return parse_commit(commit_content)
def next(self):
try:
- return self.it.next()
+ return next(self.it)
except StopIteration as e:
self.done = True
raise
raise
def _join(self, it):
- type = it.next()
+ type = next(it)
if type == 'blob':
for blob in it:
yield blob
continue
item_it = cat_pipe.get(id)
- type = item_it.next()
+ type = next(item_it)
if type not in ('blob', 'commit', 'tree'):
raise Exception('unexpected repository object type %r' % type)
raise
-_unspecified_next_default = object()
-
-def _fallback_next(it, default=_unspecified_next_default):
- """Retrieve the next item from the iterator by calling its
- next() method. If default is given, it is returned if the
- iterator is exhausted, otherwise StopIteration is raised."""
-
- if default is _unspecified_next_default:
- return it.next()
- else:
- try:
- return it.next()
- except StopIteration:
- return default
-
-if sys.version_info < (2, 6):
- next = _fallback_next
-
-
def merge_iter(iters, pfreq, pfunc, pfinal, key=None):
if key:
samekey = lambda e, pe: getattr(e, key) == getattr(pe, key, None)
yield e
count += 1
try:
- e = it.next() # Don't use next() function, it's too expensive
+ e = next(it)
except StopIteration:
heapq.heappop(heap) # remove current
else:
if not self._next_packet(timeout):
return False
try:
- self.buf = self.reader.next()
+ self.buf = next(self.reader)
return True
except StopIteration:
self.reader = None
pi = iter(r)
for h in sorted(hashes):
- WVPASSEQ(str(pi.next()).encode('hex'), h.encode('hex'))
+ WVPASSEQ(str(next(pi)).encode('hex'), h.encode('hex'))
WVFAIL(r.find_offset('\0'*20))
git_size = int(exo('git', '--git-dir', bupdir,
'cat-file', '-s', 'src'))
it = git.cp().get('src', size=True)
- get_type, get_size = it.next()
- for buf in it.next():
+ get_type, get_size = next(it)
+ for buf in next(it):
pass
WVPASSEQ(get_type, git_type)
WVPASSEQ(get_size, git_size)
bup_tmp = os.path.realpath('../../../t/tmp')
mkdirp(bup_tmp)
-@wvtest
-def test_next():
- with no_lingering_errors():
- # Test whatever you end up with for next() after import '*'.
- WVPASSEQ(next(iter([]), None), None)
- x = iter([1])
- WVPASSEQ(next(x, None), 1)
- WVPASSEQ(next(x, None), None)
- x = iter([1])
- WVPASSEQ(next(x, 'x'), 1)
- WVPASSEQ(next(x, 'x'), 'x')
- WVEXCEPT(StopIteration, next, iter([]))
- x = iter([1])
- WVPASSEQ(next(x), 1)
- WVEXCEPT(StopIteration, next, x)
-
-
-@wvtest
-def test_fallback_next():
- with no_lingering_errors():
- global next
- orig = next
- next = helpers._fallback_next
- try:
- test_next()
- finally:
- next = orig
-
@wvtest
def test_parse_num():
def _treeget(hash, repo_dir=None):
it = cp(repo_dir).get(hash.encode('hex'))
- type = it.next()
+ type = next(it)
assert(type == 'tree')
return git.tree_decode(''.join(it))
while len(out) < size:
if self.it and not self.blob:
try:
- self.blob = self.it.next()
+ self.blob = next(self.it)
except StopIteration:
self.it = None
if self.blob:
def _mksubs(self):
self._subs = {}
it = cp(self._repo_dir).get(self.hash.encode('hex'))
- type = it.next()
+ type = next(it)
if type == 'commit':
del it
it = cp(self._repo_dir).get(self.hash.encode('hex') + ':')
- type = it.next()
+ type = next(it)
assert(type == 'tree')
for (mode,mangled_name,sha) in git.tree_decode(''.join(it)):
if mangled_name == '.bupm':