* src/ReportUtils.py (rgb_color): Add docs; (child_str): Fixes.

* src/plugins/Ancestors.py: Misc fixes.
* src/plugins/DetAncestralReport.py: Properly call child_str.
* src/plugins/DetDescendantReport.py: Properly call child_str.
* src/plugins/FtmStyleAncestors.py: Properly call child_str.
* src/plugins/FtmStyleDescendants.py: Properly call child_str.


svn: r4073
This commit is contained in:
Alex Roitman 2005-02-22 03:43:53 +00:00
parent 4d89c53ccc
commit 6755b7e04e
7 changed files with 49 additions and 74 deletions

View File

@ -13,6 +13,13 @@
* src/ReportUtils.py (rgb_color): Add function. * src/ReportUtils.py (rgb_color): Add function.
* src/docgen/LPRDoc.py: Use rgb_color from ReportUtils. * src/docgen/LPRDoc.py: Use rgb_color from ReportUtils.
* src/ReportUtils.py (rgb_color): Add docs; (child_str): Fixes.
* src/plugins/Ancestors.py: Misc fixes.
* src/plugins/DetAncestralReport.py: Properly call child_str.
* src/plugins/DetDescendantReport.py: Properly call child_str.
* src/plugins/FtmStyleAncestors.py: Properly call child_str.
* src/plugins/FtmStyleDescendants.py: Properly call child_str.
2005-02-20 Alex Roitman <shura@alex.neuro.umn.edu> 2005-02-20 Alex Roitman <shura@alex.neuro.umn.edu>
* src/docgen/LPRDoc.py (draw_path,draw_bar): Set proper linewidth. * src/docgen/LPRDoc.py (draw_path,draw_bar): Set proper linewidth.
* doc/gramps-manual/C/usage.xml: Update. * doc/gramps-manual/C/usage.xml: Update.

View File

@ -63,6 +63,14 @@ def cm2pt(cm):
return cm*182.88 return cm*182.88
def rgb_color(color): def rgb_color(color):
"""
Converts color value from 0-255 integer range into 0-1 float range.
@param color: list or tuple of integer values for red, green, and blue
@type color: int
@returns: (r,g,b) tuple of floating point color values
@rtype: 3-tuple
"""
r = float(color[0])/255.0 r = float(color[0])/255.0
g = float(color[1])/255.0 g = float(color[1])/255.0
b = float(color[2])/255.0 b = float(color[2])/255.0
@ -932,7 +940,7 @@ def married_rel_str(database,person,family,is_first=True):
text = text + " " text = text + " "
return text return text
def child_str(person,person_name=0,father_name="",mother_name="",dead=0): def child_str(person,father_name="",mother_name="",dead=0):
""" """
Composes a string describing person being a child. Composes a string describing person being a child.
@ -952,14 +960,6 @@ def child_str(person,person_name=0,father_name="",mother_name="",dead=0):
@rtype: unicode @rtype: unicode
""" """
if person_name == None:
person_name = _nd.display_name(person.get_primary_name())
elif person_name == 0:
if person.get_gender() == RelLib.Person.MALE:
person_name = _('He')
else:
person_name = _('She')
text = "" text = ""
if person.get_gender() == RelLib.Person.MALE: if person.get_gender() == RelLib.Person.MALE:

View File

