Supertool missing citations in attributes

I’m looking for citations associated to person attributes but I can’t find them: attributes properties are only attributes name and value.

And this code gives me an error. attr returns the value of the attribute, so cit corresponds to each of the letters contained in attr, and not to a citation object:

for attr in person.attribute_list:
 print(attr)
 for cit in attr.citation_list:
  print(cit.gramps_id)
WfwV3 Status (Waiting/Running/Checking/Finished) [C]; Recherche (Running/Finished) [F]; Date Connue (X/Imprécise/Fourchette) [ ]; Lieu Connu (X) [ ]; Acte Recherché@AD/Réclamé@Mairie (X) [ ]; Acte Obtenu (X) [ ]; Acte saisi (X) [ ]
Traceback (most recent call last):
  File "C:\Users\1\AppData\Roaming\gramps\gramps51\plugins\SuperTool\SuperTool.py", line 830, in execute
    self.execute1(query)
  File "C:\Users\1\AppData\Roaming\gramps\gramps51\plugins\SuperTool\SuperTool.py", line 913, in execute1
    for values in gramps_engine.get_values(self.trans):
  File "C:\Users\1\AppData\Roaming\gramps\gramps51\plugins\SuperTool\SuperTool.py", line 481, in get_values
    for obj, env, values in self.generate_values(env):
  File "C:\Users\1\AppData\Roaming\gramps\gramps51\plugins\SuperTool\SuperTool.py", line 463, in generate_values
    raise e
  File "C:\Users\1\AppData\Roaming\gramps\gramps51\plugins\SuperTool\SuperTool.py", line 436, in generate_values
    "exec",
  File "C:\Users\1\AppData\Roaming\gramps\gramps51\plugins\SuperTool\supertool_engine.py", line 806, in execute_person
    return execute(dbstate, obj, code, PersonProxy, envvars, exectype)
  File "C:\Users\1\AppData\Roaming\gramps\gramps51\plugins\SuperTool\supertool_engine.py", line 791, in execute
    res = exec(code, env)
  File "statements", line 4, in <module>
AttributeError: 'str' object has no attribute 'gramps_id'

How to obtain citations in attributes ?

Well ‘cit’ in your code snippet is a handle to the citation object.
You need to get the citation object;

citation = db.get_citation_from_handle(cit)
print(citation.gramps_id)

note that db may not be the right var name, use whatever the appropriate var means the db in your case.

1 Like

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