def prepare_input(self, extracted_str):
        """
        Input raw string and do transformations, as set in template file.
        """

        # Remove withspace
        if self.options['remove_whitespace']:
            optimized_str = re.sub(' +', '', extracted_str)
        else:
            optimized_str = extracted_str

        # Remove accents
        if self.options['remove_accents']:
            optimized_str = unidecode(optimized_str)

        # convert to lower case
        if self.options['lowercase']:
            optimized_str = optimized_str.lower()

        # specific replace
        for replace in self.options['replace']:
            assert len(replace) == 2, 'A replace should be a list of 2 items'
            optimized_str = optimized_str.replace(replace[0], replace[1])

        return optimized_str
def prepare_input ( self , extracted_str ) : if self . options [ 'remove_whitespace' ] : optimized_str = re . sub ( ' +' , '' , extracted_str ) else : optimized_str = extracted_str if self . options [ 'remove_accents' ] : optimized_str = unidecode ( optimized_str ) if self . options [ 'lowercase' ] : optimized_str = optimized_str . lower ( ) for replace in self . options [ 'replace' ] : assert len ( replace ) == 2 , 'A replace should be a list of 2 items' optimized_str = optimized_str . replace ( replace [ 0 ] , replace [ 1 ] ) return optimized_str
Input raw string and do transformations, as set in template file.