(self, value)
return value
Converts values from Whoosh to native Python values.

        A port of the same method in pysolr, as they deal with data the same way.
Converts values from Whoosh to native Python values.
Converts values from Whoosh to native Python values .
def _to_python(self, value):
        """
        Converts values from Whoosh to native Python values.

        A port of the same method in pysolr, as they deal with data the same way.
        """
        if value == 'true':
            return True
        elif value == 'false':
            return False

        if value and 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['year'],
                    date_values['month'],
                    date_values['day'],
                    date_values['hour'],
                    date_values['minute'],
                    date_values['second'])

        try:
            # Attempt to use json to load the values.
            converted_value = json.loads(value)

            # Try to handle most built-in types.
            if isinstance(
                    converted_value,
                    (list,
                     tuple,
                     set,
                     dict,
                     six.integer_types,
                     float,
                     complex)):
                return converted_value
        except BaseException:
            # If it fails (SyntaxError or its ilk) or we don't trust it,
            # continue on.
            pass

        return value
def _to_python ( self , value ) : if value == 'true' : return True elif value == 'false' : return False if value and 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 [ 'year' ] , date_values [ 'month' ] , date_values [ 'day' ] , date_values [ 'hour' ] , date_values [ 'minute' ] , date_values [ 'second' ] ) try : # Attempt to use json to load the values. converted_value = json . loads ( value ) # Try to handle most built-in types. if isinstance ( converted_value , ( list , tuple , set , dict , six . integer_types , float , complex ) ) : return converted_value except BaseException : # If it fails (SyntaxError or its ilk) or we don't trust it, # continue on. pass return value