File tree Expand file tree Collapse file tree 10 files changed +79
-2
lines changed Expand file tree Collapse file tree 10 files changed +79
-2
lines changed Original file line number Diff line number Diff line change 41
41
# Typing modules
42
42
#
43
43
# -------------------------------------------------------------------------
44
- from ...lib .primaryobj import PrimaryObject
44
+ from typing import Set
45
+ from ...types import PrimaryObjectHandle , PrimaryObject
45
46
from ...db import Database
46
47
47
48
@@ -57,10 +58,14 @@ class HasGrampsId(Rule):
57
58
name = "Object with <Id>"
58
59
description = "Matches objects with a specified Gramps ID"
59
60
category = _ ("General filters" )
61
+ selected_handles : Set [PrimaryObjectHandle ] = set ([])
60
62
61
63
def apply_to_one (self , db : Database , obj : PrimaryObject ) -> bool :
62
64
"""
63
65
apply the rule on the obj.
64
66
return true if the rule passes, false otherwise.
65
67
"""
66
- return obj .gramps_id == self .list [0 ]
68
+ return obj .handle in self .selected_handles
69
+
70
+ def reset (self ):
71
+ self .selected_handles .clear ()
Original file line number Diff line number Diff line change 25
25
#
26
26
# -------------------------------------------------------------------------
27
27
from ....const import GRAMPS_LOCALE as glocale
28
+ from ....db import Database
28
29
29
30
_ = glocale .translation .gettext
30
31
@@ -46,3 +47,10 @@ class HasIdOf(HasGrampsId):
46
47
47
48
name = _ ("Citation with <Id>" )
48
49
description = _ ("Matches a citation with a specified Gramps ID" )
50
+
51
+ def prepare (self , db : Database , user ):
52
+ data = db ._get_raw_citation_from_id_data (self .list [0 ])
53
+ if data :
54
+ self .selected_handles = set ([data .handle ])
55
+ else :
56
+ self .selected_handles = set ([])
Original file line number Diff line number Diff line change 24
24
#
25
25
# -------------------------------------------------------------------------
26
26
from ....const import GRAMPS_LOCALE as glocale
27
+ from ....db import Database
27
28
28
29
_ = glocale .translation .gettext
29
30
@@ -45,3 +46,10 @@ class HasIdOf(HasGrampsId):
45
46
46
47
name = _ ("Event with <Id>" )
47
48
description = _ ("Matches an event with a specified Gramps ID" )
49
+
50
+ def prepare (self , db : Database , user ):
51
+ data = db ._get_raw_event_from_id_data (self .list [0 ])
52
+ if data :
53
+ self .selected_handles = set ([data .handle ])
54
+ else :
55
+ self .selected_handles = set ([])
Original file line number Diff line number Diff line change 24
24
#
25
25
# -------------------------------------------------------------------------
26
26
from ....const import GRAMPS_LOCALE as glocale
27
+ from ....db import Database
27
28
28
29
_ = glocale .translation .gettext
29
30
@@ -45,3 +46,10 @@ class HasIdOf(HasGrampsId):
45
46
46
47
name = _ ("Family with <Id>" )
47
48
description = _ ("Matches a family with a specified Gramps ID" )
49
+
50
+ def prepare (self , db : Database , user ):
51
+ data = db ._get_raw_family_from_id_data (self .list [0 ])
52
+ if data :
53
+ self .selected_handles = set ([data .handle ])
54
+ else :
55
+ self .selected_handles = set ([])
Original file line number Diff line number Diff line change 24
24
#
25
25
# -------------------------------------------------------------------------
26
26
from ....const import GRAMPS_LOCALE as glocale
27
+ from ....db import Database
27
28
28
29
_ = glocale .translation .gettext
29
30
@@ -45,3 +46,10 @@ class HasIdOf(HasGrampsId):
45
46
46
47
name = _ ("Media object with <Id>" )
47
48
description = _ ("Matches a media object with a specified Gramps ID" )
49
+
50
+ def prepare (self , db : Database , user ):
51
+ data = db ._get_raw_media_from_id_data (self .list [0 ])
52
+ if data :
53
+ self .selected_handles = set ([data .handle ])
54
+ else :
55
+ self .selected_handles = set ([])
Original file line number Diff line number Diff line change 24
24
#
25
25
# -------------------------------------------------------------------------
26
26
from ....const import GRAMPS_LOCALE as glocale
27
+ from ....db import Database
27
28
28
29
_ = glocale .translation .gettext
29
30
@@ -45,3 +46,10 @@ class HasIdOf(HasGrampsId):
45
46
46
47
name = _ ("Note with <Id>" )
47
48
description = _ ("Matches a note with a specified Gramps ID" )
49
+
50
+ def prepare (self , db : Database , user ):
51
+ data = db ._get_raw_note_from_id_data (self .list [0 ])
52
+ if data :
53
+ self .selected_handles = set ([data .handle ])
54
+ else :
55
+ self .selected_handles = set ([])
Original file line number Diff line number Diff line change 24
24
#
25
25
# -------------------------------------------------------------------------
26
26
from ....const import GRAMPS_LOCALE as glocale
27
+ from ....db import Database
27
28
28
29
_ = glocale .translation .gettext
29
30
@@ -45,3 +46,10 @@ class HasIdOf(HasGrampsId):
45
46
46
47
name = _ ("Person with <Id>" )
47
48
description = _ ("Matches person with a specified Gramps ID" )
49
+
50
+ def prepare (self , db : Database , user ):
51
+ data = db ._get_raw_person_from_id_data (self .list [0 ])
52
+ if data :
53
+ self .selected_handles = set ([data .handle ])
54
+ else :
55
+ self .selected_handles = set ([])
Original file line number Diff line number Diff line change 24
24
#
25
25
# -------------------------------------------------------------------------
26
26
from ....const import GRAMPS_LOCALE as glocale
27
+ from ....db import Database
27
28
28
29
_ = glocale .translation .gettext
29
30
@@ -45,3 +46,10 @@ class HasIdOf(HasGrampsId):
45
46
46
47
name = _ ("Place with <Id>" )
47
48
description = _ ("Matches a place with a specified Gramps ID" )
49
+
50
+ def prepare (self , db : Database , user ):
51
+ data = db ._get_raw_place_from_id_data (self .list [0 ])
52
+ if data :
53
+ self .selected_handles = set ([data .handle ])
54
+ else :
55
+ self .selected_handles = set ([])
Original file line number Diff line number Diff line change 24
24
#
25
25
# -------------------------------------------------------------------------
26
26
from ....const import GRAMPS_LOCALE as glocale
27
+ from ....db import Database
27
28
28
29
_ = glocale .translation .gettext
29
30
@@ -45,3 +46,10 @@ class HasIdOf(HasGrampsId):
45
46
46
47
name = _ ("Repository with <Id>" )
47
48
description = _ ("Matches a repository with a specified Gramps ID" )
49
+
50
+ def prepare (self , db : Database , user ):
51
+ data = db ._get_raw_repository_from_id_data (self .list [0 ])
52
+ if data :
53
+ self .selected_handles = set ([data .handle ])
54
+ else :
55
+ self .selected_handles = set ([])
Original file line number Diff line number Diff line change 24
24
#
25
25
# -------------------------------------------------------------------------
26
26
from ....const import GRAMPS_LOCALE as glocale
27
+ from ....db import Database
27
28
28
29
_ = glocale .translation .gettext
29
30
@@ -45,3 +46,10 @@ class HasIdOf(HasGrampsId):
45
46
46
47
name = _ ("Source with <Id>" )
47
48
description = _ ("Matches a source with a specified Gramps ID" )
49
+
50
+ def prepare (self , db : Database , user ):
51
+ data = db ._get_raw_source_from_id_data (self .list [0 ])
52
+ if data :
53
+ self .selected_handles = set ([data .handle ])
54
+ else :
55
+ self .selected_handles = set ([])
You can’t perform that action at this time.
0 commit comments