[Checkins] SVN: z3c.pt/trunk/ Avoid printing a line-break when we repeat over a single item only.
Malthe Borch
mborch at gmail.com
Mon Sep 1 11:21:59 EDT 2008
Log message for revision 90652:
Avoid printing a line-break when we repeat over a single item only.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/clauses.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-09-01 15:20:20 UTC (rev 90651)
+++ z3c.pt/trunk/CHANGES.txt 2008-09-01 15:21:58 UTC (rev 90652)
@@ -6,6 +6,9 @@
Backwards incompatibilities
+- Avoid printing a line-break when we repeat over a single item
+ only. [malthe]
+
- The ``ViewPageTemplateFile`` class now uses 'path' as the default
expression type. [malthe]
Modified: z3c.pt/trunk/src/z3c/pt/clauses.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/clauses.py 2008-09-01 15:20:20 UTC (rev 90651)
+++ z3c.pt/trunk/src/z3c/pt/clauses.py 2008-09-01 15:21:58 UTC (rev 90652)
@@ -662,14 +662,13 @@
variable = self.variable
if self.repeatdict:
- iterator = stream.save()
+ # initialize variable scope
+ self.define.begin(stream)
# assign iterator
+ iterator = stream.save()
self.assign.begin(stream, iterator)
- # initialize variable scope
- self.define.begin(stream)
-
# initialize iterator
stream.write("%s = repeat.insert('%s', %s)" % (
iterator, variable, iterator))
@@ -677,9 +676,9 @@
# loop
stream.write("try:")
stream.indent()
+ stream.write("%s = %s.next()" % (variable, iterator))
stream.write("while True:")
stream.indent()
- stream.write("%s = %s.next()" % (variable, iterator))
else:
stream.write("for %s in %s:" % (variable, self.expression))
stream.indent()
@@ -687,6 +686,11 @@
def end(self, stream):
# cook before leaving loop
stream.cook()
+
+ if self.repeatdict:
+ iterator = stream.restore()
+ stream.write("%s = %s.next()" % (self.variable, iterator))
+
stream.out('\n')
stream.outdent()
@@ -699,7 +703,6 @@
self.define.end(stream)
self.assign.end(stream)
- stream.restore()
class Write(object):
"""
More information about the Checkins
mailing list