The solution allowed me to list all people with e.g. a Birth event has a note containing the string “familysearch”.
Now I’d like to go even further and find e.g. all people with a “Birth” event whose citation contains a particular text (or e.g. whose citation contains 1 or more media references etc.).
I can build a “Citation Filter” (with the Citation Filter Editor) which selects just the citations I want.
e.g. All citations with Notes containing “XXXXX”, or e.g. all citations with notes contains “nli.ie” and where the citation has no media objects (count media = 0), etc. …
When I then go to then “Event Filter Editor” and assemble rules for a new filter there, I can’t seem to find any Citation/Source (or any other?) filter which allows me to use the “Citation Filter” I created above. i.e. something like the “Events with source matching the [source filter]” (which is available) but instead: “Events with citations matching the [citation filter]”.
Is there a way to do this using these tools or are there some other tools which make it possible?
(I am probably missing something obvious)
All the Isotammi addons are Advanced audience. So youll need to change the Filter in the Addon Manager to see them. (Or use the middle tab to install multiple addon in a single operation. It does not have an Audience filter.)
Yes, you can build complex filters in Python with SuperTool shell. And save them for use in the Filter Gramplet instead of being limited to running them in SuperTool.
There are also SQL query shell addons. And 2 other addon shells with customized Query Languages. (one contributed by @dsblank and another by @DavidMStraub.)
With Supertool you could create an event filter implementing “Events with citations matching the [citation filter]”. It could look like this:
[Gramps SuperTool script file]
version=1
[title]
events-with-citations-matching-a-citation-filter
[description]
[category]
Events
[initial_statements]
citation_filter_name = "my-filter"
f = filter(citation_filter_name, namespace="Citation")
def match(p):
for c in p.citations:
if f(c.obj):
return True
return False
[statements]
[filter]
match(self)
[expressions]
type,date
[scope]
selected
[unwind_lists]
False
[commit_changes]
False
[summary_only]
False
Save this as e.g. “events-with-citations-matching-a-citation-filter.script”. Change the filter name in the script as needed. Open Gramps and go to the Events view. Invoke Supertool, open the script file in Supertool and select “File > Save as filter”. Then you will have a new custom filter that can be used as any other custom filter.
You can also test the above script by executing it within Supertool.
You could also do everything in SuperTool. For example, this script will find all people with their birth event having at least one citation with at least one note containing the text “familysearch”. It should be used in the People view:
[Gramps SuperTool script file]
version=1
[title]
birth-citation-match
[description]
[category]
People
[initial_statements]
searchtext = "familysearch"
def match(p):
for c in p.birth.citations:
for n in c.notes:
if searchtext in n.text.lower():
return True
return False
[statements]
[filter]
match(self)
[expressions]
name
[scope]
all
[unwind_lists]
False
[commit_changes]
False
[summary_only]
False
You can paste it into a Note and then set it to the SuperTool Script custom type. (I collect these scripts by attaching them to a private ficticious person with the surname Gramps) One of the menus had an option to load scripts from Notes. By default, the list is filtered by the currently active category, keyed to the [category] in the saved script.
As a kludge coder, I need to see more than a few lines code that are visible in the SuperTool GUI. So tweaking in the Note Editor is more helpful.
Another couple hints:
including a [description] containing a URL (to the discussion where the script was discussed) is a good policy
save your scripts with [commit_changes] set to False as a “safety”. This allow you to do test runs on a temporary proxy dataset without risking your Tree. You can switch Truewhen everything tests well.