Google Translation of Geneanet Jul 2021 thread Re: I love the SuperTool!) by @PLegoux
Hello,
I am going to share here the few creations of fairly generic SuperTool (ST) filters which could be useful to others, and which have no equivalent in classic Gramps filter.
I provide you with the ST script because it is much more practical than transmitting the Gramps filter XML but once loaded in ST it must be saved as a filter (‘Save as filter’) in the citation filters.
This therefore filters the quotes based on their attributes. In this case, it is looking for an attribute “Consulted on” with the value ‘To be defined’, type and value which can be changed to whatever you want (‘*’ to search for everything)
It also works if it is saved without modification in source filters which also do not have a way to filter sources based on their attributes.
[title]
90. Attribute[{'Consulted on': 'To be defined'}] - 105p
[category]
Sources
[initial_statements]
# Editable values - beginning
# Possible values: 'text' or '*'
attribute_type = 'Consulted on'
attribute_value = 'To be defined'
# Editable values - end
gid = []
[statements]
for attribute in attributes:
if attribute_type == '*' and attribute_value == '*':
gid.append(gramps_id)
break
if attribut_type == '*':
if attribute[1] == attribute_value:
gid.append(gramps_id)
break
elif attribute_value == '*':
if attribute[0] == attribute_type:
gid.append(gramps_id)
break
else:
if attribute == (attribute_type, attribute_value):
gid.append(gramps_id)
break
[filter]
gramps_id in gid
[scope]
all
Note that at home I saved it as below, with two includes, one for initialization and another for the statements, which will allow me to modify the code of the Gramps filters already created on this basis without having to go through it again. in each of them. It does exactly the same thing (for now - includes will probably evolve to allow searching for regexes).
G:\5. Design\Gramps\Isotammi\C90.105p.script:
[title]
90. Attribute[{'Consulted on': 'To be defined'}] - 105p
[category]
Sources
[initial_statements]
# Editable values - begin
# Possible values : 'text' or '*'
attribute_type = 'Consulted on'
attribute_value = 'To be defined'
# Editable values - end
@include SC_attr_init.py
[statements]
@include SC_attr_statement.py
[filter]
gramps_id in gid
[expressions]
[scope]
all
C:\Users\Patrice\supertool\SC_attr_init.py:
# Include SC_attr_init
gid = []
C:\Users\Patrice\supertool\SC_attr_statement.py:
# Include SC_attr_statement
for attribute in attributes:
if attribute_type == '*' and attribute_value == '*':
gid.append(gramps_id)
break
if attribute_type == '*':
if attribute[1] == attribute_value:
gid.append(gramps_id)
break
elif attribute_value == '*':
if attribute[0] == attribute_type:
gid.append(gramps_id)
break
else:
if attribute == (attribute_type, attribute_value):
gid.append(gramps_id)
break
You can use the version you want, the first in a single script or the second with a script and 2 includes. They do the same thing. However, I recommend the second one even if it is a little more complicated to install.
You can use either version without fear of changes to your data, it just filters like any classic Gramps filter.