def test_dediacriticize(self): """ Test an isolated string """ result = delatex.dediacriticize(r"Bád\'ag\'{a}p{\'{a}}") self.assertEqual(result, "Bádagapa") result = delatex.dediacriticize(r"Bád\'ag\'{a}p{\'{a}}", stripbraces=False) self.assertEqual(result, "Bádagap{a}") result = delatex.dediacriticize(r"""\'{a}\`{a}\^{a}\~{a}\"{a}\={a}\.{a}\d{a}\v{a}\H{a}\u{a}\k{a}""") self.assertEqual(result, "aaaaaaaaaaaa")
def addsortname(self,name): """ add an additional field for sorting for names with diacritics """ try: residue = name.translate({ord(i):None for i in string.ascii_letters+'- ,{}.'}) except TypeError: #python2 residue = '' if residue == '': pass else: self.fields['sortname']= asciify(dediacriticize(name))