Adding "Also Known As" name into a formatted string in gen/display/name.py

I’ve been hacking on the Gramps Python files in order to do some tweaks on the detailed descendant report. It has been more or less smooth sailing, but now I’m facing a tougher puzzle. I would like to insert _AKA names into the displayed names in the report, when they exist.

I know they are stored in the NICKNAME attribute (when the _AKA name consists of a single name) when imported (I import GEDCOM data coming from Webtrees).

The name displaying functionality is so highly optimised that I’m having trouble figuring out how to tackle it. My understanding so far is that I would need to achieve the following:

  1. Smuggle a person object into gramps/name.py at maintenance/gramps51 · gramps-project/gramps · GitHub so I can call its get_attribute_list()
  2. Add an %a for aka into the dictionary in _gen_raw_func() (line 600)
  3. Use the %a in Name.LNFN in gramps/name.py at maintenance/gramps51 · gramps-project/gramps · GitHub

What would be the best way to get the person object in that context, for starters?

Welcome

The Name Display editor already allows the NIckname in the name display.

I have my basic display as Given "Nickname" Surname, Suffix. When a Nickname exists Gramps surrounds the nickname with the quotes ("). The quotes do not display when there is no nickname. The same functionality applies to parentheses and commas.

Additionally, there is the Common option. Instead of the Given field the Nickname will display as the first option, Called as the second option (when they exist), then the first name of the Given name will display.

So unless I am misreading what your ultimate goal is, there is no need for a hack of the code.

Thank you, I had overlooked that. It doesn’t work at all with the _AKA field, because it is stored in the NICKNAME attribute in the case of single names, but that is not really a problem for us. I had arrived at using _AKA due to some silly premature optimisation train of thought. We can very well go back to NICK.

However, the GUI-based approach does not seem flexible enough for the exact thing that we want to achieve. It would require conditional logic. What we want is (with pseudocode):
if nickname:
firstnames = “%nick (%given)” % {‘nick’ : nickname, ‘given’ : givenname}
else:
firstnames = givenname

Then to use this conditionally-set variable in a formatted string:

Surname, firstnames

Now I would somehow need to have such a condition in the Name.LNFN in STANDARD_FORMATS. But how can I include a function in the formatted string while passing it the already-substituted %n and %f? I am running short of Python knowledge and imagination :frowning:

Ok, one more option after internal negotiations: we could use the form

Surname, All_first_names (Nickname)

There does not seem to be any option to display all first names, though, only the first of them.

I am not understanding why you need to edit name.py to get what you desire. The Name Display editor has all of the fields accounted for for you to build a display name.

Maybe it would help if you give a concrete example of your desired result. i.e. John Michael "JM" Clarke, Jr. This is what would display using my preference from above.

Clarke, John Michael (JM)

Then in the editor, create a custom display:

Surname, Given (Nickname)

Thanks, I don’t know what I was doing when I couldn’t make it display all the first names!

1 Like

Can you help create a test person that matches the Example? I’ve gotten partway but he does not yet display identically to the Display Name Editor prediction.

I tried multiple formats (CSV, GED, GED2, Gramps XML, JSON, Raw ) The JSON was the most compact for posting here as Text, was intelligible, conveyed all pertinent fields, and imported easily. (GED and CSV didn’t support the Family Nickname. GED2 had a permissions error. Raw was not intelligible. XML was not compact.)

I did choose to remove the "handle", "gramps_id" & "change" fields from the JSON to avoid overwriting & ID conflicts.

{"_class": "Person", "private": false, "tag_list": [], "citation_list": [], "note_list": [], "media_list": [], "attribute_list": [], "address_list": [], "urls": [], "lds_ord_list": [], "primary_name": {"_class": "Name", "private": false, "surname_list": [{"_class": "Surname", "surname": "Smith", "prefix": "von der", "primary": true, "origintype": {"_class": "NameOriginType", "string": ""}, "connector": "and"}, {"_class": "Surname", "surname": "Weston", "prefix": "", "primary": false, "origintype": {"_class": "NameOriginType", "string": ""}, "connector": ""}, {"_class": "Surname", "surname": "Wilson", "prefix": "", "primary": false, "origintype": {"_class": "NameOriginType", "string": "Patronymic"}, "connector": ""}], "citation_list": [], "note_list": [], "date": null, "first_name": "Edwin Jose", "suffix": "Sr.", "title": "Dr.", "type": {"_class": "NameType", "string": "Birth Name"}, "group_as": "", "sort_as": 0, "display_as": 0, "call": "Jose", "nick": "Ed", "famnick": "Underhills"}, "event_ref_list": [], "family_list": [], "parent_family_list": [], "alternate_names": [], "person_ref_list": [], "death_ref_index": -1, "birth_ref_index": -1, "gender": 1}

I created a test database with Mr Clarke and the display option. The Example in the Display Name Editor does show correctly for Surname, Given (Nickname). The surname is long and convoluted but this is because the example needs to account for all potential possibilities.

The example shows:

von der Smith and Weston Wilson, Edwin Jose (Ed)

I can send the xml file off-list if you really need it.

person

It seems that I was anticipating a bit more interactive feedback at the Display Name Editor level.

The expectation was that that the format selected when exiting the Display Name Editor would become the “Name format:” selection for the Display tab in Preferences.

The View already reflects changes of the Name format menu selection interactively… even before the Preferences dialog is closed. (Conversely, a person’s Preferred Name Editor dialog doesn’t refresh until it is closed & re-opened. So you cannot simultaneously see the extra fields the way where in the GUI editor and compare that to the display.)


Instead you have to re-select the Name format after exiting the Display Editor.

Origins for surnames hasn’t “clicked” for me yet. Only the Patronymic origin for the Wilson surname was specified in the Example text: I just guessed at origins for the Smith and Weston surnames.

Example: Dr. Edwin Jose von der Smith and Weston Wilson Sr (“Ed”) - Underhills
Edwin Jose: Given, von der: Prefix, Smith and Weston: Primary, and: [con], Wilson: Patronymic,
Dr.: Title, Sr: Suffix, Ed: Nickname, Underhills Familynick, Jose call.

(There seems to be a typo in the Example text. Smith and Weston cannot BOTH be Primary.)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.