how to determine the 'number' of a filter?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to determine the 'number' of a filter?

brian fitzgerald
[Ubuntu 16.04LTS + Gramps4.2.5]

While revisiting a bash script written some time ago to run the Relationship Graph I noticed that the filter number had changed in the mean time. I thought it may be in one of the XML files in .gramp folder but no.
It seem to only capture the most recent output from the GUI for each report type and assigns the named filter a seemingly arbitrary number.

Is there an easier way to enumerate the currently existing named filters so the number can  used in a script?
Does anyone have a gramplet to accomplish this?

Thanks
Brian

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users
https://gramps-project.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to determine the 'number' of a filter?

Gil da Costa
On 15/03/2017 04:36, brian fitzgerald wrote:
[Ubuntu 16.04LTS + Gramps4.2.5]

While revisiting a bash script written some time ago to run the Relationship Graph I noticed that the filter number had changed in the mean time. I thought it may be in one of the XML files in .gramp folder but no.
It seem to only capture the most recent output from the GUI for each report type and assigns the named filter a seemingly arbitrary number.

Is there an easier way to enumerate the currently existing named filters so the number can  used in a script?
Does anyone have a gramplet to accomplish this?

In a bash script, I get the filter number with the following command line (works with Gramps 4.2.5):

gramps --quiet --action=report --options='name=navwebpage,show=filter' --open="$NomArbreGramps" | sed --silent --regexp-extended "s/^ *([0-9]+)\t${nom_filtre}$/\1/p"

where NomArbreGramps is the family tree name, and nom_filtre is the filter name.


Hope this helps,

G.Da Costa


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users
https://gramps-project.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to determine the 'number' of a filter?

Gil da Costa
On 16/03/2017 01:31, brian wrote:

I edited your script to be the following and called it 'get_filternumber.sh':

gramps --quiet --action=report --options='name=navwebpage,show=filter' --open="Family Tree 2" | sed --silent --regexp-extended "s/^ *([0-9]+)\t${filter_1}$/\1/p"

and I got the following;

brian@freya:~/app$ sh get_filternumber.sh
/usr/lib/python3/dist-packages/gramps/gui/utils.py:45: PyGIWarning: PangoCairo was imported without specifying a version first. Use gi.require_version('PangoCairo', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import PangoCairo
Opened successfully!
Performing action: report.
Using options string: name=navwebpage,show=filter
Cleaning up.
Exiting.
brian@freya:~/app$

All that stuff is directed to stderr.

The useful data is directed to standard output: it should have been mixed with the standard error stream.

I suggest that you first ignore the "sed" part of the command, and execute:

gramps --quiet --action=report --options='name=navwebpage,show=filter' --open="Family Tree 2" >some_file

You will know exactly the structure of the records using the command:

hexdump -C some_file


I think that the problem is due to the fact that I was not very clear in my previous mail: in the sed pattern "/^ *([0-9]+)\t${nom_filtre}$/", "nom_filtre" is not the name of the filter, but is the name of a shell variable which contains the filter name. So, try to replace "${filter_1}" with "filter_1".

I now remember having observed that the field separators (tabulation or space) may change according to the context (don't remember the details). The sed pattern is perhaps tailored for my case, and in this case, it must be adjusted.

Furthermore, I have used a non standard feature of "sed": "\t" as a synonymous for tabulation.

If it still does not work, please provide me the result of "hexdump".


G.Da Costa

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users
https://gramps-project.org
Loading...