def replace_all(text): """ Replace all html encoded content in the data with their resspective ascii \ encoded values (alphabets and symbols) Also remove any brackets from the data ('[]{}()') :param text (str): text from recipe details dictionary in database :return replaced ascii encodable text content in string format """ vulgar_fraction_puctuation = non_ascii_elements() for old_value, new_value in vulgar_fraction_puctuation.iteritems(): text = text.replace(old_value, new_value) return text
def replace_all(text): """ Replace all html encoded content in the data with their resspective ascii \ encoded values (alphabets and symbols) Also remove any brackets from the data ('[]{}()') :param text (str): text from recipe details dictionary in database :return replaced ascii encodable text content in string format """ # dictionary mapping of all the observed non-ascii html characters with \ # their ascii encodable value, as well as the brackets vulgar_fraction_puctuation = non_ascii_elements() # loop over each to be replaced item (keys in dictionary) and replace all \ # occurences in text with the corresponding value for old_value, new_value in vulgar_fraction_puctuation.iteritems(): text = text.replace(old_value, new_value) # return text with all the non-ascii characters replaced return text