Clean up PyLint warnings in GVHourGlass.py.

svn: r9789
This commit is contained in:
Brian Matherly 2008-01-13 04:26:47 +00:00
parent a6fe002719
commit 789a33adfd
2 changed files with 53 additions and 35 deletions

View File

@ -1,3 +1,6 @@
2008-01-12 Brian Matherly <brian@gramps-project.org>
* src/plugins/GVHourGlass.py: Clean up PyLint warnings.
2008-01-12 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDisplay.py: open url in standard way
* src/gramps.py: add comment on use of import gnome

View File

@ -22,6 +22,12 @@
"""
Generate an hourglass graph using the GraphViz generator.
"""
#------------------------------------------------------------------------
#
# python modules
#
#------------------------------------------------------------------------
from gettext import gettext as _
#------------------------------------------------------------------------
#
@ -40,19 +46,24 @@ import DateHandler
#
#------------------------------------------------------------------------
class HourGlassReport(Report):
"""
An hourglass report displays ancestors and descendants of a center person.
"""
def __init__(self, database, person, options_class):
"""
Creates HourGlass object that produces the report.
"""
Report.__init__(self, database, person, options_class)
self.db = database
self.__db = database
self.max_descend = options_class.handler.options_dict['maxdescend']
self.max_ascend = options_class.handler.options_dict['maxascend']
pid = options_class.handler.options_dict['pid']
self.center_person = database.get_person_from_gramps_id(pid)
def write_report(self):
"""
Generate the report.
"""
self.add_person(self.center_person)
self.traverse_up(self.center_person, 1)
self.traverse_down(self.center_person, 1)
@ -64,12 +75,12 @@ class HourGlassReport(Report):
if gen > self.max_descend:
return
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)
self.add_family(family)
self.doc.add_link( person.get_gramps_id(), family.get_gramps_id() )
for child_ref in family.get_child_ref_list():
child_handle = child_ref.get_reference_handle()
child = self.db.get_person_from_handle(child_handle)
child = self.__db.get_person_from_handle(child_handle)
self.add_person(child)
self.doc.add_link(family.get_gramps_id(), child.get_gramps_id())
self.traverse_down(child, gen+1)
@ -82,19 +93,19 @@ class HourGlassReport(Report):
return
family_handle = person.get_main_parents_family_handle()
if family_handle:
family = self.db.get_family_from_handle(family_handle)
family = self.__db.get_family_from_handle(family_handle)
family_id = family.get_gramps_id()
self.add_family(family)
self.doc.add_link( family_id, person.get_gramps_id() )
father_handle = family.get_father_handle()
if father_handle:
father = self.db.get_person_from_handle(father_handle)
father = self.__db.get_person_from_handle(father_handle)
self.add_person(father)
self.doc.add_link( father.get_gramps_id(), family_id )
self.traverse_up(father, gen+1)
mother_handle = family.get_mother_handle()
if mother_handle:
mother = self.db.get_person_from_handle( mother_handle )
mother = self.__db.get_person_from_handle( mother_handle )
self.add_person( mother )
self.doc.add_link( mother.get_gramps_id(), family_id )
self.traverse_up( mother, gen+1 )
@ -106,13 +117,13 @@ class HourGlassReport(Report):
p_id = person.get_gramps_id()
name = name_displayer.display_formal(person)
birth_evt = ReportUtils.get_birth_or_fallback(self.db,person)
birth_evt = ReportUtils.get_birth_or_fallback(self.__db, person)
if birth_evt:
birth = DateHandler.get_date(birth_evt)
else:
birth = ""
death_evt = ReportUtils.get_death_or_fallback(self.db,person)
death_evt = ReportUtils.get_death_or_fallback(self.__db, person)
if death_evt:
death = DateHandler.get_date(death_evt)
else:
@ -136,10 +147,11 @@ class HourGlassReport(Report):
"""
family_id = family.get_gramps_id()
label = ""
marriage = ReportUtils.find_marriage(self.db,family)
marriage = ReportUtils.find_marriage(self.__db, family)
if marriage:
label = DateHandler.get_date(marriage)
self.doc.add_node(family_id,label,"ellipse","","filled","lightyellow")
self.doc.add_node(family_id, label, "ellipse", "",
"filled", "lightyellow")
#------------------------------------------------------------------------
#
@ -154,10 +166,13 @@ class HourGlassOptions(MenuReportOptions):
MenuReportOptions.__init__(self, name, dbstate)
def add_menu_options(self, menu, dbstate):
id = ""
"""
Create all the menu options for this report.
"""
gid = ""
if dbstate:
id = dbstate.get_active_person().get_gramps_id()
pid = PersonOption(_("Center Person"),id,dbstate)
gid = dbstate.get_active_person().get_gramps_id()
pid = PersonOption(_("Center Person"), gid, dbstate)
pid.set_help(_("The center person for the report"))
menu.add_option("", "pid", pid)