improve pylint score of Detailed Descendant report from 7.80 to 9.70

This commit is contained in:
Paul Franklin 2016-06-03 12:26:15 -07:00
parent 99fbd648a0
commit 2d396891b8

View File

@ -75,6 +75,7 @@ HENRY = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class DetDescendantReport(Report): class DetDescendantReport(Report):
""" Detailed Descendant Report """
def __init__(self, database, options, user): def __init__(self, database, options, user):
""" """
@ -138,7 +139,7 @@ class DetDescendantReport(Report):
stdoptions.run_private_data_option(self, menu) stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale) stdoptions.run_living_people_option(self, menu, self._locale)
self.database = CacheProxyDb(self.database) self.database = CacheProxyDb(self.database)
self.db = self.database self._db = self.database
self.max_generations = get_value('gen') self.max_generations = get_value('gen')
self.pgbrk = get_value('pagebbg') self.pgbrk = get_value('pagebbg')
@ -167,15 +168,16 @@ class DetDescendantReport(Report):
self.inc_ssign = get_value('incssign') self.inc_ssign = get_value('incssign')
self.inc_materef = get_value('incmateref') self.inc_materef = get_value('incmateref')
pid = get_value('pid') pid = get_value('pid')
self.center_person = self.db.get_person_from_gramps_id(pid) self.center_person = self._db.get_person_from_gramps_id(pid)
if (self.center_person == None) : if self.center_person is None:
raise ReportError(_("Person %s is not in the Database") % pid ) raise ReportError(_("Person %s is not in the Database") % pid)
self.gen_handles = {} self.gen_handles = {}
self.prev_gen_handles = {} self.prev_gen_handles = {}
self.gen_keys = [] self.gen_keys = []
self.dnumber = {} self.dnumber = {}
self.dmates = {} self.dmates = {}
self.numbers_printed = list()
if blankdate: if blankdate:
empty_date = EMPTY_ENTRY empty_date = EMPTY_ENTRY
@ -189,7 +191,7 @@ class DetDescendantReport(Report):
stdoptions.run_name_format_option(self, menu) stdoptions.run_name_format_option(self, menu)
self.__narrator = Narrator(self.db, self.verbose, self.__narrator = Narrator(self._db, self.verbose,
use_call, use_fulldate, use_call, use_fulldate,
empty_date, empty_place, empty_date, empty_place,
nlocale=self._locale, nlocale=self._locale,
@ -197,7 +199,7 @@ class DetDescendantReport(Report):
self.bibli = Bibliography(Bibliography.MODE_DATE|Bibliography.MODE_PAGE) self.bibli = Bibliography(Bibliography.MODE_DATE|Bibliography.MODE_PAGE)
def apply_henry_filter(self,person_handle, index, pid, cur_gen=1): def apply_henry_filter(self, person_handle, index, pid, cur_gen=1):
if (not person_handle) or (cur_gen > self.max_generations): if (not person_handle) or (cur_gen > self.max_generations):
return return
if person_handle in self.dnumber: if person_handle in self.dnumber:
@ -212,18 +214,18 @@ class DetDescendantReport(Report):
else: else:
self.gen_keys[cur_gen-1].append(index) self.gen_keys[cur_gen-1].append(index)
person = self.db.get_person_from_handle(person_handle) person = self._db.get_person_from_handle(person_handle)
index = 0 index = 0
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
family = self.db.get_family_from_handle(family_handle) family = self._db.get_family_from_handle(family_handle)
for child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
ix = max(self.map) _ix = max(self.map)
self.apply_henry_filter(child_ref.ref, ix+1, self.apply_henry_filter(child_ref.ref, _ix+1,
pid+HENRY[index], cur_gen+1) pid+HENRY[index], cur_gen+1)
index += 1 index += 1
# Filter for d'Aboville numbering # Filter for d'Aboville numbering
def apply_daboville_filter(self,person_handle, index, pid, cur_gen=1): def apply_daboville_filter(self, person_handle, index, pid, cur_gen=1):
if (not person_handle) or (cur_gen > self.max_generations): if (not person_handle) or (cur_gen > self.max_generations):
return return
self.dnumber[person_handle] = pid self.dnumber[person_handle] = pid
@ -234,13 +236,13 @@ class DetDescendantReport(Report):
else: else:
self.gen_keys[cur_gen-1].append(index) self.gen_keys[cur_gen-1].append(index)
person = self.db.get_person_from_handle(person_handle) person = self._db.get_person_from_handle(person_handle)
index = 1 index = 1
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
family = self.db.get_family_from_handle(family_handle) family = self._db.get_family_from_handle(family_handle)
for child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
ix = max(self.map) _ix = max(self.map)
self.apply_daboville_filter(child_ref.ref, ix+1, self.apply_daboville_filter(child_ref.ref, _ix+1,
pid+"."+str(index), cur_gen+1) pid+"."+str(index), cur_gen+1)
index += 1 index += 1
@ -255,13 +257,13 @@ class DetDescendantReport(Report):
else: else:
self.gen_keys[cur_gen-1].append(index) self.gen_keys[cur_gen-1].append(index)
person = self.db.get_person_from_handle(person_handle) person = self._db.get_person_from_handle(person_handle)
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
family = self.db.get_family_from_handle(family_handle) family = self._db.get_family_from_handle(family_handle)
for child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
ix = max(self.map) _ix = max(self.map)
self.apply_mod_reg_filter_aux(child_ref.ref, ix+1, cur_gen+1) self.apply_mod_reg_filter_aux(child_ref.ref, _ix+1, cur_gen+1)
def apply_mod_reg_filter(self, person_handle): def apply_mod_reg_filter(self, person_handle):
self.apply_mod_reg_filter_aux(person_handle, 1, 1) self.apply_mod_reg_filter_aux(person_handle, 1, 1)
@ -294,8 +296,8 @@ class DetDescendantReport(Report):
self.doc.start_paragraph("DDR-Title") self.doc.start_paragraph("DDR-Title")
# feature request 2356: avoid genitive form # feature request 2356: avoid genitive form
title = self._("Descendant Report for %(person_name)s") % { title = self._(
'person_name' : name } "Descendant Report for %(person_name)s") % {'person_name' : name}
mark = IndexMark(title, INDEX_TYPE_TOC, 1) mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.write_text(title, mark) self.doc.write_text(title, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
@ -324,7 +326,7 @@ class DetDescendantReport(Report):
if self.pgbrkenotes: if self.pgbrkenotes:
self.doc.page_break() self.doc.page_break()
# it ignores language set for Note type (use locale) # it ignores language set for Note type (use locale)
endnotes.write_endnotes(self.bibli, self.db, self.doc, endnotes.write_endnotes(self.bibli, self._db, self.doc,
printnotes=self.inc_srcnotes, printnotes=self.inc_srcnotes,
elocale=self._locale) elocale=self._locale)
@ -334,16 +336,16 @@ class DetDescendantReport(Report):
#person changes in the loop #person changes in the loop
family_handle = person.get_main_parents_family_handle() family_handle = person.get_main_parents_family_handle()
if family_handle: if family_handle:
family = self.db.get_family_from_handle(family_handle) family = self._db.get_family_from_handle(family_handle)
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if mother_handle and mother_handle in self.dnumber: if mother_handle and mother_handle in self.dnumber:
person = self.db.get_person_from_handle(mother_handle) person = self._db.get_person_from_handle(mother_handle)
person_name = self._name_display.display_name( person_name = self._name_display.display_name(
person.get_primary_name()) person.get_primary_name())
path.append(person_name) path.append(person_name)
elif father_handle and father_handle in self.dnumber: elif father_handle and father_handle in self.dnumber:
person = self.db.get_person_from_handle(father_handle) person = self._db.get_person_from_handle(father_handle)
person_name = self._name_display.display_name( person_name = self._name_display.display_name(
person.get_primary_name()) person.get_primary_name())
path.append(person_name) path.append(person_name)
@ -369,7 +371,7 @@ class DetDescendantReport(Report):
"""Output birth, death, parentage, marriage and notes information """ """Output birth, death, parentage, marriage and notes information """
person_handle = self.map[key] person_handle = self.map[key]
person = self.db.get_person_from_handle(person_handle) person = self._db.get_person_from_handle(person_handle)
val = self.dnumber[person_handle] val = self.dnumber[person_handle]
@ -378,12 +380,12 @@ class DetDescendantReport(Report):
else: else:
self.numbers_printed.append(val) self.numbers_printed.append(val)
self.doc.start_paragraph("DDR-First-Entry","%s." % val) self.doc.start_paragraph("DDR-First-Entry", "%s." % val)
name = self._name_display.display(person) name = self._name_display.display(person)
if not name: if not name:
name = self._("Unknown") name = self._("Unknown")
mark = ReportUtils.get_person_mark(self.db, person) mark = ReportUtils.get_person_mark(self._db, person)
self.doc.start_bold() self.doc.start_bold()
self.doc.write_text(name, mark) self.doc.write_text(name, mark)
@ -402,12 +404,10 @@ class DetDescendantReport(Report):
if dkey >= key: if dkey >= key:
break break
if self.map[key] == self.map[dkey]: if self.map[key] == self.map[dkey]:
self.doc.write_text(self._( self.doc.write_text(
"%(name)s is the same person as [%(id_str)s].") % { self._("%(name)s is the same person as [%(id_str)s]."
'name' :'', % {'name' : '',
'id_str': self.dnumber[self.map[dkey]], 'id_str' : self.dnumber[self.map[dkey]]}))
}
)
self.doc.end_paragraph() self.doc.end_paragraph()
return return
@ -418,7 +418,7 @@ class DetDescendantReport(Report):
if (self.inc_mates or self.listchildren or self.inc_notes or if (self.inc_mates or self.listchildren or self.inc_notes or
self.inc_events or self.inc_attrs): self.inc_events or self.inc_attrs):
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
family = self.db.get_family_from_handle(family_handle) family = self._db.get_family_from_handle(family_handle)
if self.inc_mates: if self.inc_mates:
self.__write_mate(person, family) self.__write_mate(person, family)
if self.listchildren: if self.listchildren:
@ -433,24 +433,25 @@ class DetDescendantReport(Report):
def write_event(self, event_ref): def write_event(self, event_ref):
text = "" text = ""
event = self.db.get_event_from_handle(event_ref.ref) event = self._db.get_event_from_handle(event_ref.ref)
if self.fulldate: if self.fulldate:
date = self._get_date(event.get_date_object()) date = self._get_date(event.get_date_object())
else: else:
date = event.get_date_object().get_year() date = event.get_date_object().get_year()
place = place_displayer.display_event(self.db, event) place = place_displayer.display_event(self._db, event)
self.doc.start_paragraph('DDR-MoreDetails') self.doc.start_paragraph('DDR-MoreDetails')
event_name = self._get_type(event.get_type()) event_name = self._get_type(event.get_type())
if date and place: if date and place:
text += self._('%(date)s, %(place)s') % { # translators: needed for Arabic, ignore otherwise
'date' : date, 'place' : place } text += self._(
'%(date)s, %(place)s') % {'date' : date, 'place' : place}
elif date: elif date:
text += self._('%(date)s') % {'date' : date} text += '%s' % date
elif place: elif place:
text += self._('%(place)s') % { 'place' : place } text += '%s' % place
if event.get_description(): if event.get_description():
if text: if text:
@ -462,9 +463,10 @@ class DetDescendantReport(Report):
if text: if text:
text += ". " text += ". "
text = self._('%(event_name)s: %(event_text)s') % { # translators: needed for French, ignore otherwise
'event_name' : self._(event_name), text = self._('%(str1)s: %(str2)s'
'event_text' : text } % {'str1' : self._(event_name),
'str2' : text})
self.doc.write_text_citation(text) self.doc.write_text_citation(text)
@ -476,12 +478,12 @@ class DetDescendantReport(Report):
if text: if text:
# translators: needed for Arabic, ignore otherwise # translators: needed for Arabic, ignore otherwise
text += self._("; ") text += self._("; ")
attrName = attr.get_type().type2base() attr_name = attr.get_type().type2base()
# translators: needed for French, ignore otherwise # translators: needed for French, ignore otherwise
text += self._("%(type)s: %(value)s%(endnotes)s") % { text += self._("%(type)s: %(value)s%(endnotes)s"
'type' : self._(attrName), % {'type' : self._(attr_name),
'value' : attr.get_value(), 'value' : attr.get_value(),
'endnotes' : self.endnotes(attr) } 'endnotes' : self.endnotes(attr)})
text = " " + text text = " " + text
self.doc.write_text_citation(text) self.doc.write_text_citation(text)
@ -493,30 +495,31 @@ class DetDescendantReport(Report):
notelist = event.get_note_list() notelist = event.get_note_list()
notelist.extend(event_ref.get_note_list()) notelist.extend(event_ref.get_note_list())
for notehandle in notelist: for notehandle in notelist:
note = self.db.get_note_from_handle(notehandle) note = self._db.get_note_from_handle(notehandle)
self.doc.write_styled_note(note.get_styledtext(), self.doc.write_styled_note(
note.get_format(),"DDR-MoreDetails", note.get_styledtext(),
contains_html= note.get_type() == NoteType.HTML_CODE) note.get_format(), "DDR-MoreDetails",
contains_html=(note.get_type() == NoteType.HTML_CODE))
def __write_parents(self, person): def __write_parents(self, person):
family_handle = person.get_main_parents_family_handle() family_handle = person.get_main_parents_family_handle()
if family_handle: if family_handle:
family = self.db.get_family_from_handle(family_handle) family = self._db.get_family_from_handle(family_handle)
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if mother_handle: if mother_handle:
mother = self.db.get_person_from_handle(mother_handle) mother = self._db.get_person_from_handle(mother_handle)
mother_name = self._name_display.display_name( mother_name = self._name_display.display_name(
mother.get_primary_name()) mother.get_primary_name())
mother_mark = ReportUtils.get_person_mark(self.db, mother) mother_mark = ReportUtils.get_person_mark(self._db, mother)
else: else:
mother_name = "" mother_name = ""
mother_mark = "" mother_mark = ""
if father_handle: if father_handle:
father = self.db.get_person_from_handle(father_handle) father = self._db.get_person_from_handle(father_handle)
father_name = self._name_display.display_name( father_name = self._name_display.display_name(
father.get_primary_name()) father.get_primary_name())
father_mark = ReportUtils.get_person_mark(self.db, father) father_mark = ReportUtils.get_person_mark(self._db, father)
else: else:
father_name = "" father_name = ""
father_mark = "" father_mark = ""
@ -534,11 +537,11 @@ class DetDescendantReport(Report):
""" """
is_first = True is_first = True
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
family = self.db.get_family_from_handle(family_handle) family = self._db.get_family_from_handle(family_handle)
spouse_handle = ReportUtils.find_spouse(person, family) spouse_handle = ReportUtils.find_spouse(person, family)
if spouse_handle: if spouse_handle:
spouse = self.db.get_person_from_handle(spouse_handle) spouse = self._db.get_person_from_handle(spouse_handle)
spouse_mark = ReportUtils.get_person_mark(self.db, spouse) spouse_mark = ReportUtils.get_person_mark(self._db, spouse)
else: else:
spouse_mark = None spouse_mark = None
@ -559,18 +562,18 @@ class DetDescendantReport(Report):
mate_handle = family.get_father_handle() mate_handle = family.get_father_handle()
if mate_handle: if mate_handle:
mate = self.db.get_person_from_handle(mate_handle) mate = self._db.get_person_from_handle(mate_handle)
self.doc.start_paragraph("DDR-MoreHeader") self.doc.start_paragraph("DDR-MoreHeader")
name = self._name_display.display(mate) name = self._name_display.display(mate)
if not name: if not name:
name = self._("Unknown") name = self._("Unknown")
mark = ReportUtils.get_person_mark(self.db, mate) mark = ReportUtils.get_person_mark(self._db, mate)
if family.get_relationship() == FamilyRelType.MARRIED: if family.get_relationship() == FamilyRelType.MARRIED:
self.doc.write_text(self._("Spouse: %s") % name, mark) self.doc.write_text(self._("Spouse: %s") % name, mark)
else: else:
self.doc.write_text(self._("Relationship with: %s") self.doc.write_text(
% name, mark) self._("Relationship with: %s") % name, mark)
if name[-1:] != '.': if name[-1:] != '.':
self.doc.write_text(".") self.doc.write_text(".")
self.doc.write_text_citation(self.endnotes(mate)) self.doc.write_text_citation(self.endnotes(mate))
@ -584,9 +587,9 @@ class DetDescendantReport(Report):
if mate_handle in self.dnumber: if mate_handle in self.dnumber:
self.doc.start_paragraph('DDR-MoreDetails') self.doc.start_paragraph('DDR-MoreDetails')
self.doc.write_text_citation( self.doc.write_text_citation(
self._("Ref: %(number)s. %(name)s") % self._("Ref: %(number)s. %(name)s"
{'number': self.dnumber[mate_handle], % {'number' : self.dnumber[mate_handle],
'name': name}) 'name' : name}))
self.doc.end_paragraph() self.doc.end_paragraph()
else: else:
self.dmates[mate_handle] = person.get_handle() self.dmates[mate_handle] = person.get_handle()
@ -595,7 +598,7 @@ class DetDescendantReport(Report):
def __get_mate_names(self, family): def __get_mate_names(self, family):
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
if mother_handle: if mother_handle:
mother = self.db.get_person_from_handle(mother_handle) mother = self._db.get_person_from_handle(mother_handle)
mother_name = self._name_display.display(mother) mother_name = self._name_display.display(mother)
if not mother_name: if not mother_name:
mother_name = self._("Unknown") mother_name = self._("Unknown")
@ -604,7 +607,7 @@ class DetDescendantReport(Report):
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if father_handle: if father_handle:
father = self.db.get_person_from_handle(father_handle) father = self._db.get_person_from_handle(father_handle)
father_name = self._name_display.display(father) father_name = self._name_display.display(father)
if not father_name: if not father_name:
father_name = self._("Unknown") father_name = self._("Unknown")
@ -624,19 +627,19 @@ class DetDescendantReport(Report):
self.doc.start_paragraph("DDR-ChildTitle") self.doc.start_paragraph("DDR-ChildTitle")
self.doc.write_text( self.doc.write_text(
self._("Children of %(mother_name)s and %(father_name)s") % self._("Children of %(mother_name)s and %(father_name)s"
{'father_name': father_name, % {'father_name' : father_name,
'mother_name': mother_name } ) 'mother_name' : mother_name}))
self.doc.end_paragraph() self.doc.end_paragraph()
cnt = 1 cnt = 1
for child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
child_handle = child_ref.ref child_handle = child_ref.ref
child = self.db.get_person_from_handle(child_handle) child = self._db.get_person_from_handle(child_handle)
child_name = self._name_display.display(child) child_name = self._name_display.display(child)
if not child_name: if not child_name:
child_name = self._("Unknown") child_name = self._("Unknown")
child_mark = ReportUtils.get_person_mark(self.db, child) child_mark = ReportUtils.get_person_mark(self._db, child)
if self.childref and self.prev_gen_handles.get(child_handle): if self.childref and self.prev_gen_handles.get(child_handle):
value = str(self.prev_gen_handles.get(child_handle)) value = str(self.prev_gen_handles.get(child_handle))
@ -645,7 +648,7 @@ class DetDescendantReport(Report):
if self.inc_ssign: if self.inc_ssign:
prefix = " " prefix = " "
for family_handle in child.get_family_handle_list(): for family_handle in child.get_family_handle_list():
family = self.db.get_family_from_handle(family_handle) family = self._db.get_family_from_handle(family_handle)
if family.get_child_ref_list(): if family.get_child_ref_list():
prefix = "+ " prefix = "+ "
break break
@ -661,7 +664,9 @@ class DetDescendantReport(Report):
+ ".") + ".")
else: else:
self.doc.start_paragraph("DDR-ChildList", self.doc.start_paragraph("DDR-ChildList",
prefix + ReportUtils.roman(cnt).lower() + ".") prefix
+ ReportUtils.roman(cnt).lower()
+ ".")
cnt += 1 cnt += 1
self.doc.write_text("%s. " % child_name, child_mark) self.doc.write_text("%s. " % child_name, child_mark)
@ -685,14 +690,14 @@ class DetDescendantReport(Report):
self.doc.start_paragraph("DDR-NoteHeader") self.doc.start_paragraph("DDR-NoteHeader")
self.doc.write_text( self.doc.write_text(
self._('Notes for %(mother_name)s and %(father_name)s:') % { self._('Notes for %(mother_name)s and %(father_name)s:'
'mother_name' : mother_name, % {'mother_name' : mother_name,
'father_name' : father_name }) 'father_name' : father_name}))
self.doc.end_paragraph() self.doc.end_paragraph()
for notehandle in notelist: for notehandle in notelist:
note = self.db.get_note_from_handle(notehandle) note = self._db.get_note_from_handle(notehandle)
self.doc.write_styled_note(note.get_styledtext(), self.doc.write_styled_note(note.get_styledtext(),
note.get_format(),"DDR-Entry") note.get_format(), "DDR-Entry")
def __write_family_events(self, family): def __write_family_events(self, family):
""" """
@ -708,9 +713,9 @@ class DetDescendantReport(Report):
if first: if first:
self.doc.start_paragraph('DDR-MoreHeader') self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text( self.doc.write_text(
self._('More about %(mother_name)s and %(father_name)s:') self._('More about %(mother_name)s and %(father_name)s:'
% {'mother_name' : mother_name, % {'mother_name' : mother_name,
'father_name' : father_name }) 'father_name' : father_name}))
self.doc.end_paragraph() self.doc.end_paragraph()
first = False first = False
self.write_event(event_ref) self.write_event(event_ref)
@ -727,19 +732,19 @@ class DetDescendantReport(Report):
self.doc.start_paragraph('DDR-MoreHeader') self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text( self.doc.write_text(
self._('More about %(mother_name)s and %(father_name)s:') self._('More about %(mother_name)s and %(father_name)s:'
% {'mother_name' : mother_name, % {'mother_name' : mother_name,
'father_name' : father_name }) 'father_name' : father_name}))
self.doc.end_paragraph() self.doc.end_paragraph()
for attr in attrs: for attr in attrs:
self.doc.start_paragraph('DDR-MoreDetails') self.doc.start_paragraph('DDR-MoreDetails')
attrName = self._get_type(attr.get_type()) attr_name = self._get_type(attr.get_type())
text = self._("%(type)s: %(value)s%(endnotes)s") % { text = self._("%(type)s: %(value)s%(endnotes)s"
'type' : self._(attrName), % {'type' : self._(attr_name),
'value' : attr.get_value(), 'value' : attr.get_value(),
'endnotes' : self.endnotes(attr) } 'endnotes' : self.endnotes(attr)})
self.doc.write_text_citation( text ) self.doc.write_text_citation(text)
self.doc.end_paragraph() self.doc.end_paragraph()
if self.inc_notes: if self.inc_notes:
@ -747,7 +752,7 @@ class DetDescendantReport(Report):
# get the text and format it correctly # get the text and format it correctly
notelist = attr.get_note_list() notelist = attr.get_note_list()
for notehandle in notelist: for notehandle in notelist:
note = self.db.get_note_from_handle(notehandle) note = self._db.get_note_from_handle(notehandle)
self.doc.write_styled_note(note.get_styledtext(), self.doc.write_styled_note(note.get_styledtext(),
note.get_format(), note.get_format(),
"DDR-MoreDetails") "DDR-MoreDetails")
@ -762,7 +767,7 @@ class DetDescendantReport(Report):
plist = person.get_media_list() plist = person.get_media_list()
if self.addimages and len(plist) > 0: if self.addimages and len(plist) > 0:
photo = plist[0] photo = plist[0]
ReportUtils.insert_image(self.db, self.doc, photo, self._user) ReportUtils.insert_image(self._db, self.doc, photo, self._user)
self.doc.start_paragraph("DDR-Entry") self.doc.start_paragraph("DDR-Entry")
@ -801,37 +806,36 @@ class DetDescendantReport(Report):
self.doc.write_text(self._("Notes for %s") % name) self.doc.write_text(self._("Notes for %s") % name)
self.doc.end_paragraph() self.doc.end_paragraph()
for notehandle in notelist: for notehandle in notelist:
note = self.db.get_note_from_handle(notehandle) note = self._db.get_note_from_handle(notehandle)
self.doc.write_styled_note(note.get_styledtext(), self.doc.write_styled_note(
note.get_format(),"DDR-Entry", note.get_styledtext(), note.get_format(), "DDR-Entry",
contains_html= note.get_type() == NoteType.HTML_CODE) contains_html=(note.get_type() == NoteType.HTML_CODE))
first = True first = True
if self.inc_names: if self.inc_names:
for alt_name in person.get_alternate_names(): for alt_name in person.get_alternate_names():
if first: if first:
self.doc.start_paragraph('DDR-MoreHeader') self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text(self._('More about %(person_name)s:') self.doc.write_text(self._('More about %(person_name)s:'
% {'person_name' : name }) % {'person_name' : name}))
self.doc.end_paragraph() self.doc.end_paragraph()
first = False first = False
self.doc.start_paragraph('DDR-MoreDetails') self.doc.start_paragraph('DDR-MoreDetails')
atype = self._get_type(alt_name.get_type()) atype = self._get_type(alt_name.get_type())
aname = alt_name.get_regular_name() aname = alt_name.get_regular_name()
self.doc.write_text_citation( self.doc.write_text_citation(
self._('%(name_kind)s: %(name)s%(endnotes)s') self._('%(name_kind)s: %(name)s%(endnotes)s'
% {'name_kind' : self._(atype), % {'name_kind' : self._(atype),
'name' : aname, 'name' : aname,
'endnotes' : self.endnotes(alt_name), 'endnotes' : self.endnotes(alt_name)}))
})
self.doc.end_paragraph() self.doc.end_paragraph()
if self.inc_events: if self.inc_events:
for event_ref in person.get_primary_event_ref_list(): for event_ref in person.get_primary_event_ref_list():
if first: if first:
self.doc.start_paragraph('DDR-MoreHeader') self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text(self._('More about %(person_name)s:') self.doc.write_text(self._('More about %(person_name)s:'
% {'person_name' : name }) % {'person_name' : name}))
self.doc.end_paragraph() self.doc.end_paragraph()
first = 0 first = 0
@ -841,8 +845,8 @@ class DetDescendantReport(Report):
for addr in person.get_address_list(): for addr in person.get_address_list():
if first: if first:
self.doc.start_paragraph('DDR-MoreHeader') self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text(self._('More about %(person_name)s:') self.doc.write_text(self._('More about %(person_name)s:'
% {'person_name' : name }) % {'person_name' : name}))
self.doc.end_paragraph() self.doc.end_paragraph()
first = False first = False
self.doc.start_paragraph('DDR-MoreDetails') self.doc.start_paragraph('DDR-MoreDetails')
@ -857,36 +861,37 @@ class DetDescendantReport(Report):
self.doc.write_text(self._('Address: ')) self.doc.write_text(self._('Address: '))
if date: if date:
# translators: needed for Arabic, ignore otherwise # translators: needed for Arabic, ignore otherwise
self.doc.write_text(self._('%s, ') % date ) self.doc.write_text(self._('%s, ') % date)
self.doc.write_text( text ) self.doc.write_text(text)
self.doc.write_text_citation( self.endnotes(addr) ) self.doc.write_text_citation(self.endnotes(addr))
self.doc.end_paragraph() self.doc.end_paragraph()
if self.inc_attrs: if self.inc_attrs:
attrs = person.get_attribute_list() attrs = person.get_attribute_list()
if first and attrs: if first and attrs:
self.doc.start_paragraph('DDR-MoreHeader') self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text(self._('More about %(person_name)s:') % { self.doc.write_text(
'person_name' : name }) self._('More about %(person_name)s:'
% {'person_name' : name}))
self.doc.end_paragraph() self.doc.end_paragraph()
first = False first = False
for attr in attrs: for attr in attrs:
self.doc.start_paragraph('DDR-MoreDetails') self.doc.start_paragraph('DDR-MoreDetails')
attrName = attr.get_type().type2base() attr_name = attr.get_type().type2base()
# translators: needed for French, ignore otherwise # translators: needed for French, ignore otherwise
text = self._("%(type)s: %(value)s%(endnotes)s") % { text = self._("%(type)s: %(value)s%(endnotes)s"
'type' : self._(attrName), % {'type' : self._(attr_name),
'value' : attr.get_value(), 'value' : attr.get_value(),
'endnotes' : self.endnotes(attr) } 'endnotes' : self.endnotes(attr)})
self.doc.write_text_citation( text ) self.doc.write_text_citation(text)
self.doc.end_paragraph() self.doc.end_paragraph()
def endnotes(self, obj): def endnotes(self, obj):
if not obj or not self.inc_sources: if not obj or not self.inc_sources:
return "" return ""
txt = endnotes.cite_source(self.bibli, self.db, obj, self._locale) txt = endnotes.cite_source(self.bibli, self._db, obj, self._locale)
if txt: if txt:
txt = '<super>' + txt + '</super>' txt = '<super>' + txt + '</super>'
return txt return txt
@ -928,15 +933,14 @@ class DetDescendantOptions(MenuReportOptions):
numbering.set_items([ numbering.set_items([
("Henry", _("Henry numbering")), ("Henry", _("Henry numbering")),
("d'Aboville", _("d'Aboville numbering")), ("d'Aboville", _("d'Aboville numbering")),
("Record (Modified Register)", ("Record (Modified Register)", _(
_("Record (Modified Register) numbering"))]) "Record (Modified Register) numbering"))])
numbering.set_help(_("The numbering system to be used")) numbering.set_help(_("The numbering system to be used"))
add_option("numbering", numbering) add_option("numbering", numbering)
generations = NumberOption(_("Generations"), 10, 1, 100) generations = NumberOption(_("Generations"), 10, 1, 100)
generations.set_help( generations.set_help(
_("The number of generations to include in the report") _("The number of generations to include in the report"))
)
add_option("gen", generations) add_option("gen", generations)
pagebbg = BooleanOption(_("Page break between generations"), False) pagebbg = BooleanOption(_("Page break between generations"), False)
@ -944,7 +948,7 @@ class DetDescendantOptions(MenuReportOptions):
_("Whether to start a new page after each generation.")) _("Whether to start a new page after each generation."))
add_option("pagebbg", pagebbg) add_option("pagebbg", pagebbg)
pageben = BooleanOption(_("Page break before end notes"),False) pageben = BooleanOption(_("Page break before end notes"), False)
pageben.set_help( pageben.set_help(
_("Whether to start a new page before the end notes.")) _("Whether to start a new page before the end notes."))
add_option("pageben", pageben) add_option("pageben", pageben)
@ -956,19 +960,21 @@ class DetDescendantOptions(MenuReportOptions):
add_option = partial(menu.add_option, _("Content")) add_option = partial(menu.add_option, _("Content"))
usecall = BooleanOption(_("Use callname for common name"), False) usecall = BooleanOption(_("Use callname for common name"), False)
usecall.set_help(_("Whether to use the call name as the first name.")) usecall.set_help(
_("Whether to use the call name as the first name."))
add_option("usecall", usecall) add_option("usecall", usecall)
fulldates = BooleanOption(_("Use full dates instead of only the year"), fulldates = BooleanOption(
True) _("Use full dates instead of only the year"), True)
fulldates.set_help(_("Whether to use full dates instead of just year.")) fulldates.set_help(
_("Whether to use full dates instead of just year."))
add_option("fulldates", fulldates) add_option("fulldates", fulldates)
listc = BooleanOption(_("List children"), True) listc = BooleanOption(_("List children"), True)
listc.set_help(_("Whether to list children.")) listc.set_help(_("Whether to list children."))
add_option("listc", listc) add_option("listc", listc)
computeage = BooleanOption(_("Compute death age"),True) computeage = BooleanOption(_("Compute death age"), True)
computeage.set_help(_("Whether to compute a person's age at death.")) computeage.set_help(_("Whether to compute a person's age at death."))
add_option("computeage", computeage) add_option("computeage", computeage)
@ -987,7 +993,6 @@ class DetDescendantOptions(MenuReportOptions):
_("Whether to add descendant references in child list.")) _("Whether to add descendant references in child list."))
add_option("desref", desref) add_option("desref", desref)
category_name = _("Include")
add_option = partial(menu.add_option, _("Include")) add_option = partial(menu.add_option, _("Include"))
incnotes = BooleanOption(_("Include notes"), True) incnotes = BooleanOption(_("Include notes"), True)
@ -998,7 +1003,8 @@ class DetDescendantOptions(MenuReportOptions):
incattrs.set_help(_("Whether to include attributes.")) incattrs.set_help(_("Whether to include attributes."))
add_option("incattrs", incattrs) add_option("incattrs", incattrs)
incphotos = BooleanOption(_("Include Photo/Images from Gallery"), False) incphotos = BooleanOption(
_("Include Photo/Images from Gallery"), False)
incphotos.set_help(_("Whether to include images.")) incphotos.set_help(_("Whether to include images."))
add_option("incphotos", incphotos) add_option("incphotos", incphotos)
@ -1019,20 +1025,22 @@ class DetDescendantOptions(MenuReportOptions):
add_option("incsources", incsources) add_option("incsources", incsources)
incsrcnotes = BooleanOption(_("Include sources notes"), False) incsrcnotes = BooleanOption(_("Include sources notes"), False)
incsrcnotes.set_help(_("Whether to include source notes in the " incsrcnotes.set_help(
_("Whether to include source notes in the "
"Endnotes section. Only works if Include sources is selected.")) "Endnotes section. Only works if Include sources is selected."))
add_option("incsrcnotes", incsrcnotes) add_option("incsrcnotes", incsrcnotes)
incmates = BooleanOption(_("Include spouses"), False) incmates = BooleanOption(_("Include spouses"), False)
incmates.set_help(_("Whether to include detailed spouse information.")) incmates.set_help(
_("Whether to include detailed spouse information."))
add_option("incmates", incmates) add_option("incmates", incmates)
incmateref = BooleanOption(_("Include spouse reference"), False) incmateref = BooleanOption(_("Include spouse reference"), False)
incmateref.set_help(_("Whether to include reference to spouse.")) incmateref.set_help(_("Whether to include reference to spouse."))
add_option("incmateref", incmateref) add_option("incmateref", incmateref)
incssign = BooleanOption(_("Include sign of succession ('+')" incssign = BooleanOption(
" in child-list"), True) _("Include sign of succession ('+') in child-list"), True)
incssign.set_help(_("Whether to include a sign ('+') before the" incssign.set_help(_("Whether to include a sign ('+') before the"
" descendant number in the child-list to indicate" " descendant number in the child-list to indicate"
" a child has succession.")) " a child has succession."))
@ -1047,8 +1055,10 @@ class DetDescendantOptions(MenuReportOptions):
add_option = partial(menu.add_option, _("Missing information")) add_option = partial(menu.add_option, _("Missing information"))
repplace = BooleanOption(_("Replace missing places with ______"), False) repplace = BooleanOption(
repplace.set_help(_("Whether to replace missing Places with blanks.")) _("Replace missing places with ______"), False)
repplace.set_help(
_("Whether to replace missing Places with blanks."))
add_option("repplace", repplace) add_option("repplace", repplace)
repdate = BooleanOption(_("Replace missing dates with ______"), False) repdate = BooleanOption(_("Replace missing dates with ______"), False)
@ -1128,7 +1138,8 @@ class DetDescendantOptions(MenuReportOptions):
para.set(first_indent=0.0, lmargin=1.5) para.set(first_indent=0.0, lmargin=1.5)
para.set_top_margin(0.25) para.set_top_margin(0.25)
para.set_bottom_margin(0.25) para.set_bottom_margin(0.25)
para.set_description(_('The style used for the More About header and ' para.set_description(
_('The style used for the More About header and '
'for headers of mates.')) 'for headers of mates.'))
default_style.add_paragraph_style("DDR-MoreHeader", para) default_style.add_paragraph_style("DDR-MoreHeader", para)