@ -46,7 +46,9 @@ import BaseDoc
import RelLib import RelLib
import PluginMgr import PluginMgr
import ReportOptions import ReportOptions
import ReportUtils
from DateHandler import displayer as _dd from DateHandler import displayer as _dd
from NameDisplay import displayer as _nd
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -519,7 +521,7 @@ class ComprehensiveAncestorsReport (Report.Report):
birth = self.database.get_event_from_handle(birth_handle) birth = self.database.get_event_from_handle(birth_handle)
date = birth.get_date () date = birth.get_date ()
if date: if date:
ret += _(" b. %(date)s") % {'date': date} ret += _(" b. %(birth_date)s") % {'birth_date': date}
ret += self.cite_sources (birth.get_source_references ()) ret += self.cite_sources (birth.get_source_references ())
death_handle = person.get_death_handle () death_handle = person.get_death_handle ()
@ -527,7 +529,7 @@ class ComprehensiveAncestorsReport (Report.Report):
death = self.database.get_event_from_handle(death_handle) death = self.database.get_event_from_handle(death_handle)
date = death.get_date () date = death.get_date ()
if date: if date:
ret += _(" d. %(date)s") % {'date': date} ret += _(" d. %(death_date)s") % {'death_date': date}
ret += self.cite_sources (death.get_source_references ()) ret += self.cite_sources (death.get_source_references ())
return ret return ret
@ -557,49 +559,27 @@ class ComprehensiveAncestorsReport (Report.Report):
return ret return ret
def parents_of (self, person_handle): def parents_of (self, person_handle):
ret = '. ' ret = '. '
person = self.database.get_person_from_handle(person_handle) person = self.database.get_person_from_handle(person_handle)
gender = person.get_gender () family_handle = person.get_main_parents_family_handle()
family_handle = person.get_main_parents_family_handle ()
if family_handle: if family_handle:
family = self.database.get_family_from_handle(family_handle) family = self.database.get_family_from_handle(family_handle)
fathername = mothername = None mother_handle = family.get_mother_handle()
father_handle = family.get_father_handle () father_handle = family.get_father_handle()
if father_handle:
#father = self.database.get_person_from_handle(father_handle)
fathername = self.person_name (father_handle)
mother_handle = family.get_mother_handle ()
if mother_handle: if mother_handle:
#mother = self.database.get_person_from_handle(mother_handle) mother = self.database.get_person_from_handle(mother_handle)
mothername = self.person_name (mother_handle) mother_name = _nd.display_name(mother.get_primary_name())
else:
mother_name = ""
if father_handle:
father = self.database.get_person_from_handle(father_handle)
father_name = _nd.display_name(father.get_primary_name())
else:
father_name = ""
if not mother_handle and not father_handle: ret += ReportUtils.child_str(person,father_name,mother_name,
pass bool(person.get_death_handle()))
elif not father_handle:
if gender == RelLib.Person.FEMALE:
ret += _("She is the daughter of %(mother)s.") % \
{'mother': mothername}
else:
ret += _("He is the son of %(mother)s.") % \
{'mother': mothername}
elif not mother_handle:
if gender == RelLib.Person.FEMALE:
ret += _("She is the daughter of %(father)s.") % \
{'father': fathername}
else:
ret += _("He is the son of %(father)s.") % \
{'father': fathername}
else:
if gender == RelLib.Person.FEMALE:
ret += \
_("She is the daughter of %(father)s and %(mother)s.")%\
{'father': fathername,
'mother': mothername}
else:
ret +=_("He is the son of %(father)s and %(mother)s.") % \
{'father': fathername,
'mother': mothername}
return ret return ret
@ -646,13 +626,7 @@ class ComprehensiveAncestorsReport (Report.Report):
citation += "[%d" % ind citation += "[%d" % ind
comments = ref.get_comments () comments = ref.get_comments ()
if comments and comments.find ('\n') == -1: if comments and comments.find ('\n') == -1:
# Work around rstrip('.') which is not working citation += " - %s" % comments.rstrip ('.')
# with python2.2.1 and earlier
#citation += " - %s" % comments.rstrip ('.')
comments = comments.rstrip()
if comments[-1] == '.':
comments = comments[:-1]
citation += " - %s" % comments
citation += "]" citation += "]"
@ -676,14 +650,8 @@ class ComprehensiveAncestorsReport (Report.Report):
nick = person.get_nick_name () nick = person.get_nick_name ()
if nick: if nick:
#nick = nick.strip ('"') nick = nick.strip ('"')
# Work around strip('"') which is not working
# with python2.2.1 and earlier
nick = nick.strip() nick = nick.strip()
if nick[0] == '"':
nick = nick[1:]
if nick[-1] == '"':
nick = nick[:-1]
name += ' ("%s")' % nick name += ' ("%s")' % nick
spfx = primary.get_surname_prefix () spfx = primary.get_surname_prefix ()
@ -716,9 +684,9 @@ class ComprehensiveAncestorsReport (Report.Report):
mother_handle = family.get_mother_handle () mother_handle = family.get_mother_handle ()
mother = self.database.get_person_from_handle(mother_handle) mother = self.database.get_person_from_handle(mother_handle)
for spouse_handle in [family.get_father_handle (), mother_handle]: for spouse_handle in [family.get_father_handle (), mother_handle]:
spouse = self.database.get_person_from_handle(spouse_handle)
if spouse_handle == person.get_handle() or not spouse_handle: if spouse_handle == person.get_handle() or not spouse_handle:
continue continue
spouse = self.database.get_person_from_handle(spouse_handle)
children = '' children = ''
childlist = family.get_child_handle_list () childlist = family.get_child_handle_list ()

