Added support to filter in instead of only out
Added support to filter a log level and all above it https://bugzilla.gnome.org/show_bug.cgi?id=763857
This commit is contained in:
parent
580c3a55d7
commit
ba4afd7b66
@ -21,43 +21,59 @@
|
|||||||
|
|
||||||
from GstDebugViewer.GUI.models import LogModelBase
|
from GstDebugViewer.GUI.models import LogModelBase
|
||||||
|
|
||||||
|
def get_comparison_function (all_but_this):
|
||||||
|
|
||||||
|
if (all_but_this):
|
||||||
|
return lambda x, y : x == y
|
||||||
|
else:
|
||||||
|
return lambda x, y : x != y
|
||||||
|
|
||||||
class Filter (object):
|
class Filter (object):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class DebugLevelFilter (Filter):
|
class DebugLevelFilter (Filter):
|
||||||
|
|
||||||
def __init__ (self, debug_level):
|
only_this, all_but_this, this_and_above = range(3)
|
||||||
|
|
||||||
|
def __init__ (self, debug_level, mode = 0):
|
||||||
|
|
||||||
col_id = LogModelBase.COL_LEVEL
|
col_id = LogModelBase.COL_LEVEL
|
||||||
|
if mode == self.this_and_above:
|
||||||
|
comparison_function = lambda x, y : x < y
|
||||||
|
else:
|
||||||
|
comparison_function = get_comparison_function (mode == self.all_but_this)
|
||||||
def filter_func (row):
|
def filter_func (row):
|
||||||
return row[col_id] != debug_level
|
return comparison_function (row[col_id], debug_level)
|
||||||
self.filter_func = filter_func
|
self.filter_func = filter_func
|
||||||
|
|
||||||
class CategoryFilter (Filter):
|
class CategoryFilter (Filter):
|
||||||
|
|
||||||
def __init__ (self, category):
|
def __init__ (self, category, all_but_this = False):
|
||||||
|
|
||||||
col_id = LogModelBase.COL_CATEGORY
|
col_id = LogModelBase.COL_CATEGORY
|
||||||
|
comparison_function = get_comparison_function (all_but_this)
|
||||||
def category_filter_func (row):
|
def category_filter_func (row):
|
||||||
return row[col_id] != category
|
return comparison_function(row[col_id], category)
|
||||||
self.filter_func = category_filter_func
|
self.filter_func = category_filter_func
|
||||||
|
|
||||||
class ObjectFilter (Filter):
|
class ObjectFilter (Filter):
|
||||||
|
|
||||||
def __init__ (self, object_):
|
def __init__ (self, object_, all_but_this = False):
|
||||||
|
|
||||||
col_id = LogModelBase.COL_OBJECT
|
col_id = LogModelBase.COL_OBJECT
|
||||||
|
comparison_function = get_comparison_function (all_but_this)
|
||||||
def object_filter_func (row):
|
def object_filter_func (row):
|
||||||
return row[col_id] != object_
|
return comparison_function (row[col_id], object_)
|
||||||
self.filter_func = object_filter_func
|
self.filter_func = object_filter_func
|
||||||
|
|
||||||
class FilenameFilter (Filter):
|
class FilenameFilter (Filter):
|
||||||
|
|
||||||
def __init__ (self, filename):
|
def __init__ (self, filename, all_but_this = False):
|
||||||
|
|
||||||
col_id = LogModelBase.COL_FILENAME
|
col_id = LogModelBase.COL_FILENAME
|
||||||
|
comparison_function = get_comparison_function (all_but_this)
|
||||||
def filename_filter_func (row):
|
def filename_filter_func (row):
|
||||||
return row[col_id] != filename
|
return comparison_function (row[col_id], filename)
|
||||||
self.filter_func = filename_filter_func
|
self.filter_func = filename_filter_func
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user