Bug 1210687 - Remove PushbackIter now it's not used anymore. r=gps

This commit is contained in:
Mike Hommey 2015-10-08 09:35:59 +09:00
parent 8e61778945
commit 563b4fd669

View File

@ -724,40 +724,6 @@ def lock_file(lockfile, max_wait = 600):
return LockFile(lockfile)
class PushbackIter(object):
'''Utility iterator that can deal with pushed back elements.
This behaves like a regular iterable, just that you can call
iter.pushback(item) to get the given item as next item in the
iteration.
'''
def __init__(self, iterable):
self.it = iter(iterable)
self.pushed_back = []
def __iter__(self):
return self
def __nonzero__(self):
if self.pushed_back:
return True
try:
self.pushed_back.insert(0, self.it.next())
except StopIteration:
return False
else:
return True
def next(self):
if self.pushed_back:
return self.pushed_back.pop()
return self.it.next()
def pushback(self, item):
self.pushed_back.append(item)
def shell_quote(s):
'''Given a string, returns a version enclosed with single quotes for use
in a shell command line.