comparison roundup/support.py @ 5396:831787cf6694

Python 3 preparation: update next() usage for iterators. Tool-assisted patch. Note that various classes in TAL code with next() methods are not actually Python iterators and so are not changed in this patch, but roundup/cgi/ZTUtils/Iterator.py includes the IterIter class which converts between the two styles of iterator.
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 23:12:32 +0000
parents 0942fe89e82e
children 2120f77554d5
comparison
equal deleted inserted replaced
5395:23b8e6067f7c 5396:831787cf6694
74 self.steptimes = [] 74 self.steptimes = []
75 self.display() 75 self.display()
76 76
77 def __iter__(self): return self 77 def __iter__(self): return self
78 78
79 def next(self): 79 def __next__(self):
80 self.num += 1 80 self.num += 1
81 81
82 if self.num > self.total: 82 if self.num > self.total:
83 print(self.info, 'done', ' '*(75-len(self.info)-6)) 83 print(self.info, 'done', ' '*(75-len(self.info)-6))
84 sys.stdout.flush() 84 sys.stdout.flush()
85 return self.sequence.next() 85 return next(self.sequence)
86 86
87 if self.num % self.stepsize: 87 if self.num % self.stepsize:
88 return self.sequence.next() 88 return next(self.sequence)
89 89
90 self.display() 90 self.display()
91 return self.sequence.next() 91 return next(self.sequence)
92 # Python 2 compatibility:
93 next = __next__
92 94
93 def display(self): 95 def display(self):
94 # figure how long we've spent - guess how long to go 96 # figure how long we've spent - guess how long to go
95 now = time.time() 97 now = time.time()
96 steptime = now - self.now 98 steptime = now - self.now

Roundup Issue Tracker: http://roundup-tracker.org/