"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "roundup/cgi/ZTUtils/Iterator.py" between
roundup-1.6.1.tar.gz and roundup-2.0.0.tar.gz

About: Roundup is an highly customisable issue-tracking system with command-line, web and e-mail interfaces (written in Python).

Iterator.py  (roundup-1.6.1):Iterator.py  (roundup-2.0.0)
skipping to change at line 41 skipping to change at line 41
nextIndex = 0 nextIndex = 0
def __init__(self, seq): def __init__(self, seq):
self.seq = iter(seq) # force seq to be an iterator self.seq = iter(seq) # force seq to be an iterator
self._inner = iterInner self._inner = iterInner
self._prep_next = iterInner.prep_next self._prep_next = iterInner.prep_next
def __getattr__(self, name): def __getattr__(self, name):
try: try:
inner = getattr(self._inner, 'it_' + name) inner = getattr(self._inner, 'it_' + name)
except AttributeError: except AttributeError:
raise AttributeError, name raise AttributeError(name)
return inner(self) return inner(self)
def next(self): def next(self):
if not (hasattr(self, '_next') or self._prep_next(self)): if not (hasattr(self, '_next') or self._prep_next(self)):
return 0 return 0
self.index = i = self.nextIndex self.index = i = self.nextIndex
self.nextIndex = i+1 self.nextIndex = i+1
self._advance(self) self._advance(self)
return 1 return 1
skipping to change at line 87 skipping to change at line 87
(1000,'M'),(900,'CM'),(500,'D'),(400,'CD'), (1000,'M'),(900,'CM'),(500,'D'),(400,'CD'),
(100,'C'),(90,'XC'),(50,'L'),(40,'XL'), (100,'C'),(90,'XC'),(50,'L'),(40,'XL'),
(10,'X'),(9,'IX'),(5,'V'),(4,'IV'),(1,'I')) ): (10,'X'),(9,'IX'),(5,'V'),(4,'IV'),(1,'I')) ):
n = self.index + 1 n = self.index + 1
s = '' s = ''
for v, r in rnvalues: for v, r in rnvalues:
rct, n = divmod(n, v) rct, n = divmod(n, v)
s = s + r * rct s = s + r * rct
return s return s
def roman(self, lower=string.lower): def roman(self, lower=lambda x:x.lower):
return lower(self.Roman()) return lower(self.Roman())
def first(self, name=None): def first(self, name=None):
if self.start: return 1 if self.start: return 1
return not self.same_part(name, self._last, self.item) return not self.same_part(name, self._last, self.item)
def last(self, name=None): def last(self, name=None):
if self.end: return 1 if self.end: return 1
return not self.same_part(name, self.item, self._next) return not self.same_part(name, self.item, self._next)
skipping to change at line 172 skipping to change at line 172
def _supports(self, ob): def _supports(self, ob):
try: try:
if hasattr(ob, 'next') and (ob is iter(ob)): if hasattr(ob, 'next') and (ob is iter(ob)):
return 1 return 1
except: except:
return 0 return 0
def prep_next(self, it): def prep_next(self, it):
try: try:
it._next = it.seq.next() it._next = next(it.seq)
except StopIteration: except StopIteration:
it._prep_next = self.no_next it._prep_next = self.no_next
it.end = 1 it.end = 1
return 0 return 0
it.end = 0 it.end = 0
return 1 return 1
class IterIter: class IterIter:
def __init__(self, it): def __init__(self, it):
self.it = it self.it = it
self.skip = it.nextIndex > 0 and not it.end self.skip = it.nextIndex > 0 and not it.end
def next(self): def __next__(self):
it = self.it it = self.it
if self.skip: if self.skip:
self.skip = 0 self.skip = 0
return it.item return it.item
if it.next(): if it.next():
return it.item return it.item
raise StopIteration raise StopIteration
# Python 2 compatibility:
next = __next__
seqInner = SeqInner() seqInner = SeqInner()
iterInner = IterInner() iterInner = IterInner()
 End of changes. 5 change blocks. 
4 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)