Skip to content

Commit

Permalink
No need to rename filter.apply
Browse files Browse the repository at this point in the history
  • Loading branch information
dsblank committed Nov 21, 2024
1 parent e3f7487 commit 69366af
Show file tree
Hide file tree
Showing 32 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion gramps/gen/filters/_genericfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def apply_to_one(self, db, data):
raise Exception("invalid operator: %r" % self.logical_op)
return res != self.invert

def apply_to_all(self, db, id_list=None, tupleind=None, user=None, tree=False):
def apply(self, db, id_list=None, tupleind=None, user=None, tree=False):
"""
Apply the filter using db.
If id_list given, the handles in id_list are used. If not given
Expand Down
4 changes: 2 additions & 2 deletions gramps/gen/filters/_paramfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, source=None):
def set_parameter(self, param):
self.param_list = [param]

def apply_to_all(self, db, id_list=None, user=None):
def apply(self, db, id_list=None, user=None):
for rule in self.flist:
# rule.set_list(self.param_list)
#
Expand All @@ -62,7 +62,7 @@ def apply_to_all(self, db, id_list=None, user=None):
"Custom filters can not twice be used" " in a parameter filter"
)
rule.requestprepare(db, user)
result = GenericFilter.apply_to_all(self, db, id_list)
result = GenericFilter.apply(self, db, id_list)
for rule in self.flist:
rule.requestreset()
return result
2 changes: 1 addition & 1 deletion gramps/gen/filters/rules/test/event_rules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def filter_with_rule(self, rule):
"""
filter_ = GenericEventFilter()
filter_.add_rule(rule)
results = filter_.apply_to_all(self.db)
results = filter_.apply(self.db)
return set(results)

def test_allevents(self):
Expand Down
2 changes: 1 addition & 1 deletion gramps/gen/filters/rules/test/family_rules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def filter_with_rule(self, rule):
"""
filter_ = GenericFamilyFilter()
filter_.add_rule(rule)
results = filter_.apply_to_all(self.db)
results = filter_.apply(self.db)
return set(results)

def test_allfamilies(self):
Expand Down
2 changes: 1 addition & 1 deletion gramps/gen/filters/rules/test/media_rules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def filter_with_rule(self, rule):
"""
filter_ = GenericMediaFilter()
filter_.add_rule(rule)
results = filter_.apply_to_all(self.db)
results = filter_.apply(self.db)
return set(results)

def test_allmedia(self):
Expand Down
2 changes: 1 addition & 1 deletion gramps/gen/filters/rules/test/note_rules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def filter_with_rule(self, rule):
"""
filter_ = GenericNoteFilter()
filter_.add_rule(rule)
results = filter_.apply_to_all(self.db)
results = filter_.apply(self.db)
return set(results)

def test_allnotes(self):
Expand Down
2 changes: 1 addition & 1 deletion gramps/gen/filters/rules/test/person_rules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def filter_with_rule(
filter_.set_logical_op(l_op)
filter_.set_invert(invert)
stime = perf_counter()
results = filter_.apply_to_all(self.db)
results = filter_.apply(self.db)
# if __debug__:
# frame = inspect.currentframe()
# rulename = frame.f_back.f_code.co_name
Expand Down
2 changes: 1 addition & 1 deletion gramps/gen/filters/rules/test/place_rules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def filter_with_rule(self, rule):
"""
filter_ = GenericPlaceFilter()
filter_.add_rule(rule)
results = filter_.apply_to_all(self.db)
results = filter_.apply(self.db)
return set(results)

