better pylint score for Family Group report (7.99=>9.31)
This commit is contained in:
parent
80ec97baaa
commit
8be0a72ea9
@ -82,11 +82,12 @@ class FamilyGroup(Report):
|
||||
|
||||
stdoptions.run_private_data_option(self, menu)
|
||||
stdoptions.run_living_people_option(self, menu)
|
||||
self.db = self.database
|
||||
|
||||
self.family_handle = None
|
||||
|
||||
family_id = menu.get_option_by_name('family_id').get_value()
|
||||
family = self.database.get_family_from_gramps_id(family_id)
|
||||
family = self.db.get_family_from_gramps_id(family_id)
|
||||
if family:
|
||||
self.family_handle = family.get_handle()
|
||||
else:
|
||||
@ -118,7 +119,7 @@ class FamilyGroup(Report):
|
||||
descr = ""
|
||||
if event:
|
||||
date = self._get_date(event.get_date_object())
|
||||
place = place_displayer.display_event(self.database, event)
|
||||
place = place_displayer.display_event(self.db, event)
|
||||
if place is None:
|
||||
place = ''
|
||||
descr = event.get_description()
|
||||
@ -174,10 +175,10 @@ class FamilyGroup(Report):
|
||||
father_name = ""
|
||||
mother_name = ""
|
||||
if family_handle:
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
father_handle = family.get_father_handle()
|
||||
if father_handle:
|
||||
father = self.database.get_person_from_handle(father_handle)
|
||||
father = self.db.get_person_from_handle(father_handle)
|
||||
father_name = self._name_display.display(father)
|
||||
if self.gramps_ids:
|
||||
gid = father.get_gramps_id()
|
||||
@ -187,18 +188,18 @@ class FamilyGroup(Report):
|
||||
birth_ref = father.get_birth_ref()
|
||||
birth = " "
|
||||
if birth_ref:
|
||||
event = self.database.get_event_from_handle(birth_ref.ref)
|
||||
event = self.db.get_event_from_handle(birth_ref.ref)
|
||||
birth = self._get_date(event.get_date_object())
|
||||
death_ref = father.get_death_ref()
|
||||
death = " "
|
||||
if death_ref:
|
||||
event = self.database.get_event_from_handle(death_ref.ref)
|
||||
event = self.db.get_event_from_handle(death_ref.ref)
|
||||
death = self._get_date(event.get_date_object())
|
||||
if birth_ref or death_ref:
|
||||
father_name += " (%s - %s)" % (birth, death)
|
||||
mother_handle = family.get_mother_handle()
|
||||
if mother_handle:
|
||||
mother = self.database.get_person_from_handle(mother_handle)
|
||||
mother = self.db.get_person_from_handle(mother_handle)
|
||||
mother_name = self._name_display.display(mother)
|
||||
if self.gramps_ids:
|
||||
gid = mother.get_gramps_id()
|
||||
@ -208,12 +209,12 @@ class FamilyGroup(Report):
|
||||
birth_ref = mother.get_birth_ref()
|
||||
birth = " "
|
||||
if birth_ref:
|
||||
event = self.database.get_event_from_handle(birth_ref.ref)
|
||||
event = self.db.get_event_from_handle(birth_ref.ref)
|
||||
birth = self._get_date(event.get_date_object())
|
||||
death_ref = mother.get_death_ref()
|
||||
death = " "
|
||||
if death_ref:
|
||||
event = self.database.get_event_from_handle(death_ref.ref)
|
||||
event = self.db.get_event_from_handle(death_ref.ref)
|
||||
death = self._get_date(event.get_date_object())
|
||||
if birth_ref or death_ref:
|
||||
mother_name += " (%s - %s)" % (birth, death)
|
||||
@ -227,7 +228,7 @@ class FamilyGroup(Report):
|
||||
self.doc.end_cell()
|
||||
self.doc.start_cell("FGR-TextContentsEnd", 2)
|
||||
self.doc.start_paragraph('FGR-Normal')
|
||||
mark = ReportUtils.get_person_mark(self.database,father)
|
||||
mark = ReportUtils.get_person_mark(self.db, father)
|
||||
self.doc.write_text(father_name, mark)
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
@ -244,7 +245,7 @@ class FamilyGroup(Report):
|
||||
self.doc.end_cell()
|
||||
self.doc.start_cell("FGR-TextContentsEnd", 2)
|
||||
self.doc.start_paragraph('FGR-Normal')
|
||||
mark = ReportUtils.get_person_mark(self.database,mother)
|
||||
mark = ReportUtils.get_person_mark(self.db, mother)
|
||||
self.doc.write_text(mother_name, mark)
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
@ -276,8 +277,8 @@ class FamilyGroup(Report):
|
||||
self.doc.start_cell("FGR-TextContentsEnd", 2)
|
||||
self.doc.write_styled_note(note.get_styledtext(),
|
||||
note.get_format(), 'FGR-Note',
|
||||
contains_html= (note.get_type() ==
|
||||
NoteType.HTML_CODE)
|
||||
contains_html=
|
||||
(note.get_type()==NoteType.HTML_CODE)
|
||||
)
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
@ -289,14 +290,14 @@ class FamilyGroup(Report):
|
||||
elif not person_handle:
|
||||
person = Person()
|
||||
else:
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
person = self.db.get_person_from_handle(person_handle)
|
||||
name = self._name_display.display(person)
|
||||
|
||||
self.doc.start_table(title, 'FGR-ParentTable')
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell('FGR-ParentHead', 3)
|
||||
self.doc.start_paragraph('FGR-ParentName')
|
||||
mark = ReportUtils.get_person_mark(self.database,person)
|
||||
mark = ReportUtils.get_person_mark(self.db, person)
|
||||
# translators: needed for French, ignore otherwise
|
||||
self.doc.write_text(self._("%(str1)s: %(str2)s") % {
|
||||
'str1' : title,
|
||||
@ -313,7 +314,7 @@ class FamilyGroup(Report):
|
||||
birth = None
|
||||
evtName = self._("Birth")
|
||||
if birth_ref:
|
||||
birth = self.database.get_event_from_handle(birth_ref.ref)
|
||||
birth = self.db.get_event_from_handle(birth_ref.ref)
|
||||
if birth or self.missingInfo:
|
||||
self.dump_parent_event(evtName, birth)
|
||||
|
||||
@ -321,7 +322,7 @@ class FamilyGroup(Report):
|
||||
death = None
|
||||
evtName = self._("Death")
|
||||
if death_ref:
|
||||
death = self.database.get_event_from_handle(death_ref.ref)
|
||||
death = self.db.get_event_from_handle(death_ref.ref)
|
||||
if death or self.missingInfo:
|
||||
self.dump_parent_event(evtName, death)
|
||||
|
||||
@ -330,7 +331,7 @@ class FamilyGroup(Report):
|
||||
if self.incParEvents:
|
||||
for event_ref in person.get_primary_event_ref_list():
|
||||
if event_ref != birth_ref and event_ref != death_ref:
|
||||
event = self.database.get_event_from_handle(event_ref.ref)
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
event_type = self._get_type(event.get_type())
|
||||
self.dump_parent_event(self._(event_type), event)
|
||||
|
||||
@ -360,7 +361,7 @@ class FamilyGroup(Report):
|
||||
|
||||
if self.incParNotes:
|
||||
for notehandle in person.get_note_list():
|
||||
note = self.database.get_note_from_handle(notehandle)
|
||||
note = self.db.get_note_from_handle(notehandle)
|
||||
self.dump_parent_noteline(self._("Note"), note)
|
||||
|
||||
if self.includeAttrs:
|
||||
@ -381,15 +382,15 @@ class FamilyGroup(Report):
|
||||
if not family:
|
||||
return
|
||||
|
||||
m = None
|
||||
mrg = None
|
||||
family_list = family.get_event_ref_list()
|
||||
for event_ref in family_list:
|
||||
if event_ref:
|
||||
event = self.database.get_event_from_handle(event_ref.ref)
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
if event.get_type() == EventType.MARRIAGE and \
|
||||
(event_ref.get_role() == EventRoleType.FAMILY or
|
||||
event_ref.get_role() == EventRoleType.PRIMARY):
|
||||
m = event
|
||||
mrg = event
|
||||
break
|
||||
|
||||
if len(family_list) > 0 or self.missingInfo or self.includeAttrs:
|
||||
@ -406,11 +407,11 @@ class FamilyGroup(Report):
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
self.dump_parent_event(self._("Marriage"),m)
|
||||
self.dump_parent_event(self._("Marriage"), mrg)
|
||||
|
||||
for event_ref in family_list:
|
||||
if event_ref:
|
||||
event = self.database.get_event_from_handle(event_ref.ref)
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
if event.get_type() != EventType.MARRIAGE:
|
||||
event_type = self._get_type(event.get_type())
|
||||
self.dump_parent_event(self._(event_type), event)
|
||||
@ -429,7 +430,7 @@ class FamilyGroup(Report):
|
||||
date = self._get_date(event.get_date_object())
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = place_displayer.display_event(self.database, event)
|
||||
place = place_displayer.display_event(self.db, event)
|
||||
if place is None:
|
||||
place = ''
|
||||
|
||||
@ -457,23 +458,23 @@ class FamilyGroup(Report):
|
||||
|
||||
def dump_child(self, index, person_handle):
|
||||
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
person = self.db.get_person_from_handle(person_handle)
|
||||
families = len(person.get_family_handle_list())
|
||||
birth_ref = person.get_birth_ref()
|
||||
if birth_ref:
|
||||
birth = self.database.get_event_from_handle(birth_ref.ref)
|
||||
birth = self.db.get_event_from_handle(birth_ref.ref)
|
||||
else:
|
||||
birth = None
|
||||
death_ref = person.get_death_ref()
|
||||
if death_ref:
|
||||
death = self.database.get_event_from_handle(death_ref.ref)
|
||||
death = self.db.get_event_from_handle(death_ref.ref)
|
||||
else:
|
||||
death = None
|
||||
|
||||
spouse_count = 0;
|
||||
if self.incChiMar:
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
spouse_id = None
|
||||
if person_handle == family.get_father_handle():
|
||||
spouse_id = family.get_mother_handle()
|
||||
@ -483,7 +484,9 @@ class FamilyGroup(Report):
|
||||
spouse_count += 1
|
||||
|
||||
self.doc.start_row()
|
||||
if spouse_count != 0 or self.missingInfo or death is not None or birth is not None:
|
||||
if (spouse_count != 0 or self.missingInfo
|
||||
or death is not None
|
||||
or birth is not None):
|
||||
self.doc.start_cell('FGR-TextChild1')
|
||||
else:
|
||||
self.doc.start_cell('FGR-TextChild2')
|
||||
@ -499,7 +502,7 @@ class FamilyGroup(Report):
|
||||
self.doc.end_cell()
|
||||
|
||||
name = self._name_display.display(person)
|
||||
mark = ReportUtils.get_person_mark(self.database,person)
|
||||
mark = ReportUtils.get_person_mark(self.db, person)
|
||||
self.doc.start_cell('FGR-ChildName', 3)
|
||||
self.doc.start_paragraph('FGR-ChildText')
|
||||
self.doc.write_text(name, mark)
|
||||
@ -524,15 +527,15 @@ class FamilyGroup(Report):
|
||||
if self.incChiMar:
|
||||
index = 0
|
||||
for family_handle in person.get_family_handle_list():
|
||||
m = None
|
||||
mrg = None
|
||||
index += 1
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
|
||||
for event_ref in family.get_event_ref_list():
|
||||
if event_ref:
|
||||
event = self.database.get_event_from_handle(event_ref.ref)
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
if event.type == EventType.MARRIAGE:
|
||||
m = event
|
||||
mrg = event
|
||||
break
|
||||
|
||||
spouse_id = None
|
||||
@ -544,7 +547,7 @@ class FamilyGroup(Report):
|
||||
|
||||
if spouse_id:
|
||||
self.doc.start_row()
|
||||
if m or index != families:
|
||||
if mrg or index != families:
|
||||
self.doc.start_cell('FGR-TextChild1')
|
||||
else:
|
||||
self.doc.start_cell('FGR-TextChild2')
|
||||
@ -559,7 +562,7 @@ class FamilyGroup(Report):
|
||||
self.doc.start_cell('FGR-TextContentsEnd', 2)
|
||||
self.doc.start_paragraph('FGR-Normal')
|
||||
|
||||
spouse = self.database.get_person_from_handle(spouse_id)
|
||||
spouse = self.db.get_person_from_handle(spouse_id)
|
||||
spouse_name = self._name_display.display(spouse)
|
||||
if self.gramps_ids:
|
||||
gid = spouse.get_gramps_id()
|
||||
@ -569,12 +572,12 @@ class FamilyGroup(Report):
|
||||
birth = " "
|
||||
birth_ref = spouse.get_birth_ref()
|
||||
if birth_ref:
|
||||
event = self.database.get_event_from_handle(birth_ref.ref)
|
||||
event = self.db.get_event_from_handle(birth_ref.ref)
|
||||
birth = self._get_date(event.get_date_object())
|
||||
death = " "
|
||||
death_ref = spouse.get_death_ref()
|
||||
if death_ref:
|
||||
event = self.database.get_event_from_handle(death_ref.ref)
|
||||
event = self.db.get_event_from_handle(death_ref.ref)
|
||||
death = self._get_date(event.get_date_object())
|
||||
if birth_ref or death_ref:
|
||||
spouse_name += " (%s - %s)" % (birth, death)
|
||||
@ -582,18 +585,18 @@ class FamilyGroup(Report):
|
||||
fid = family.get_gramps_id()
|
||||
if fid:
|
||||
spouse_name += " (%s)" % fid
|
||||
mark = ReportUtils.get_person_mark(self.database,spouse)
|
||||
mark = ReportUtils.get_person_mark(self.db, spouse)
|
||||
self.doc.write_text(spouse_name, mark)
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
if m:
|
||||
if mrg:
|
||||
evtName = self._("Marriage")
|
||||
if index == families:
|
||||
self.dump_child_event('FGR-TextChild2',evtName,m)
|
||||
self.dump_child_event('FGR-TextChild2', evtName, mrg)
|
||||
else:
|
||||
self.dump_child_event('FGR-TextChild1',evtName,m)
|
||||
self.dump_child_event('FGR-TextChild1', evtName, mrg)
|
||||
|
||||
def dump_family(self, family_handle, generation):
|
||||
self.doc.start_paragraph('FGR-Title')
|
||||
@ -605,7 +608,7 @@ class FamilyGroup(Report):
|
||||
self.doc.write_text(title, mark)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
|
||||
self.dump_parent(self._("Husband"), family.get_father_handle())
|
||||
self.doc.start_paragraph("FGR-blank")
|
||||
@ -638,7 +641,7 @@ class FamilyGroup(Report):
|
||||
|
||||
if self.recursive:
|
||||
for child_ref in family.get_child_ref_list():
|
||||
child = self.database.get_person_from_handle(child_ref.ref)
|
||||
child = self.db.get_person_from_handle(child_ref.ref)
|
||||
for child_family_handle in child.get_family_handle_list():
|
||||
if child_family_handle != family_handle:
|
||||
self.doc.page_break()
|
||||
@ -797,7 +800,8 @@ class FamilyGroupOptions(MenuReportOptions):
|
||||
font.set_bold(1)
|
||||
para = ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_description(_('The style used for the text related to the children.'))
|
||||
para.set_description(
|
||||
_('The style used for the text related to the children.'))
|
||||
default_style.add_paragraph_style('FGR-ChildText', para)
|
||||
|
||||
font = FontStyle()
|
||||
|
Loading…
x
Reference in New Issue
Block a user