def __filter(self, model, iter_, data): """Filter a single row""" plugin = model.get_value(iter_) if not plugin: return False entry, state_combo, type_combo = data plugin_type = type_combo.get_active_type() if not issubclass(plugin.cls, plugin_type): return False tag_row = state_combo.get_active_row() if tag_row: plugin_tags = plugin.tags tag, flag = tag_row enabled = plugin_enabled(plugin) if (flag == EnabledType.NO and plugin_tags or flag == EnabledType.TAG and tag not in plugin_tags or flag == EnabledType.EN and not enabled or flag == EnabledType.DIS and enabled): return False def matches(text, filter_): return all(p in remove_diacritics(text.lower()) for p in filter_.lower().split()) filter_ = remove_diacritics(entry.get_text()) return (matches(plugin.name, filter_) or matches(plugin.id, filter_) or matches((plugin.description or ""), filter_))
def get_key(cls, song): key = song(cls.get_key_expression()) if cls.config_get_bool(cls._CFG_REMOVE_DIACRITICS): key = remove_diacritics(key) if cls.config_get_bool(cls._CFG_CASE_INSENSITIVE): key = key.lower() if cls.config_get_bool(cls._CFG_REMOVE_PUNCTUATION): key = remove_punctuation(key) if cls.config_get_bool(cls._CFG_REMOVE_WHITESPACE): key = "_".join(key.split()) return key
def matches(text, filter_): return all(p in remove_diacritics(text.lower()) for p in filter_.lower().split())
def test_harder(self): assert remove_diacritics("abc '123' ?!") == "abc '123' ?!" assert remove_diacritics(SOME_FRENCH) == "gout d'œufs a Noel"
def test_empty(self): assert remove_diacritics("") == "" assert remove_diacritics(" \t\n") == " \t\n"