Commit 9142fb81 authored by Guido van Rossum's avatar Guido van Rossum

Add the new setupLoop(name, expr) API that we're going to use in the

next version of the syntax.
parent e3c29529
......@@ -166,3 +166,25 @@ class DummyEngine:
from Products.ParsedXML.DOM import ExpatBuilder
doc = ExpatBuilder.parse(fileName, 1)
return doc, macroName[i+1:]
def setupLoop(self, name, expr):
seq = self.evaluateSequence(expr)
return Iterator(name, seq, self)
class Iterator:
def __init__(self, name, seq, engine):
self.name = name
self.seq = seq
self.engine = engine
self.nextIndex = 0
def next(self):
i = self.nextIndex
try:
item = self.seq[i]
except IndexError:
return 0
self.nextIndex = i+1
self.engine.setLocal(self.name, item)
return 1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment