A named place and its sub-places — a Gramps filter rule V1.0.0

A custom Places filter rule for Gramps that matches the named place itself plus every place enclosed by it — all the way down the place hierarchy.

Why?

Gramps already ships a place rule, "IsEnclosedBy", but it selects by Gramps ID. IDs change on backend upgrade, backup import and version switches, which makes ID-based filters brittle. This rule does the same job by place name, which is self-documenting and stable. If several places share a name, all of them are used as targets.

It is the Places-view companion to the person rule "People with an event in a place or its sub-places": same name-based, transitive enclosure, but here the result is the matching places themselves rather than people.

Requirements

Installation

  1. Close Gramps.

  2. Extract the downloaded ZIP archive.

  3. Copy or extract the project folder into your Gramps user plugin folder. Keep the complete folder structure unchanged, including any locale folder included with the project.

    The user plugin folder is normally located here:

    Replace <version> with the Gramps version folder used on your system.

  4. Start Gramps again.

  5. Check that the installed filter, rule, gramplet or tool is available where described in the project documentation.

If the project does not appear or fails to load, check Help → Plugin Manager for an error message.

Removing the test version

  1. Close Gramps.
  2. Delete the project folder that you added to the Gramps user plugin folder.
  3. Start Gramps again.

Because the project was installed only in the user plugin folder, removing that folder removes the test installation without changing the original Gramps program files.

Usage

  1. In the Places view, open the place filter editor (the filter gramplet / Edit → Place Filter Editor).
  2. Add a new filter, click Add to add a rule, and under General filters choose "Places within a named place or its sub-places".
  3. Fill in the fields:
  4. Click OK.

The result is every place that is, or lies within, the named place — handy for scoping a jurisdiction, then reusing the filter in reports or exports.

Exact vs. regular-expression name matching

By default the place name is matched exactly (ignoring upper/lower case). Ticking Use regular expressions switches the place-name field to a regular expression, searched anywhere in the name/title:

This differs from the usual Gramps behaviour. Gramps' standard rules that offer a "Use regular expressions" checkbox treat the unticked field as a substring (contains) match. This rule instead treats the unticked field as an exact, whole-name (case-insensitive) match. In both, ticked = a regular expression — so the only difference from the usual behaviour is the unticked default: exact here, contains elsewhere.

Note: in regex mode the pattern is also tested against each place's full title, so an unanchored pattern can match via the title too; anchor with ^…$ for the name field only.

How matching works

The rule resolves the typed name to every place whose name/title matches, then a place is selected if it is one of those targets or lies within one (tested with Gramps' own located_in, so the "enclosed by" semantics are identical to the built-in rule). Place hierarchies are shallow, so this is cheap even on large trees.

License

GNU General Public License, version 2 or later — same as Gramps.

Translations (i18n)

Ships with a Danish translation. Layout:

<addon folder>/ *.py *.gpr.py po/template.pot po/da.po locale/da/LC_MESSAGES/addon.mo

Gramps loads locale/<lang>/LC_MESSAGES/addon.mo automatically for that language. To add a language, copy po/template.pot to po/<lang>.po, translate each msgstr, compile to locale/<lang>/LC_MESSAGES/addon.mo (msgfmt po/<lang>.po -o locale/<lang>/LC_MESSAGES/addon.mo), and restart.

Only strings unique to this addon are translated here. Standard Gramps terms — the General filters category name and the Use regular expressions checkbox — come from Gramps' own translations automatically.