View File

@ -137,7 +137,7 @@ class DetAncestorReport(Report.Report):
def write_report(self): def write_report(self):
self.apply_filter(self.start_person.get_handle(),1) self.apply_filter(self.start_person.get_handle(),1)
name = self.start_person.get_primary_name().get_regular_name() name = _nd.display_name(self.start_person.get_primary_name())
self.doc.start_paragraph("DAR-Title") self.doc.start_paragraph("DAR-Title")
title = _("Detailed Ancestral Report for %s") % name title = _("Detailed Ancestral Report for %s") % name
self.doc.write_text(title) self.doc.write_text(title)
@ -255,16 +255,16 @@ class DetAncestorReport(Report.Report):
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if mother_handle: if mother_handle:
mother = self.database.get_person_from_handle(mother_handle) mother = self.database.get_person_from_handle(mother_handle)
mother_name = mother.get_primary_name().get_regular_name() mother_name = _nd.display_name(mother.get_primary_name())
else: else:
mother_name = "" mother_name = ""
if father_handle: if father_handle:
father = self.database.get_person_from_handle(father_handle) father = self.database.get_person_from_handle(father_handle)
father_name = father.get_primary_name().get_regular_name() father_name = _nd.display_name(father.get_primary_name())
else: else:
father_name = "" father_name = ""
text = ReportUtils.child_str(person,firstName, text = ReportUtils.child_str(person,
father_name,mother_name, father_name,mother_name,
bool(person.get_death_handle())) bool(person.get_death_handle()))
if text: if text:

View File

@ -146,7 +146,7 @@ class DetDescendantReport(Report.Report):
def write_report(self): def write_report(self):
self.apply_filter(self.start_person.get_handle(),1) self.apply_filter(self.start_person.get_handle(),1)
name = self.start_person.get_primary_name().get_regular_name() name = _nd.display_name(self.start_person.get_primary_name())
spouseName = "" spouseName = ""
for family_handle in self.start_person.get_family_handle_list(): for family_handle in self.start_person.get_family_handle_list():
@ -278,16 +278,16 @@ class DetDescendantReport(Report.Report):
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if mother_handle: if mother_handle:
mother = self.database.get_person_from_handle(mother_handle) mother = self.database.get_person_from_handle(mother_handle)
mother_name = mother.get_primary_name().get_regular_name() mother_name = _nd.display_name(mother.get_primary_name())
else: else:
mother_name = "" mother_name = ""
if father_handle: if father_handle:
father = self.database.get_person_from_handle(father_handle) father = self.database.get_person_from_handle(father_handle)
father_name = father.get_primary_name().get_regular_name() father_name = _nd.display_name(father.get_primary_name())
else: else:
father_name = "" father_name = ""
text = ReportUtils.child_str(person,firstName, text = ReportUtils.child_str(person,
father_name,mother_name, father_name,mother_name,
bool(person.get_death_handle())) bool(person.get_death_handle()))
if text: if text:

View File

@ -336,7 +336,7 @@ class FtmAncestorReport(Report.Report):
else: else:
father_name = "" father_name = ""
text = ReportUtils.child_str(person,0, text = ReportUtils.child_str(person,
father_name,mother_name,dead) father_name,mother_name,dead)
if text: if text:
self.doc.write_text(text) self.doc.write_text(text)

View File

@ -482,7 +482,7 @@ class FtmDescendantReport(Report.Report):
else: else:
father_name = "" father_name = ""
text = ReportUtils.child_str(person,0, text = ReportUtils.child_str(person,
father_name,mother_name,dead) father_name,mother_name,dead)
if text: if text:
self.doc.write_text(text) self.doc.write_text(text)