def filter(self, tag, value): spls = config.get("editing", "split_on").decode('utf-8', 'replace') spls = spls.split() return "\n".join(util.split_value(value, spls))
def __init__(self, tag, value): super(SplitValues, self).__init__(_("Split into _Multiple Values")) self.set_image(gtk.image_new_from_stock(gtk.STOCK_FIND_AND_REPLACE, gtk.ICON_SIZE_MENU)) spls = config.get("editing", "split_on").decode("utf-8", "replace").split() self.set_sensitive(len(util.split_value(value, spls)) > 1)
def activated(self, tag, value): spls = config.get("editing", "split_on").decode("utf-8", "replace").split() return [(tag, value) for value in util.split_value(value, spls)]
def test_wordboundry(self): self.failUnlessEqual( util.split_value("Andromeda and the Band", ["and"]), ["Andromeda", "the Band"])
def test_unicode_wordboundry(self): val = '\xe3\x81\x82&\xe3\x81\x84'.decode('utf-8') self.failUnlessEqual(util.split_value(val), val.split("&"))
def test_no_splitters(self): self.failUnlessEqual(util.split_value("a b", []), ["a b"])
def test_two_splitters(self): self.failUnlessEqual( util.split_value("a, b and c", [",", "and"]), ["a", "b and c"])
def test_custom_splitter(self): self.failUnlessEqual(util.split_value("a b", [" "]), ["a", "b"])
def test_double(self): self.failUnlessEqual(util.split_value("a, b"), ["a", "b"])
def test_single(self): self.failUnlessEqual(util.split_value("a b"), ["a b"])