Skip to content

Commit

Permalink
Reformat with black
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Smeets authored and Nick-Hall committed Feb 8, 2024
1 parent 591e9cd commit a31e116
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
6 changes: 4 additions & 2 deletions gramps/gen/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,23 +671,25 @@ def get_event_person_referents(event_handle, db):
This function finds all primary objects that refer
to the given event handle in a given database.
"""
_primaries = ("Person", )
_primaries = ("Person",)

lists = get_referents(event_handle, db, _primaries)
return [x for xs in lists for x in xs]


def get_event_family_referents(event_handle, db):
"""
Find families that refer to the event object.
This function finds all primary objects that refer
to the given event handle in a given database.
"""
_primaries = ("Family", )
_primaries = ("Family",)

lists = get_referents(event_handle, db, _primaries)
return [x for xs in lists for x in xs]


def get_media_referents(media_handle, db):
"""
Find objects that refer the media object.
Expand Down
42 changes: 28 additions & 14 deletions gramps/plugins/webreport/basepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,9 @@ def event_header_row(self):
trow += Html("/tr", close=None)
return trow

def display_event_other_person_role(self, skip_event_ref, uplink, htmllist, refering_person):
def display_event_other_person_role(
self, skip_event_ref, uplink, htmllist, refering_person
):
"""
Display the role of the refering person to this event.
Skip the role for the specified skip_event_ref because it is already
Expand All @@ -861,7 +863,10 @@ def display_event_other_person_role(self, skip_event_ref, uplink, htmllist, refe
"""
event_refs = refering_person.get_event_ref_list()
for event_ref in event_refs:
if event_ref.get_reference_handle() != skip_event_ref.get_reference_handle():
if (
event_ref.get_reference_handle()
!= skip_event_ref.get_reference_handle()
):
# Refering to an other event.
continue
elif event_ref.is_equal(skip_event_ref):
Expand All @@ -878,9 +883,7 @@ def display_event_other_person_role(self, skip_event_ref, uplink, htmllist, refe
"p",
_("(%(str1)s) %(str2)s")
% {
"str1": Html(
"b", role
),
"str1": Html("b", role),
"str2": person_name,
},
)
Expand All @@ -900,14 +903,20 @@ def display_event_other_person_roles(self, event, skip_event_ref, uplink, htmlli
@return void
"""
refering_person_handles = get_event_person_referents(event.get_handle(), self.r_db)
refering_person_handles = get_event_person_referents(
event.get_handle(), self.r_db
)
for refering_person_handle in refering_person_handles:
refering_person = self.r_db.get_person_from_handle(refering_person_handle)
if not refering_person:
continue
self.display_event_other_person_role(skip_event_ref, uplink, htmllist, refering_person)
self.display_event_other_person_role(
skip_event_ref, uplink, htmllist, refering_person
)

def display_event_other_family_role(self, skip_event_ref, uplink, htmllist, refering_family):
def display_event_other_family_role(
self, skip_event_ref, uplink, htmllist, refering_family
):
"""
Display the role of the refering family to this event.
Skip the role for the specified skip_event_ref because it is already
Expand All @@ -921,7 +930,10 @@ def display_event_other_family_role(self, skip_event_ref, uplink, htmllist, refe
"""
event_refs = refering_family.get_event_ref_list()
for event_ref in event_refs:
if event_ref.get_reference_handle() != skip_event_ref.get_reference_handle():
if (
event_ref.get_reference_handle()
!= skip_event_ref.get_reference_handle()
):
# Refering to an other event.
continue
elif event_ref.is_equal(skip_event_ref):
Expand All @@ -941,9 +953,7 @@ def display_event_other_family_role(self, skip_event_ref, uplink, htmllist, refe
"p",
_("(%(str1)s) %(str2)s")
% {
"str1": Html(
"b", role
),
"str1": Html("b", role),
"str2": family_name,
},
)
Expand All @@ -963,12 +973,16 @@ def display_event_other_family_roles(self, event, skip_event_ref, uplink, htmlli
@return void
"""
refering_family_handles = get_event_family_referents(event.get_handle(), self.r_db)
refering_family_handles = get_event_family_referents(
event.get_handle(), self.r_db
)
for refering_family_handle in refering_family_handles:
refering_family = self.r_db.get_family_from_handle(refering_family_handle)
if not refering_family:
continue
self.display_event_other_family_role(skip_event_ref, uplink, htmllist, refering_family)
self.display_event_other_family_role(
skip_event_ref, uplink, htmllist, refering_family
)

def display_event_row(
self, event, event_ref, place_lat_long, uplink, hyperlink, omit
Expand Down

0 comments on commit a31e116

Please sign in to comment.