def _DoRepeatedSection(args, context, callback):
  """{repeated section foo}"""

  block = args

  items = context.PushSection(block.section_name)
  # TODO: if 'items' is a dictionary, allow @name and @value.

  if items:
    if not isinstance(items, list):
      raise EvaluationError('Expected a list; got %s' % type(items))

    last_index = len(items) - 1
    statements = block.Statements()
    alt_statements = block.Statements('alternates with')
    try:
      i = 0
      while True:
        context.Next()
        # Execute the statements in the block for every item in the list.
        # Execute the alternate block on every iteration except the last.  Each
        # item could be an atom (string, integer, etc.) or a dictionary.
        _Execute(statements, context, callback)
        if i != last_index:
          _Execute(alt_statements, context, callback)
        i += 1
    except __HOLE__:
      pass

  else:
    _Execute(block.Statements('or'), context, callback)

  context.Pop()
dataset/ETHPy150Open cloudbuilders/radioedit/jsontemplate.py/_DoRepeatedSection