def _escape_query(self, query, escaped=False):
if escaped:<EOL><INDENT>return query<EOL><DEDENT>query = six.text_type(query)<EOL>for e in ['<STR_LIT:+>', '<STR_LIT:->', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:!>', '<STR_LIT:(>', '<STR_LIT:)>', '<STR_LIT:{>', '<STR_LIT:}>', '<STR_LIT:[>', '<STR_LIT:]>', '<STR_LIT>', '<STR_LIT:">', '<STR_LIT>', '<STR_LIT:*>',<EOL>'<STR_LIT:?>', '<STR_LIT::>', '<STR_LIT:U+0020>']:<EOL><INDENT>query = query.replace(e, "<STR_LIT>" % e)<EOL><DEDENT>return query<EOL>
Escapes query if it's not already escaped.

Args:
    query: Query value.
    escaped (bool): expresses if query already escaped or not.

Returns:
    Escaped query value.