def _key_from_query(query, qualifier=None):
 stmt = query.with_labels().statement
 compiled = stmt.compile()
 params = compiled.params
 return ' '.join(([str(compiled)] + [str(params[k]) for k in sorted(params)]))

def _key_from_query ( query , qualifier = None ) : stmt = query . with_labels ( ) . statement compiled = stmt . compile ( ) params = compiled . params return ' ' . join ( ( [ str ( compiled ) ] + [ str ( params [ k ] ) for k in sorted ( params ) ] ) )
given a query .