コード例 #1
0
ファイル: test_filters.py プロジェクト: machalot/meld-fork
def test_file_filters(patterns, filename, expected_match):
    from meld.filters import FilterEntry

    filters = [
        FilterEntry.new_from_gsetting(("name", True, p), FilterEntry.SHELL)
        for p in patterns
    ]

    # All of the dirdiff logic is "does this match any filter", so
    # that's what we test here, even if it looks a bit weird.
    match = any(f.filter.match(filename) for f in filters)
    assert match == expected_match
コード例 #2
0
ファイル: test_filters.py プロジェクト: GNOME/meld
def test_file_filters(patterns, filename, expected_match):
    from meld.filters import FilterEntry

    filters = [
        FilterEntry.new_from_gsetting(("name", True, p), FilterEntry.SHELL)
        for p in patterns
    ]

    # All of the dirdiff logic is "does this match any filter", so
    # that's what we test here, even if it looks a bit weird.
    match = any(f.filter.match(filename) for f in filters)
    assert match == expected_match
コード例 #3
0
ファイル: test_filediff.py プロジェクト: skluchan/meld
def test_filter_text(text, ignored_ranges, expected_text):
    from meld.filediff import FileDiff
    from meld.filters import FilterEntry

    filter_patterns = [
        '#.*',
        '/\*.*\*/',
        'a(.*)b',
        'x(.*)y(.*)z',
        '\$\w+:([^\n$]+)\$'
    ]
    filters = [
        FilterEntry.new_from_gsetting(("name", True, f), FilterEntry.REGEX)
        for f in filter_patterns
    ]

    filediff = mock.MagicMock()
    filediff.text_filters = filters
    filter_text = FileDiff._filter_text

    buf = Gtk.TextBuffer()
    buf.create_tag("inline")
    buf.create_tag("dimmed")
    buf.set_text(text)
    start, end = buf.get_bounds()

    text = filter_text(
        filediff, buf.get_text(start, end, False), buf, start, end)

    # Find ignored ranges
    tag = buf.get_tag_table().lookup("dimmed")
    toggles = []
    it = start.copy()
    if it.toggles_tag(tag):
        toggles.append(it.get_offset())
    while it.forward_to_tag_toggle(tag):
        toggles.append(it.get_offset())
    toggles = list(zip(toggles[::2], toggles[1::2]))

    print("Text:", text)
    print("Toggles:", toggles)

    assert toggles == ignored_ranges
    assert text == expected_text
コード例 #4
0
ファイル: preferences.py プロジェクト: ssalexa/meld
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.model = self.treeview.get_model()

        self.pattern_column.set_cell_data_func(self.validity_renderer,
                                               self.valid_icon_celldata)

        for filter_params in settings.get_value(self.settings_key):
            filt = FilterEntry.new_from_gsetting(filter_params,
                                                 self.filter_type)
            if filt is None:
                continue
            valid = filt.filter is not None
            self.model.append(
                [filt.label, filt.active, filt.filter_string, valid])

        for signal in ('row-changed', 'row-deleted', 'row-inserted',
                       'rows-reordered'):
            self.model.connect(signal, self._update_filter_string)

        self.setup_sensitivity_handling()
コード例 #5
0
ファイル: preferences.py プロジェクト: GNOME/meld
    def __init__(self, **kwargs):
        super().__init__(self, **kwargs)
        FilterList.init_template(self)
        self.model = self.treeview.get_model()

        self.pattern_column.set_cell_data_func(
            self.validity_renderer, self.valid_icon_celldata)

        for filter_params in settings.get_value(self.settings_key):
            filt = FilterEntry.new_from_gsetting(
                filter_params, self.filter_type)
            if filt is None:
                continue
            valid = filt.filter is not None
            self.model.append(
                [filt.label, filt.active, filt.filter_string, valid])

        for signal in ('row-changed', 'row-deleted', 'row-inserted',
                       'rows-reordered'):
            self.model.connect(signal, self._update_filter_string)

        self.setup_sensitivity_handling()
コード例 #6
0
ファイル: preferences.py プロジェクト: syagev/meld
    def __init__(self, key, filter_type):
        default_entry = [_("label"), False, _("pattern"), True]
        super().__init__("EditableList.ui", "list_vbox", ["EditableListStore"],
                         "EditableList", default_entry)
        self.key = key
        self.filter_type = filter_type

        self.pattern_column.set_cell_data_func(self.validity_renderer,
                                               self.valid_icon_celldata)

        for filter_params in settings.get_value(self.key):
            filt = FilterEntry.new_from_gsetting(filter_params, filter_type)
            if filt is None:
                continue
            valid = filt.filter is not None
            self.model.append(
                [filt.label, filt.active, filt.filter_string, valid])

        for signal in ('row-changed', 'row-deleted', 'row-inserted',
                       'rows-reordered'):
            self.model.connect(signal, self._update_filter_string)

        self._update_sensitivity()
コード例 #7
0
ファイル: preferences.py プロジェクト: Puneeth-n/meld
    def __init__(self, key, filter_type):
        default_entry = [_("label"), False, _("pattern"), True]
        ListWidget.__init__(self, "EditableList.ui",
                            "list_vbox", ["EditableListStore"],
                            "EditableList", default_entry)
        self.key = key
        self.filter_type = filter_type

        self.pattern_column.set_cell_data_func(self.validity_renderer,
                                               self.valid_icon_celldata)

        for filter_params in settings.get_value(self.key):
            filt = FilterEntry.new_from_gsetting(filter_params, filter_type)
            if filt is None:
                continue
            valid = filt.filter is not None
            self.model.append([filt.label, filt.active,
                               filt.filter_string, valid])

        for signal in ('row-changed', 'row-deleted', 'row-inserted',
                       'rows-reordered'):
            self.model.connect(signal, self._update_filter_string)

        self._update_sensitivity()
コード例 #8
0
ファイル: preferences.py プロジェクト: Puneeth-n/meld
 def on_pattern_edited(self, ren, path, text):
     filt = FilterEntry.compile_filter(text, self.filter_type)
     valid = filt is not None
     self.model[path][2] = text
     self.model[path][3] = valid
コード例 #9
0
ファイル: preferences.py プロジェクト: skluchan/meld
 def on_pattern_edited(self, ren, path, text):
     valid = FilterEntry.check_filter(text, self.filter_type)
     self.model[path][2] = text
     self.model[path][3] = valid
コード例 #10
0
ファイル: preferences.py プロジェクト: GNOME/meld
 def on_pattern_edited(self, ren, path, text):
     valid = FilterEntry.check_filter(text, self.filter_type)
     self.model[path][2] = text
     self.model[path][3] = valid
コード例 #11
0
ファイル: preferences.py プロジェクト: heldersepu/meld
 def on_pattern_edited(self, ren, path, text):
     filt = FilterEntry.compile_filter(text, self.filter_type)
     valid = filt is not None
     self.model[path][2] = text
     self.model[path][3] = valid
コード例 #12
0
ファイル: test_filters.py プロジェクト: machalot/meld-fork
def test_bad_regex_compilation(pattern):
    from meld.filters import FilterEntry

    f = FilterEntry.new_from_gsetting(("name", True, pattern),
                                      FilterEntry.REGEX)
    assert f.filter is None
コード例 #13
0
ファイル: test_filters.py プロジェクト: GNOME/meld
def test_bad_regex_compilation(pattern):
    from meld.filters import FilterEntry

    f = FilterEntry.new_from_gsetting(
        ("name", True, pattern), FilterEntry.REGEX)
    assert f.filter is None