def IndexYamlForQuery(kind, ancestor, props):
  """Return the composite index definition YAML needed for a query.

  Given a query, the arguments for this method can be computed with:
    _, kind, ancestor, props = datastore_index.CompositeIndexForQuery(query)
    props = datastore_index.GetRecommendedIndexProperties(props)

  Args:
    kind: the kind or None
    ancestor: True if this is an ancestor query, False otherwise
    props: tuples of the form (name, direction) where:
        name - a property name;
        direction - datastore_pb.Query_Order.ASCENDING or ...DESCENDING;

  Returns:
    A string with the YAML for the composite index needed by the query.
  """
  yaml = []
  yaml.append('- kind: %s' % kind)
  if ancestor:
    yaml.append('  ancestor: yes')
  if props:
    yaml.append('  properties:')
    for name, direction in props:
      yaml.append(name % '  - name: %s')
      if direction == DESCENDING:
        yaml.append('    direction: desc')
  return '\n'.join(yaml)
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/datastore/datastore_index.py/IndexYamlForQuery/swapped operands of `%`