Supertool changing sources of citations

The script below tries to change the source of the selected citations to the source of the first citation selected. But, it doesn’t change the source. What am I doing wrong, please?

[Gramps SuperTool script file]
version=1
[title]
SuperTool-Citations
[category]
Citations
[initial_statements]
first = True
[statements]
if first:
	snew = source
first = False 
citation.source = snew
[filter]
[expressions]
source, citation,snew
[scope]
selected
[unwind_lists]
False
[commit_changes]
True
[summary_only]
False

Output:

ID	Value1	Value2	Value3
C05306 	Source[S01909] 	<gramps.gen.lib...	Source[S01909]
C12219 	Source[S00857] 	<gramps.gen.lib...	Source[S01909]

David Lynch
GRAMPS: AIO64-5.1.4-1
Python: 3.6.4 (default, Jan 23 2018, 13:17:37) …
BSDDB: 6.1.0 (6, 0, 30)
sqlite: 3.21.0 (2.6.0)
LANG: en_GB.UTF-8
OS: Windows
Supertool 1.1.7

You can’t directly change the citation’s reference to its source, you have to use a method to do it, something like that in statements:

if first:
	snew = source.handle
	first = False 
citation.set_reference_handle(snew)

I’ve tested it, that’s working.

1 Like

Thank you, as you say, it now works.

How could I have known the correct code without asking? Is it because Source is of type SourceProxy and so can’t be altered directly?

David Lynch

My references documents are principally these two:

You could also read posts tagged Isotammi on this Discourse

And, I’ve published this filters library, may be you could find some methods used in it interesting(?)

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