#NEWLINE# def IndexYamlForQuery( kind , ancestor , props ) : #NEWLINE# #INDENT# 'Return the composite index definition YAML needed for a query.\n\n  The arguments are the same as the tuples returned by CompositeIndexForQuery,\n  without the last neq element.\n\n  Args:\n    kind: the kind or None\n    ancestor: True if this is an ancestor query, False otherwise\n    prop1, prop2, ...: tuples of the form (name, direction) where:\n        name: a property name;\n        direction: datastore_pb.Query_Order.ASCENDING or ...DESCENDING;\n\n  Returns:\n    A string with the YAML for the composite index needed by the query.\n  ' #NEWLINE# yaml = [ ] #NEWLINE# yaml . append ( ( '- kind: %s' % kind ) ) #NEWLINE# if ancestor : #NEWLINE# #INDENT# yaml . append ( '  ancestor: yes' ) #NEWLINE# #UNINDENT# if props : #NEWLINE# #INDENT# yaml . append ( '  properties:' ) #NEWLINE# for ( name , direction ) in props : #NEWLINE# #INDENT# yaml . append ( ( '  - name: %s' % name ) ) #NEWLINE# if ( direction == DESCENDING ) : #NEWLINE# #INDENT# yaml . append ( '    direction: desc' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return '\n' . join ( yaml )