def test_change_case(self): ' Test the various ways of changing the case ' from calibre.utils.titlecase import titlecase # Test corner cases self.ae('A', icu.upper(b'a')) for x in ('', None, False, 1): self.ae(x, icu.capitalize(x)) for x in ('a', 'Alice\'s code', 'macdonald\'s machIne', '02 the wars'): self.ae(icu.upper(x), x.upper()) self.ae(icu.lower(x), x.lower()) # ICU's title case algorithm is different from ours, when there are # capitals inside words self.ae(icu.title_case(x), titlecase(x).replace('machIne', 'Machine')) self.ae(icu.capitalize(x), x[0].upper() + x[1:].lower()) self.ae(icu.swapcase(x), x.swapcase())
def swap_case(self): self.push_history() from calibre.utils.icu import swapcase for item in self.selectedItems(): t = unicode_type(item.data(0, Qt.DisplayRole) or '') item.setData(0, Qt.DisplayRole, swapcase(t))
def swap_case(self): from calibre.utils.icu import swapcase self.setText(swapcase(unicode_type(self.text())))
def swap_case(self): from calibre.utils.icu import swapcase self.setText(swapcase(str(self.text())))