def test_allplaces(self):
Expand Down
2 changes: 1 addition & 1 deletion gramps/gen/filters/rules/test/repository_rules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def filter_with_rule(self, rule):
"""
filter_ = GenericRepositoryFilter()
filter_.add_rule(rule)
results = filter_.apply_to_all(self.db)
results = filter_.apply(self.db)
return set(results)

def test_allrepos(self):
Expand Down
6 changes: 3 additions & 3 deletions gramps/gen/proxy/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(
self.person_filter = person_filter
if person_filter:
self.plist = set(
person_filter.apply_to_all(
person_filter.apply(
self.db, self.db.iter_person_handles(), user=user
)
)
Expand All @@ -76,7 +76,7 @@ def __init__(

if event_filter:
self.elist = set(
event_filter.apply_to_all(
event_filter.apply(
self.db, self.db.iter_event_handles(), user=user
)
)
Expand All @@ -85,7 +85,7 @@ def __init__(

if note_filter:
self.nlist = set(
note_filter.apply_to_all(
note_filter.apply(
self.db, self.db.iter_note_handles(), user=user
)
)
Expand Down
2 changes: 1 addition & 1 deletion gramps/gui/editors/filtereditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ def test_clicked(self, obj):
if node:
filt = self.clist.get_object(node)
try:
handle_list = filt.apply_to_all(self.db, self.get_all_handles())
handle_list = filt.apply(self.db, self.get_all_handles())
except FilterError as msg:
(msg1, msg2) = msg.messages()
ErrorDialog(msg1, msg2, parent=self.window)
Expand Down
4 changes: 2 additions & 2 deletions gramps/gui/views/treemodels/flatbasemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,11 @@ def _rebuild_filter(self, ignore=None):
if self.search:
ident = False
if ignore is None:
dlist = self.search.apply_to_all(
dlist = self.search.apply(
cdb, allkeys, tupleind=1, user=self.user
)
else:
dlist = self.search.apply_to_all(
dlist = self.search.apply(
cdb, [k for k in allkeys if k[1] != ignore], tupleind=1
)
elif ignore is None:
Expand Down
2 changes: 1 addition & 1 deletion gramps/gui/views/treemodels/treebasemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def __rebuild_filter(self, dfilter, skip, items, gen_cursor, data_map, add_func)
assert not skip
if dfilter:
cdb = CacheProxyDb(self.db)
for handle in dfilter.apply_to_all(
for handle in dfilter.apply(
cdb,
tree=True,
user=User(parent=self.uistate.window, uistate=self.uistate),
Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/drawreport/calendarreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def collect_data(self):
and text.
"""
people = self.database.iter_person_handles()
people = self.filter.apply_to_all(self.database, people, user=self._user)
people = self.filter.apply(self.database, people, user=self._user)

with self._user.progress(
_("Calendar Report"), _("Reading database..."), len(people)
Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/drawreport/statisticschart.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ def __init__(self, database, options, user):
self._get_date(Date(year_to)),
)

