PersonRelationshipFilter#987
Conversation
…ields IsSiblingofNamedSibling crashed with HandleError whenever applied to a person with no recorded parents, because get_family_from_handle(None) raises rather than returning None. RegExpPersonal/RegExpFamily also searched mismatched Name fields (title was listed twice in the personal list, and call name was searched by the family/surname rule instead), so personal search never matched a person's call name and surname search could false-positive on an unrelated title or call name. Adds unit tests covering both regressions plus the general relationship-matching rules, and brings the addon up to date with black/mypy. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…wiki page help_url pointed at Addon:AdvancedPersonFilter, a different addon name left over from this addon's origin, instead of Addon:PersonRelationshipFilter. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Don't need the pinning of Gtk and Gdk to 3.0 in the test. |
|
Running unittest failed python3 -m unittest PersonRelationshipFilter.tests.test_person_relationship_filter_rules During handling of the above exception, another exception occurred: Traceback (most recent call last): |
A new gramplet, Relationship Filter (previously called Flat Filter), that drops into the Person view's Gramplet bar as a sidebar-style filter. Unlike the built-in Person filter (which only matches on the active person's own attributes), this one searches by the names of relatives:
Each name field is split into given-name and surname boxes searched independently (substring or regex), and results combine into a single
GenericFilterapplied to the Person view.Motivation
The stock Person sidebar filter can't answer "find people whose mother is named X" or "find the children of someone named Y" — you have to know the target person's own name or ID. In a large tree, it's often the relative's name you remember, not the person you're actually looking for. This gramplet lets you search on that relationship directly instead of navigating the tree by hand.
History and bugs fixed here
This is a new addon for addons-source, based on earlier work by Paul Womack (BugBear, 2024). While bringing it up to date for Gramps 6.1, I found and fixed two correctness bugs in that original code:
IsSiblingofNamedSiblingcrashed withHandleErrorwhenever applied to a person with no recorded parents (any root ancestor, immigrant, etc.).Person.get_main_parents_family_handle()returnsNonewhen there's no parent family, but the code passed that straight intoget_family_from_handle(), which raises rather than returningNoneon aNonehandle. Fixed with a guard, matching the pattern used elsewhere in this file and in core (e.g.persondetails.py).RegExpPersonal/RegExpFamilysearched mismatchedNamefields. The personal (given-name) field list listedtitletwice instead of including the call name, so a personal-name search never matched a person's call name. The family/surname field list includedtitleandcallname — both personal-name fields — so a surname search could false-positive on an unrelated title or call name. Split the field lists to match the Given/Family grouping in the Name Editor.Also:
allbuiltin.black; added a type annotation somypyis clean.tests/test_person_relationship_filter_rules.py— builds a small family tree directly in an in-memory database and exercises every rule (RegExpPersonal/RegExpFamilyfield matching,HasNamedFather/Mother/Child/Spouse,IsSiblingofNamedSibling,HasName), including both regressions above.tests/__init__.pyis left empty, matching the convention used by the rest of the repo's per-addon test suites (onlyRepositoriesReportpins GTK/GDK at the package level; every other addon'stests/__init__.pyis empty and each test module self-guards, which this one does too).Test plan
python3 -m pytest PersonRelationshipFilter/tests/ -v— 19 passedHandleErrorfor the sibling crash,AssertionErrorfor the call-name mismatch) and pass again with the fixblack --check PersonRelationshipFilter/— cleanmypy --ignore-missing-imports PersonRelationshipFilter/PersonRelationshipFilter.py PersonRelationshipFilter/tests/— clean🤖 Generated with Claude Code