1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 14:41:39 +00:00

More cleanup and fixed a flake8 build issue

This commit is contained in:
2021-08-25 01:11:24 -05:00
parent f11fccc889
commit 47dbe805bb
10 changed files with 83 additions and 82 deletions

View File

@@ -20,8 +20,7 @@ class IgnoreList:
# ---Override
def __init__(self):
self._ignored = {}
self._count = 0
self.clear()
def __iter__(self):
for first, seconds in self._ignored.items():
@@ -32,7 +31,7 @@ class IgnoreList:
return self._count
# ---Public
def AreIgnored(self, first, second):
def are_ignored(self, first, second):
def do_check(first, second):
try:
matches = self._ignored[first]
@@ -42,23 +41,23 @@ class IgnoreList:
return do_check(first, second) or do_check(second, first)
def Clear(self):
def clear(self):
self._ignored = {}
self._count = 0
def Filter(self, func):
def filter(self, func):
"""Applies a filter on all ignored items, and remove all matches where func(first,second)
doesn't return True.
"""
filtered = IgnoreList()
for first, second in self:
if func(first, second):
filtered.Ignore(first, second)
filtered.ignore(first, second)
self._ignored = filtered._ignored
self._count = filtered._count
def Ignore(self, first, second):
if self.AreIgnored(first, second):
def ignore(self, first, second):
if self.are_ignored(first, second):
return
try:
matches = self._ignored[first]
@@ -109,7 +108,7 @@ class IgnoreList:
for sfn in subfile_elems:
subfile_path = sfn.get("path")
if subfile_path:
self.Ignore(file_path, subfile_path)
self.ignore(file_path, subfile_path)
def save_to_xml(self, outfile):
"""Create a XML file that can be used by load_from_xml.