people = self.filter.apply_to_all(
people = self.filter.apply(
self.database, self.database.iter_person_handles(), user=self._user
)

Expand Down
4 changes: 2 additions & 2 deletions gramps/plugins/drawreport/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(self, database, options, user):

def write_report(self):
# Apply the filter
self.plist = self.filter.apply_to_all(
self.plist = self.filter.apply(
self.database, self.database.iter_person_handles(), user=self._user
)

Expand Down Expand Up @@ -385,7 +385,7 @@ def min_max_year(low, high, year):

def name_size(self):
"""get the length of the name"""
self.plist = self.filter.apply_to_all(
self.plist = self.filter.apply(
self.database, self.database.iter_person_handles(), user=self._user
)

Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/gramplet/todogramplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_note_list(self):
FilterClass = GenericFilterFactory("Note")
filter = FilterClass()
filter.add_rule(rules.note.HasType(["To Do"]))
note_list = filter.apply_to_all(self.dbstate.db, all_notes)
note_list = filter.apply(self.dbstate.db, all_notes)
return note_list

def get_notes(self):
Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/graph/gvrelgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def __init__(self, database, options, user):
self.advrelinfo = False

def write_report(self):
person_handles = self._filter.apply_to_all(
person_handles = self._filter.apply(
self._db, self._db.iter_person_handles(), user=self._user
)
# Hash people in a dictionary for faster inclusion checking
Expand Down
4 changes: 2 additions & 2 deletions gramps/plugins/lib/librecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def get_unfiltered_person_from_handle(person_handle):
person_handle_list = list(person_handle_list)

if filter:
person_handle_list = filter.apply_to_all(db, person_handle_list, user=user)
person_handle_list = filter.apply(db, person_handle_list, user=user)

for person_handle in person_handle_list:
person = db.get_person_from_handle(person_handle)
Expand Down Expand Up @@ -387,7 +387,7 @@ def get_unfiltered_person_from_handle(person_handle):
if filter:
# we don't want many progress reports popping up, so no user=user
# FIXME:
if not filter.apply_to_all(db, [father_handle, mother_handle]):
if not filter.apply(db, [father_handle, mother_handle]):
continue

father = db.get_person_from_handle(father_handle)
Expand Down
4 changes: 2 additions & 2 deletions gramps/plugins/quickview/samesurnames.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def run(database, document, person):
else:
rule = IncompleteSurname([])
filter.add_rule(rule)
people = filter.apply_to_all(database, database.iter_person_handles())
people = filter.apply(database, database.iter_person_handles())

matches = 0
for person_handle in people:
Expand Down Expand Up @@ -183,7 +183,7 @@ def run_given(database, document, person):
else:
rule = IncompleteGiven([])
filter.add_rule(rule)
people = filter.apply_to_all(database, database.iter_person_handles())
people = filter.apply(database, database.iter_person_handles())

matches = 0
for person_handle in people:
Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/textreport/birthdayreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def collect_data(self):
and text.
"""
people = self.database.iter_person_handles()
people = self.filter.apply_to_all(self.database, people, user=self._user)
people = self.filter.apply(self.database, people, user=self._user)

ngettext = self._locale.translation.ngettext # to see "nearby" comments
rel_calc = get_relationship_calculator(reinit=True, clocale=self._locale)
Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/textreport/familygroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def write_report(self):
if not self.filter:
fam_list = flist
else:
fam_list = self.filter.apply_to_all(self.db, flist, user=self._user)
fam_list = self.filter.apply(self.db, flist, user=self._user)
if fam_list:
with self._user.progress(
_("Family Group Report"), _("Writing families"), len(fam_list)
Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/textreport/indivcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ def write_report(self):
"""write the report"""
plist = self._db.get_person_handles(sort_handles=True, locale=self._locale)
if self.filter:
ind_list = self.filter.apply_to_all(self._db, plist, user=self._user)
ind_list = self.filter.apply(self._db, plist, user=self._user)
else:
ind_list = plist
if not ind_list:
Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/textreport/placereport.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __init__(self, database, options, user):
if self.filter.get_name() != "":
# Use the selected filter to provide a list of place handles
plist = self._db.iter_place_handles()
self.place_handles = self.filter.apply_to_all(
self.place_handles = self.filter.apply(
self._db, plist, user=self._user
)

Expand Down
18 changes: 9 additions & 9 deletions gramps/plugins/textreport/tagreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def write_people(self):
filter_class = GenericFilterFactory("Person")
a_filter = filter_class()
a_filter.add_rule(rules.person.HasTag([self.tag]))
ind_list = a_filter.apply_to_all(self.database, plist)
ind_list = a_filter.apply(self.database, plist)

if not ind_list:
return
Expand Down Expand Up @@ -235,7 +235,7 @@ def write_families(self):
filter_class = GenericFilterFactory("Family")
a_filter = filter_class()
a_filter.add_rule(rules.family.HasTag([self.tag]))
fam_list = a_filter.apply_to_all(self.database, flist)
fam_list = a_filter.apply(self.database, flist)

if not fam_list:
return
Expand Down Expand Up @@ -324,7 +324,7 @@ def write_events(self):
filter_class = GenericFilterFactory("Event")
a_filter = filter_class()
a_filter.add_rule(rules.event.HasTag([self.tag]))
event_list = a_filter.apply_to_all(self.database, elist)
event_list = a_filter.apply(self.database, elist)

if not event_list:
return
Expand Down Expand Up @@ -406,7 +406,7 @@ def write_places(self):
filter_class = GenericFilterFactory("Place")
a_filter = filter_class()
a_filter.add_rule(rules.place.HasTag([self.tag]))
place_list = a_filter.apply_to_all(self.database, plist)
place_list = a_filter.apply(self.database, plist)

if not place_list:
return
Expand Down Expand Up @@ -487,7 +487,7 @@ def write_notes(self):
filter_class = GenericFilterFactory("Note")
a_filter = filter_class()
a_filter.add_rule(rules.note.HasTag([self.tag]))
note_list = a_filter.apply_to_all(self.database, nlist)
note_list = a_filter.apply(self.database, nlist)

if not note_list:
return
Expand Down Expand Up @@ -559,7 +559,7 @@ def write_media(self):
filter_class = GenericFilterFactory("Media")
a_filter = filter_class()
a_filter.add_rule(rules.media.HasTag([self.tag]))
media_list = a_filter.apply_to_all(self.database, mlist)
media_list = a_filter.apply(self.database, mlist)

if not media_list:
return
Expand Down Expand Up @@ -643,7 +643,7 @@ def write_repositories(self):
filter_class = GenericFilterFactory("Repository")
a_filter = filter_class()
a_filter.add_rule(rules.repository.HasTag([self.tag]))
repo_list = a_filter.apply_to_all(self.database, rlist)
repo_list = a_filter.apply(self.database, rlist)

if not repo_list:
return
Expand Down Expand Up @@ -728,7 +728,7 @@ def write_sources(self):
filter_class = GenericFilterFactory("Source")
a_filter = filter_class()
a_filter.add_rule(rules.source.HasTag([self.tag]))
source_list = a_filter.apply_to_all(self.database, slist)
source_list = a_filter.apply(self.database, slist)

if not source_list:
return
Expand Down Expand Up @@ -810,7 +810,7 @@ def write_citations(self):
filter_class = GenericFilterFactory("Citation")
a_filter = filter_class()
a_filter.add_rule(rules.citation.HasTag([self.tag]))
citation_list = a_filter.apply_to_all(self.database, clist)
citation_list = a_filter.apply(self.database, clist)

if not citation_list:
return
Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/tool/eventcmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def on_apply_clicked(self, obj):
progress_bar = ProgressMeter(_("Comparing events"), "", parent=self.window)
progress_bar.set_pass(_("Selecting people"), 1)

plist = cfilter.apply_to_all(self.db, self.db.iter_person_handles())
plist = cfilter.apply(self.db, self.db.iter_person_handles())

progress_bar.step()
progress_bar.close()
Expand Down
4 changes: 2 additions & 2 deletions gramps/plugins/tool/removeunused.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ def collect_unused(self):
FilterClass = GenericFilterFactory("Note")
filter1 = FilterClass()
filter1.add_rule(rules.note.HasType(["To Do"]))
todo_list = filter1.apply_to_all(self.dbstate.db, all_notes)
todo_list = filter1.apply(self.dbstate.db, all_notes)
filter2 = FilterClass()
filter2.add_rule(rules.note.HasType(["Link"]))
link_list = filter2.apply_to_all(self.dbstate.db, all_notes)
link_list = filter2.apply(self.dbstate.db, all_notes)

for the_type, cursor_func, total_func in tables:
if not self.options.handler.options_dict[the_type]:
Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/tool/sortevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def sort_person_events(self, trans):
"""
Sort the personal events associated with the selected people.
"""
people_handles = self.filter.apply_to_all(
people_handles = self.filter.apply(
self.db, self.db.iter_person_handles(), user=self._user
)
self.progress.set_pass(
Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/view/geoevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def _createmap(self, obj):
progress.close()
elif self.generic_filter:
user = self.uistate.viewmanager.user
events_list = self.generic_filter.apply_to_all(dbstate.db, user=user)
events_list = self.generic_filter.apply(dbstate.db, user=user)
progress = ProgressMeter(
self.window_name, can_cancel=False, parent=self.uistate.window
)
Expand Down
Loading

0 comments on commit 69366af

Please sign in to comment.