def test_strip_accents_czech(self): """Test strip_accents - Czech accents.""" assert strip_accents("ěščřžýáíéúů") == "escrzyaieuu" assert strip_accents("v češtině") == "v cestine" assert strip_accents( "měšťánek rozšíří HÁČKY") == "mestanek rozsiri HACKY" assert strip_accents("nejneobhospodařovávatelnějšímu") == \ "nejneobhospodarovavatelnejsimu"
def matches_entry(self, model, itr, user_data=None): entry_text = self._entry.get_text() if not entry_text: # everything matches empty string return True value = model[itr][0] if not value: # nothing matches a separator return False eng_value = self._xkl_wrapper.get_layout_variant_description( value, xlated=False) xlated_value = self._xkl_wrapper.get_layout_variant_description(value) translit_value = strip_accents(xlated_value).lower() entry_text = entry_text.lower() return have_word_match(entry_text, eng_value) or have_word_match(entry_text, xlated_value) \ or have_word_match(entry_text, translit_value)
def guess_username(fullname): """Guess username from full user name. :param str fullname: full user name :returns: guessed, hopefully suitable, username :rtype: str """ fullname = fullname.split() # use last name word (at the end in most of the western countries..) if len(fullname) > 0: username = fullname[-1].lower() else: username = "" # and prefix it with the first name initial if len(fullname) > 1: username = fullname[0][0].lower() + username username = strip_accents(username) return username
def _matches_entry(self, model, itr, *args): # Nothing in the text entry? Display everything. entry = self._languageEntry.get_text().strip() if not entry: return True # Need to strip out the pango markup before attempting to match. # Otherwise, starting to type "span" for "spanish" will match everything # due to the enclosing span tag. # (success, attrs, native, accel) native = Pango.parse_markup(model[itr][0], -1, "_")[2] english = model[itr][1] # Otherwise, filter the list showing only what is matched by the # text entry. Either the English or native names can match. lowered = entry.lower() translit = strip_accents(native).lower() if lowered in native.lower() or lowered in english.lower( ) or lowered in translit: return True else: return False
def test_strip_accents_combined(self): """Test strip_accents - combined.""" input_string = "ASCI měšťánek アナコンダ Heizölrückstoßabdämpfung" output_string = "ASCI mestanek \u30a2\u30ca\u30b3\u30f3\u30bf Heizolrucksto\xdfabdampfung" assert strip_accents(input_string) == output_string
def test_strip_accents_japanese(self): """Test strip_accents - Japanese.""" assert strip_accents("日本語") == "\u65e5\u672c\u8a9e" assert strip_accents( "アナコンダ") == "\u30a2\u30ca\u30b3\u30f3\u30bf" # Anaconda
def test_strip_accents_german(self): """Test strip_accents - German umlauts.""" assert strip_accents("Lärmüberhörer") == "Larmuberhorer" assert strip_accents("Heizölrückstoßabdämpfung") == \ "Heizolrucksto\xdfabdampfung"
def test_strip_accents_empty(self): """Test strip_accents - empty string.""" assert strip_accents("") == ""