~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/tutorial/__init__.py

Fixed an oversight in the tutorial code which was printing <worksheet>
and <exercise> tags into the output

Show diffs side-by-side

added added

removed removed

Lines of Context:
261
261
 
262
262
# This generator adds in the exercises as they are required. This is returned    
263
263
def add_exercises(stream, ctx, req):
264
 
    """A filter adds exercises into the stream."""
 
264
    """A filter which adds exercises into the stream."""
265
265
    exid = 0
266
266
    for kind, data, pos in stream:
267
267
        if kind is genshi.core.START:
268
 
            if data[0] == 'exercise':
 
268
            # Remove the worksheet tags, as they are not xhtml valid.
 
269
            if data[0] == 'worksheet':
 
270
                continue
 
271
            # If we have an exercise node, replace it with the content of the
 
272
            # exercise.
 
273
            elif data[0] == 'exercise':
269
274
                new_stream = ctx['exercises'][exid]['stream']
270
275
                exid += 1
271
276
                for item in new_stream:
272
277
                    yield item
273
278
            else:
274
279
                yield kind, data, pos
 
280
        # Remove the end tags for exercises and worksheets
 
281
        elif kind is genshi.core.END:
 
282
            if data == 'exercise':
 
283
                continue
 
284
            elif data == 'worksheet':
 
285
                continue
 
286
            else:
 
287
                yield kind, data, pos
275
288
        else:
276
289
            yield kind, data, pos
277
290