[db.get_name_group_mapping(name.get_group_name()) for name in nameobjs]
I don’t know why group_as always returns an empty string instead of the expected group_as name. It seems you have to get it from a database table where surnames and group_as names are mapped.
I like grouped persons to be sorted by their firstname but somtimes I need them to be sorted by their lastname so this script works now (-1 designate the firstname sort order I’ve designed in preferences):
[Gramps SuperTool script file]
version=1
[title]
Individus-Sort_as of grouped persons
[category]
People
[initial_statements]
sort_by_fn = True # By firstname -> True; By lastname -> False
if sort_by_fn:
sort_order = -1
else:
sort_order = 0
[statements]
if "<<" in db.get_name_group_mapping(nameobjs[0].get_group_name()):
for n in nameobjs:
n.set_sort_as(sort_order)
[filter]
[expressions]
[scope]
selected
[unwind_lists]
False
[commit_changes]
True
[summary_only]
False
Have you used the Isotammi add-ons: Name Editor tool… and Name Merge tool… ?
Even when not using them for their intended purpose (like merging all the uppercase “JOHN” instances into camelcase “John”), you can use them as quantified worklists of all the oddities that you want to manually harmonize.
And since they count the number of instances, you can decide which oddities are worth writing a SuperTool script.
There are two group_as functions, the first is specific to a particular name in the name.group_as object. This is set when a name is given a specific override, not as a part of the larger group, when set with the “Group this name only” in the “Group all people with the same name” dialog box that turns up when you set the Group as override.
The second group_as function appears when answering with “Group all” to the dialog, the db.get_name_group_mapping values are set since they apply to all the matching names.
The types of Harmonization I’m talking about are definite data entry errors.
Like a “, Jr.” appended in the Given Name rather than the suffix field. Or worse, the floating “I” that has to be inspected one-by-one to see if it is the initial “I.” (appropriate for the Given Name) or eponym indicator (that should be a suffix)
I found a lot of nicknames in the example.gramps file that were incorrectly parenthesized or quoted in the Given Name too.