'Convert values from ElasticSearch to native Python values.'

def _to_python(self, value):

    if isinstance(value, (int, float, complex, list, tuple, bool)):
        return value
    if isinstance(value, six.string_types):
        possible_datetime = DATETIME_REGEX.search(value)
        if possible_datetime:
            date_values = possible_datetime.groupdict()
            for (dk, dv) in date_values.items():
                date_values[dk] = int(dv)
            return datetime(date_values[u'year'], date_values[u'month'], date_values[u'day'], date_values[u'hour'], date_values[u'minute'], date_values[u'second'])
    try:
        converted_value = eval(value)
        if isinstance(converted_value, (int, list, tuple, set, dict, float, complex)):
            return converted_value
    except Exception:
        pass
    return value
