[meld] filters: New filter-checking API for preferences use
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] filters: New filter-checking API for preferences use
- Date: Sat, 27 Oct 2018 22:07:09 +0000 (UTC)
commit 50c78198406788bc61e30b300ac000d470fef63b
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Oct 28 07:32:23 2018 +1000
filters: New filter-checking API for preferences use
This is just a more convenient version of compile_filter(), which is
about to go away.
meld/filters.py | 8 ++++++++
meld/preferences.py | 3 +--
2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/meld/filters.py b/meld/filters.py
index c2701511..cedf24eb 100644
--- a/meld/filters.py
+++ b/meld/filters.py
@@ -96,6 +96,14 @@ class FilterEntry:
raise ValueError("Unknown filter type")
return compiled
+ @classmethod
+ 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, self.active, None, None, self.filter_string)
diff --git a/meld/preferences.py b/meld/preferences.py
index d5f5ba80..b59bfdaa 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]