How to display non private attributes and make them private with Supertool

(Gramps 5.1.5 - Linux Debian 11)

Hello,
I have used a Supertool script to list attributes of people, events, sources and citations.
In Expressions to display I have Gramps_id, title, attribute and it works well.

How to display only non private attributes and how to make them private?
Thank you pour your answer!

Since the ‘Private’ lock (and ‘probably living’ filter) is normally only considered during export and report generation, perhaps you ought to clarify what your goal is in setting Privacy on all the secondary objects?

Generally, when locking the Privacy on a Person, the secondary objects are going to be omitted from the export/report when the Person is omitted.

Setting additional locks might be work that you don’t need to do.

(Note that I generally mark all eMail addresses as Private as well as my Research Notes that are logs of discussion threads. Those secondary objects are clearly modern with living people and it is difficult to predict where people will feel confidentiality was implied.)

The above caveat aside, the following thread talks about the set privacy tool, filtering with privacy, and setting via the SuperTool:

1 Like

Thank you emyoulation,
I use attributes for personal informations and researchs in people, events, sources, citations, and I don’t want them to be exported. For this, I want to make them private.

In Supertool is it possible to display the “private statut” of these attributs in people, events, sources and citations? And to make them private?

Yes. The script can be Execute without the “Commit changes” option selected to show the current status and what the status would be after ‘committing’. Here, I have used the script in Places category with a few places selected from the Example.gramps sample tree. (Added a "longname, type, " to the Expressions to Display to make the results more human-readable):

Thank you emyoulation,
It seems we don’t speak about the same thing.

For example, with “Attributs_des_sources.script”, I can see my sources with their attributes (Value 3 in Sources-1.png) :

[Gramps SuperTool script file]
version=1

[title]
Attributs_des_sources

[category]
Sources

[initial_statements]
# Valeurs modifiables - début
# Valeurs possibles:  'texte' ou '*'

attribut_type    = '*'
attribut_valeur = '*'

# Valeurs modifiables - fin

gid = []

[statements]
for attribute in attributes:
 if attribut_type == '*' and attribut_valeur == '*':
  gid.append(gramps_id)
  break
 
 if attribut_type == '*':
  if attribute[1] == attribut_valeur:
   gid.append(gramps_id)
   break
 elif attribut_valeur == '*':
  if attribute[0] == attribut_type:
   gid.append(gramps_id)
   break
 else:
  if attribute == (attribut_type, attribut_valeur):
   gid.append(gramps_id)
   break

[filter]
gramps_id in gid

[expressions]
gramps_id, title, attributes

[scope]
all

[unwind_lists]
False

[commit_changes]
False

[summary_only]
False

How can i do for make private these attributes Value 3, like in Sources-2.png but with Supertool?

Thank you for your answer!

Just making certain that your goal is to set the Privacy so these items can be excluded in a subsequent Export or for Reports, right? Since there is no global Privacy redaction for data in the GUI. (The filter gramplets can hide stuff… but it is sloooowwwww and would have to be filtered at each separate view.)

Given the above assumption, your script above is not doing a .set_privacy(True) for any of the attribute objects being listed. So even if the ‘commit changes’ was set, it doesn’t make the change. (Since I don’t like changing values in the blind, I always .get_privacy() to read the original privacy flag setting, list that and then the updated value. It is reassuring to do a test run without committing changes first.)

Oh, I recognize my script there. Just change all stuff in the for loop (or create a new empty script) and replace it by something like that:

for attribute in attributes:
    if not attribute.get_privacy():
        attribute.set_privacy(True)

Check the Commit changes checkbox to register your changes.


P.S. How do you store all these Zotero attributes into Gramps?

1 Like

Unfortunately Patrice’s code does not work because ‘attributes’ is just a list of (name,value) tuples and does not give access to the underlying Gramps Attribute objects. Maybe that was a bad design decision but that is how it works.

Instead you could use the lower-level Gramps method ‘get_attribute_list’, something like

    for attr in obj.get_attribute_list():
        if not attr.get_privacy():
            attr.set_privacy(True)
3 Likes

It works with the script :

[Gramps SuperTool script file]
version=1

[title]
Attributs_des_sources - 3 --> OK

[category]
Sources

[initial_statements]
# 
# Mise en privé des attributs de la source
#

[statements]
for attr in obj.get_attribute_list():
     #
     # voir test si pas d'attribut 
     #
     myinitprivacy = attr.get_privacy()     
     if not attr.get_privacy():          
          attr.set_privacy(True)
     myendprivacy = attr.get_privacy()

[filter]
gramps_id

[expressions]
gramps_id, title, attributes, myinitprivacy, myendprivacy

[scope]
selected

[unwind_lists]
True

[commit_changes]
False

[summary_only]
False

Thank you emyoulation, PLegoux and kku for your answers!

P.S. For PLegoux, see : https://www.geneanet.org/forum/viewtopic.php?p=2194913#p2194913

1 Like

You should add some comments that describe the purpose of the script and a URL of this discussion.

A library of saved scripts gets unruly very quickly. So you need strict organization workflows. (It is similar with the more complex custom filters.)

Also, add a bookmark in the GTK File Chooser dialog so you can find your saved scripts easily. (I bookmarked the Gramps User Directory and have a folder for my scripts there.)