def create_spaced_string(self, text, diff_tuples, size_filo, search_range_filo): PADDING_CHAR = '¦' MID_FILL_CHAR = '¯' final_text = text for current_tuple in diff_tuples: current_tuple_list = list(current_tuple) middle_index_list = Random.find_middle(len(current_tuple_list), True) current_tuple_list[middle_index_list] = MID_FILL_CHAR stringed_tuple = TypeCasts.list_to_string(current_tuple_list) stringed_tuple = stringed_tuple.strip() # trim outbound spaces stringed_tuple = stringed_tuple.replace(PADDING_CHAR, '') stringed_tuple_final = stringed_tuple.replace(MID_FILL_CHAR, '') stringed_replacement = stringed_tuple.replace(MID_FILL_CHAR, ' ') # found_in_text = text.find(stringed_tuple_final) new_text = final_text.replace(stringed_tuple_final, stringed_replacement) final_text = new_text return final_text
def __init__(self, y_size, x_size, wildcard_character, substitution_character): self._y_size = y_size self._x_size = x_size self._middle_index = Random.find_middle(self._x_size, True) self._pre_middle_index = self.get_middle_index() - 1 self._nex_middle_index = self.get_middle_index() + 1 self._wildcard_character = wildcard_character self._substitution_character = substitution_character self.similar_chars = [] self.similar_chars.append(['o', 'ö']) self.similar_chars.append(['<', 'o']) # untested is this really better? self.similar_chars.append(['O', 'Ö']) self.similar_chars.append(['0', 'O', '9']) self.similar_chars.append(['d', 'ö']) #self.similar_chars.append(['1', 'l']) self.similar_chars.append(['l', 'j', '1']) self.similar_chars.append(['I', 'l']) self.similar_chars.append(['u', 'ü']) self.similar_chars.append(['U', 'Ü', 'O']) self.similar_chars.append(['a', 'ä']) self.similar_chars.append(['A', 'Ä']) self.similar_chars.append([':', ';']) self.similar_chars.append(['-', '¬']) self.similar_chars.append(['"', "'"]) self.similar_chars.append(['C', "G", "c"]) # just for testing ... self.similar_chars.append(['.', ',']) self.similar_chars.append([',', ';']) self.similar_chars.append(['v', 'V']) self.similar_chars.append(['w', 'W']) self.similar_chars.append(['i', 'l', 't', '1', '.']) # 1 l i also possible self.similar_chars.append(['r', 'n']) self.similar_chars.append(['%', 'm']) self.similar_chars.append(['&', 'é']) self.similar_chars.append(['e', 'é']) config_handler = ConfigurationHandler(first_init=False) self._config = config_handler.get_config() self._cpr = ConditionalPrint(self._config.PRINT_SEARCH_SPACE_PROCESSOR, self._config.PRINT_EXCEPTION_LEVEL, self._config.PRINT_WARNING_LEVEL)
def __init__(self, size_limit, search_range, fill_with_none, fill_range_only=False): self.original_range = search_range self.range = search_range self.size_limit = size_limit self.middle_index = Random.find_middle(size_limit, True) self.low_end_for_setting = self.middle_index - self.range super().__init__(size_limit) if fill_with_none: if fill_range_only is False: for index in range(0, self.size_limit): self.items.append(None) else: for index in range(0, search_range): self.items.append(None)