help with registering a filter

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

help with registering a filter

Doug-11
Can someone help me with a newbie problem?

I want to make a new filter in order to trace a matrilineal
line.

Some provisional code was suggested nearly 10 years ago
together with instructions for installing the new rule
(create the filter in Gramps/gen/filters/rules and restart
gramps).

Now, running 4.2.5, I have created and installed the new
filter, and run python3 setup.py build before re-starting
gramps. But after starting gramps I don't see the new filter
rule appearing.

What am I missing doing or doing wrong?

Doug


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

Re: help with registering a filter

prculley
You probably forgot to edit the gramps/gen/filters/rules/__init__.py file.

I also noticed that is might be possible to make a filter as a plugin.  There was some code that mentioned a 'filter' category.  However, there are no examples of this so I just went for the direct addition.

Paul Culley

On Thu, Feb 2, 2017 at 7:04 AM, Doug <[hidden email]> wrote:
Can someone help me with a newbie problem?

I want to make a new filter in order to trace a matrilineal
line.

Some provisional code was suggested nearly 10 years ago
together with instructions for installing the new rule
(create the filter in Gramps/gen/filters/rules and restart
gramps).

Now, running 4.2.5, I have created and installed the new
filter, and run python3 setup.py build before re-starting
gramps. But after starting gramps I don't see the new filter
rule appearing.

What am I missing doing or doing wrong?

Doug


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


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

Re: help with registering a filter

Peter Hewett-2

------------------------
From: Paul Culley <[hidden email]>
Subject: Re: [Gramps-devel] help with registering a filter

> I just did that; take a look at
> https://github.com/gramps-project/gramps/pull/346
> You probably forgot to edit the gramps/gen/filters/rules/__init__.py file.

Marvellous !
It works.

But I think that the file to edit is
 gramps/gen/filters/rules/person/__init__.py

I made a copy of the _isdescendantof.py to make _isdescendantfemaleof.py
based on Benny's advice
http://gramps.1791082.n4.nabble.com/Filter-Direct-Female-Descendants-td1811913.html#a1811916
But note there is a typo, should be a : after pers.FEMALE in the second
last line. And some other edits are required at the top of the code.

---------------------------
class IsDescendantFemaleOf(Rule):
    """Rule that checks for a person that is a descendant
    of a specified person"""

    labels      = [ _('ID:'), _('Inclusive:') ]
    name        = _('Descendant females of <person>')
    category    = _('Descendant filters')
    description = _('Matches all female descendants for the specified
person')

    def prepare(self, db):
        self.db = db
        self.map = set()
        try:
            first = False if int(self.list[1]) else True
        except IndexError:
            first = True
        try:
            root_person = db.get_person_from_gramps_id(self.list[0])
            self.init_list(root_person,first)
        except:
            pass

    def reset(self):
        self.map.clear()

    def apply(self, db, person):
        return person.handle in self.map

    def init_list(self, person, first):
        if not person:
            return
        if not first:
            self.map.add(person.handle)

        for fam_id in person.get_family_handle_list():
            fam = self.db.get_family_from_handle(fam_id)
            if fam:
                for child_ref in fam.get_child_ref_list():
                    pers = self.db.get_person_from_handle(child_ref.ref)
                    if pers.gender == pers.FEMALE:
                        self.init_list(pers, 0)

---------------



 


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

Re: help with registering a filter

Doug-11
In reply to this post by prculley
Thanks, Paul.

I've done that; now on running there is a bug

   File
"/home/dougb/Gramps/gramps/gen/filters/rules/person/__init__.py",
line 71, in <module>
     from ._isfemaledescendantof import IsFemaleDescendantOf
   File
"/home/dougb/Gramps/gramps/gen/filters/rules/person/_isfemaledescendantof.py",
line 80
     if pers.gender == FEMALE
                            ^
SyntaxError: invalid syntax

Can you put me right?


(the original bit of code had
  if pers.gender == pers.FEMALE
but that was a syntax error too)

Doug

On 02/02/17 16:23, Paul Culley wrote:

> I just did that; take a look at
> https://github.com/gramps-project/gramps/pull/346
> You probably forgot to edit the
> gramps/gen/filters/rules/__init__.py file.
>
> I also noticed that is might be possible to make a filter as
> a plugin.  There was some code that mentioned a 'filter'
> category.  However, there are no examples of this so I just
> went for the direct addition.
>
> Paul Culley
>
> On Thu, Feb 2, 2017 at 7:04 AM, Doug
> <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Can someone help me with a newbie problem?
>
>     I want to make a new filter in order to trace a matrilineal
>     line.
>
>     Some provisional code was suggested nearly 10 years ago
>     together with instructions for installing the new rule
>     (create the filter in Gramps/gen/filters/rules and restart
>     gramps).
>
>     Now, running 4.2.5, I have created and installed the new
>     filter, and run python3 setup.py build before re-starting
>     gramps. But after starting gramps I don't see the new filter
>     rule appearing.
>
>     What am I missing doing or doing wrong?
>
>     Doug
>
>
>     ------------------------------------------------------------------------------
>     Check out the vibrant tech community on one of the
>     world's most
>     engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>     _______________________________________________
>     Gramps-devel mailing list
>     [hidden email]
>     <mailto:[hidden email]>
>     https://lists.sourceforge.net/lists/listinfo/gramps-devel <https://lists.sourceforge.net/lists/listinfo/gramps-devel>
>
>


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

Re: help with registering a filter

Doug-11
In reply to this post by Peter Hewett-2
On 02/02/17 19:50, Peter Hewett wrote:

> ------------------------
> From: Paul Culley <[hidden email]>
> Subject: Re: [Gramps-devel] help with registering a filter
>
>> I just did that; take a look at
>> https://github.com/gramps-project/gramps/pull/346
>> You probably forgot to edit the gramps/gen/filters/rules/__init__.py file.
> Marvellous !
> It works.
>
> But I think that the file to edit is
>   gramps/gen/filters/rules/person/__init__.py
>
> I made a copy of the _isdescendantof.py to make _isdescendantfemaleof.py
> based on Benny's advice
> http://gramps.1791082.n4.nabble.com/Filter-Direct-Female-Descendants-td1811913.html#a1811916
> But note there is a typo, should be a : after pers.FEMALE in the second
> last line. And some other edits are required at the top of the code.
>
<snip>
I got most of that already, but missed the typo so, many thanks!

It does work very nicely as a female line filter.

Doug

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