I’m trying to develop a text report addon that would generate a table where the columns are persons selected using something like the “People of Interest” menu from “Family Lines Graph” graph. The rows would years, but with multiple lines per year similar to the 'Family Sheet" text report. I’m calling it “Timeline Contingency Report”. So far I have managed to:
On lines 16-17 of your Gramps Plugin Registration file, it starts to double register the Report add-on and in the wrong (Tool) class. (You definitely want to run Gramps from the Console while debugging. That’s where the Registration error appeared that helped find this problem.)
Remove lines 16 & 17 and the Report registers successfully with no errors reported to the console. And now Timeline Contingency… appears in the Reports → Text Reports menu.
However, attempting to load the report echos the following messages to the Console:
Traceback (most recent call last):
File "C:\Program Files\GrampsAIO64-5.1.5\gramps\gen\plug\_manager.py", line 252, in load_plugin
_module = self.import_plugin(pdata)
File "C:\Program Files\GrampsAIO64-5.1.5\gramps\gen\plug\_manager.py", line 285, in import_plugin
module = __import__(pdata.mod_name)
File "C:\Users\DistrictSupport\AppData\Roaming\gramps\gramps51\plugins\TimeContingency\timelinecontingency.py", line 67
SyntaxError: invalid syntax
Thanks for finding those errors. I deleted lines 16 and 17. When I tested the change, two errors occurred:
First there seemed to be some sort of conflict loading my family trees. I checked the version in the gramps help and it came up with 5.2.
Second, when I changed ‘gramps_target_version’ in the registration file to 5.2. The family tree loaded, but Timeline Contingency did not appear in the Reports → Test Reports menu.
I think I may have forked the wrong code. As I mentioned I’m finding the wiki a bit non-specific.
The code in timelinecontingency.py is mainly place holder, and I would not expect it to run correctly if at all. My first priority is getting the thin to show up on the menu.
@JohnS Are testing your new addon against a built (or installed) copy of Gramps 5.1.x? It sounds like you may be testing your addon against the latest code from gramps master branch which is versioned at 5.2 (next release). Unless your work requires Gramps 5.2, it’s probably better to target 5.1.
Typically when I work on changes (usually bug fixes) I create a new branch from the maintenance/gramps51 branch of the source, and I test changes against the installed version of Gramps 5.1.x on my system. Of course if you have a full-fledged gramps development environment, you can build and run maintenance/gramps51 branch too.
I am trying to target version 5.1. But I was confused by suggestions in one of the development wiki pages. Executing gramps/Gramps.py’ starts v5.2.0, whereas executing gramps/scripts/gramps’ starts v5.1.2. Starting in Gnome terminal desktop emulator.
Linux kihikihi 5.4.0-128-generic #144-Ubuntu SMP Tue Sep 20 11:00:04 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Strange. The menu item appeared after creating a TimeContingency folder in my Gramps User Directory plugs folder (in Windows, that’s %appdata%/gramps/gramps51/plugins/TimeContingency) with your 2 files and changing the Gramps Plugin Registration file to the following:
id = "TimelineContingency",
name = _("Timeline Contingency"),
description = _("Creates a timeline table for selected persons."),
version = "1.0.1",
gramps_target_version = "5.1",
status = STABLE,
fname = "timelinecontingency.py",
authors = ["John R. Sibert"],
authors_email = ["firstname.lastname@example.org"],
category = CATEGORY_TEXT,
reportclass = "TimelineContingency",
optionclass = "TimelineContingency",
report_modes = [REPORT_MODE_CLI, REPORT_MODE_GUI, REPORT_MODE_BKI],
require_active = False,
Although it appeared on the Tools → Text Reports submenu, here is its listing in the Report Selection dialog (launched from the button on the Toolbar.)
Make certain that the Gramps version number in the path to the plugins folder matches the version of Gramps that you are running.
You indicated you had a 5.2 prototype installed as well as the 5.1 general release version. The .gpr.py is a 5.1 version. So the addon has to be installed in the gramps/gramps51/plugins/ subfolder and you have to launch that 5.1 version of Gramps.
It appears that I neglected to build gramps from source after I downloaded to my local repo. I’m not able to specify version 5.1. The build script insists on building 5.2. I have the feeling that I should start again from zero. I’m building as a unique user to protect my standard installation.
Hah! Small success indeed.
Pasting the TimelineContingency report folder in my local gramps51 plugins folder.
However, pasting it into my gramps52 editing the gpr file to version 5.2 (with vim) caused the adddon to appear in the menu. It even produced the expected output and error.
So a bit of success. But I think I need to be targeting gramps 5.1. No?
To test your addon as you develop it is suggested that you copy your NewProjectName plugin into your Gramps user plugin directory from your addon development directory, prior to testing. Or just edit in the Gramps user plugin directory until it is ready to publish, then copy back to your addon development directory.
Your installed Gramps will search this folder (and subdirectories) for .gpr.py files, and add them to the plugin list.
The result is positive. My currently installed gramps software recognizes my new addon and executes it as expected.
However, the wiki advice runs contrary to my usual workflow with with github hosted code, which includes frequent commits to a forked repo. Copying new code back and forth between two directories is a bother and an invitation to error. So my instinct was to simply use a soft link eg ln -s ~/GrampsTesting/addons-source/TimelineContingency/ ~/.gramps/gramps51/plugins, but when I tried the soft link, my gramps did not recognize the new addon.
So, two questions: (1) is it necessary to build gramps from source if one is simply writing a new addon; (2) is soft link problem linux quirk that I’n not understanding or a gramps feature?
This is a bit late as you’ve progressed since and it would be better to stay with your setup if you’ve got it working.
However, you can try this when you’re ready to experiment again, or experiment in a separate source tree. Once you clone gramps and addons-source git repos, to work in gramps51 you can switch both repos to the origin/maintenance/gramps51 branch.
When you start new work, you can create a branch starting at the commit for origin/maintenance/gramps51 so you can develop code compatible with 5.1.
Git has a feature called ‘worktree’ which is also very helpful in creating a separate worktrees for working with different versions, but that’s a topic for another day.
Thanks, but for nowI’m working around the symlink “problem” by simply copying files as needed using a simple bash script.
Nevertheless, I’m still missing something: The Report appears in the menu as expected, but does not seem to execute correctly. It seems to simply fall through code and exit with the message
AttributeError: type object ‘TimelineContingency’ has no attribute ‘load_previous_values’
running from my standard installation of gramps 5.1