Standardise on ReportUtils fallback methods for baptism and burial dates in lieu of birth and death dates. Also some PEP8 fixes.

svn: r11716
This commit is contained in:
Gary Burton 2009-01-25 15:04:22 +00:00
parent d1918cc259
commit 9bf926274e

View File

@ -9,6 +9,7 @@
# Copyright (C) 2007 Johan Gonqvist <johan.gronqvist@gmail.com> # Copyright (C) 2007 Johan Gonqvist <johan.gronqvist@gmail.com>
# Contributions by Lorenzo Cappelletti <lorenzo.cappelletti@email.it> # Contributions by Lorenzo Cappelletti <lorenzo.cappelletti@email.it>
# Copyright (C) 2008 Stephane Charette <stephanecharette@gmail.com> # Copyright (C) 2008 Stephane Charette <stephanecharette@gmail.com>
# Copyright (C) 2009 Gary Burton
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -99,7 +100,8 @@ class RelGraphReport(Report):
url - Whether to include URLs. url - Whether to include URLs.
inclimg - Include images or not inclimg - Include images or not
imgpos - Image position, above/beside name imgpos - Image position, above/beside name
color - Whether to use outline, colored outline or filled color in graph color - Whether to use outline, colored outline or filled color
in graph
dashed - Whether to use dashed lines for non-birth relationships. dashed - Whether to use dashed lines for non-birth relationships.
use_roundedcorners - Whether to use rounded corners for females use_roundedcorners - Whether to use rounded corners for females
""" """
@ -129,7 +131,8 @@ class RelGraphReport(Report):
self.includeurl = menu.get_option_by_name('url').get_value() self.includeurl = menu.get_option_by_name('url').get_value()
self.includeimg = menu.get_option_by_name('includeImages').get_value() self.includeimg = menu.get_option_by_name('includeImages').get_value()
self.imgpos = menu.get_option_by_name('imageOnTheSide').get_value() self.imgpos = menu.get_option_by_name('imageOnTheSide').get_value()
self.use_roundedcorners = menu.get_option_by_name('useroundedcorners').get_value() self.use_roundedcorners = \
menu.get_option_by_name('useroundedcorners').get_value()
self.adoptionsdashed = menu.get_option_by_name('dashed').get_value() self.adoptionsdashed = menu.get_option_by_name('dashed').get_value()
self.show_families = menu.get_option_by_name('showfamily').get_value() self.show_families = menu.get_option_by_name('showfamily').get_value()
self.just_years = menu.get_option_by_name('justyears').get_value() self.just_years = menu.get_option_by_name('justyears').get_value()
@ -160,7 +163,8 @@ class RelGraphReport(Report):
self.add_child_links_to_families() self.add_child_links_to_families()
def add_child_links_to_families(self): def add_child_links_to_families(self):
"returns string of GraphViz edges linking parents to families or children" "returns string of GraphViz edges linking parents to families or \
children"
person_dict = {} person_dict = {}
# Hash people in a dictionary for faster inclusion checking # Hash people in a dictionary for faster inclusion checking
for person_handle in self.person_handles: for person_handle in self.person_handles:
@ -259,7 +263,8 @@ class RelGraphReport(Report):
elif self.colorize == 'filled': elif self.colorize == 'filled':
fill = self.colors['family'] fill = self.colors['family']
style = "filled" style = "filled"
self.doc.add_node(fam_id,label,"ellipse",color,style,fill) self.doc.add_node(fam_id, label, "ellipse",
color, style, fill)
# Link this person to all his/her families. # Link this person to all his/her families.
self.doc.add_link( fam_id, p_id, "", self.doc.add_link( fam_id, p_id, "",
self.arrowheadstyle, self.arrowtailstyle ) self.arrowheadstyle, self.arrowtailstyle )
@ -308,16 +313,20 @@ class RelGraphReport(Report):
imagePath = ThumbNails.get_thumbnail_path( imagePath = ThumbNails.get_thumbnail_path(
Utils.media_path_full(self.database, Utils.media_path_full(self.database,
media.get_path())) media.get_path()))
#test if thumbnail actually exists in thumbs (import of data means media files might not be present # test if thumbnail actually exists in thumbs
# (import of data means media files might not be present
imagePath = Utils.find_file(imagePath) imagePath = Utils.find_file(imagePath)
label = u"" label = u""
lineDelimiter = '\\n' lineDelimiter = '\\n'
# If we have an image, then start an HTML table; remember to close the table afterwards! # If we have an image, then start an HTML table; remember to close
# the table afterwards!
# #
# This isn't a free-form HTML format here...just a few keywords that happen to be # This isn't a free-form HTML format here...just a few keywords that
# simillar to keywords commonly seen in HTML. For additional information on what # happen to be
# simillar to keywords commonly seen in HTML. For additional
# information on what
# is allowed, see: # is allowed, see:
# #
# http://www.graphviz.org/info/shapes.html#html # http://www.graphviz.org/info/shapes.html#html
@ -358,29 +367,18 @@ class RelGraphReport(Report):
def get_date_strings(self, person): def get_date_strings(self, person):
"returns tuple of birth/christening and death/burying date strings" "returns tuple of birth/christening and death/burying date strings"
birth_ref = person.get_birth_ref() birth_event = ReportUtils.get_birth_or_fallback(self.database, person)
if birth_ref: if birth_event:
birth_event = self.database.get_event_from_handle(birth_ref.ref)
birth = self.get_event_string(birth_event) birth = self.get_event_string(birth_event)
else: else:
birth = '' birth = ""
death_ref = person.get_death_ref()
if death_ref: death_event = ReportUtils.get_death_or_fallback(self.database, person)
death_event = self.database.get_event_from_handle(death_ref.ref) if death_event:
death = self.get_event_string(death_event) death = self.get_event_string(death_event)
else: else:
death = '' death = ""
if birth and death:
return (birth, death)
# missing info, use (first) christening/burial instead
for event_ref in person.get_primary_event_ref_list():
event = self.database.get_event_from_handle(event_ref.ref)
if event.type == gen.lib.EventType.CHRISTEN:
if not birth:
birth = self.get_event_string(event)
elif event.type == gen.lib.EventType.BURIAL:
if not death:
death = self.get_event_string(event)
return (birth, death) return (birth, death)
def get_event_string(self, event): def get_event_string(self, event):