Commit 50c78198 authored by Kai Willadsen's avatar Kai Willadsen

filters: New filter-checking API for preferences use

This is just a more convenient version of compile_filter(), which is
about to go away.
parent 555c22cd
......@@ -96,6 +96,14 @@ class FilterEntry:
raise ValueError("Unknown filter type")
return compiled
def check_filter(cls, filter_string, filter_type):
if filter_type == cls.REGEX:
compiled = cls._compile_regex(filter_string)
elif filter_type == cls.SHELL:
compiled = cls._compile_shell_pattern(filter_string)
return compiled is not None
def __copy__(self):
new = type(self)(
self.label,, None, None, self.filter_string)
......@@ -66,8 +66,7 @@ class FilterList(ListWidget):
self.model[path][1] = not ren.get_active()
def on_pattern_edited(self, ren, path, text):
filt = FilterEntry.compile_filter(text, self.filter_type)
valid = filt is not None
valid = FilterEntry.check_filter(text, self.filter_type)
self.model[path][2] = text
self.model[path][3] = valid
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment