More refactoring in the report system. Book report should work again.

svn: r9916
This commit is contained in:
Brian Matherly 2008-01-23 05:41:46 +00:00
parent f01bbb3bc9
commit 2f0d587bec
23 changed files with 655 additions and 573 deletions

@ -1,3 +1,28 @@
2008-01-22 Brian Matherly <brian@gramps-project.org>
* src/plugins/KinshipReport.py:
* src/plugins/DetDescendantReport.py:
* src/plugins/DescendReport.py:
* src/plugins/IndivComplete.py:
* src/plugins/CalculateEstimatedDates.py:
* src/plugins/BookReport.py:
* src/plugins/TimeLine.py:
* src/plugins/Calendar.py:
* src/plugins/AncestorReport.py:
* src/plugins/MarkerReport.py:
* src/plugins/DescendChart.py:
* src/plugins/EndOfLineReport.py:
* src/plugins/AncestorChart.py:
* src/plugins/DetAncestralReport.py:
* src/plugins/CustomBookText.py:
* src/plugins/FamilyGroup.py:
* src/plugins/GVRelGraph.py:
* src/plugins/GVHourGlass.py:
* src/plugins/StatisticsChart.py:
* src/plugins/FanChart.py:
* src/PluginUtils/__init__.py:
* src/PluginUtils/_MenuOptions.py:
More refactoring in the report system. Book report should work again.
2008-01-22 Raphael Ackermann <raphael.ackermann@gmail.com> 2008-01-22 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/ReportBase/_Bibliography.py * src/ReportBase/_Bibliography.py
* src/ReportBase/_Endnotes.py * src/ReportBase/_Endnotes.py

@ -357,10 +357,10 @@ class EnumeratedListOption(Option):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# PersonFilterOption class # FilterOption class
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class PersonFilterOption(EnumeratedListOption): class FilterOption(EnumeratedListOption):
""" """
This class describes an option that provides a list of person filters. This class describes an option that provides a list of person filters.
Each possible value represents one of the possible filters. Each possible value represents one of the possible filters.

@ -30,7 +30,7 @@
# of the list. # of the list.
from _MenuOptions import \ from _MenuOptions import \
NumberOption, BooleanOption, TextOption, \ NumberOption, BooleanOption, TextOption, \
EnumeratedListOption, PersonFilterOption, StringOption, ColourOption, \ EnumeratedListOption, FilterOption, StringOption, ColourOption, \
PersonOption, PersonListOption, SurnameColourOption, FamilyOption PersonOption, PersonListOption, SurnameColourOption, FamilyOption
from _GuiOptions import GuiMenuOptions from _GuiOptions import GuiMenuOptions
from _PluginMgr import \ from _PluginMgr import \

@ -180,13 +180,14 @@ class AncestorChart(Report):
""" """
Report.__init__(self,database,person,options_class) Report.__init__(self,database,person,options_class)
self.display = options_class.handler.options_dict['dispf'] menu = options_class.menu
self.max_generations = options_class.handler.options_dict['maxgen'] self.display = menu.get_option_by_name('dispf').get_value()
self.force_fit = options_class.handler.options_dict['singlep'] self.max_generations = menu.get_option_by_name('maxgen').get_value()
self.incblank = options_class.handler.options_dict['incblank'] self.force_fit = menu.get_option_by_name('singlep').get_value()
self.compress = options_class.handler.options_dict['compress'] self.incblank = menu.get_option_by_name('incblank').get_value()
self.compress = menu.get_option_by_name('compress').get_value()
pid = options_class.handler.options_dict['pid'] pid = menu.get_option_by_name('pid').get_value()
center_person = database.get_person_from_gramps_id(pid) center_person = database.get_person_from_gramps_id(pid)
name = name_displayer.display_formal(center_person) name = name_displayer.display_formal(center_person)

@ -28,7 +28,6 @@
# python modules # python modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import gtk
import math import math
from gettext import gettext as _ from gettext import gettext as _
@ -52,10 +51,15 @@ from gen.lib import ChildRefType
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
def log2(val): def log2(val):
"""
Calculate the log base 2 of a number
"""
return int(math.log10(val)/math.log10(2)) return int(math.log10(val)/math.log10(2))
class AncestorReport(Report): class AncestorReport(Report):
"""
Ancestor Report class
"""
def __init__(self, database, person, options_class): def __init__(self, database, person, options_class):
""" """
Creates the AncestorReport object that produces the Ahnentafel report. Creates the AncestorReport object that produces the Ahnentafel report.
@ -77,10 +81,12 @@ class AncestorReport(Report):
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
self.map = {} self.map = {}
self.max_generations = options_class.handler.options_dict['maxgen']
self.pgbrk = options_class.handler.options_dict['pagebbg'] menu = options_class.menu
self.opt_namebrk = options_class.handler.options_dict['namebrk'] self.max_generations = menu.get_option_by_name('maxgen').get_value()
pid = options_class.handler.options_dict['pid'] self.pgbrk = menu.get_option_by_name('pagebbg').get_value()
self.opt_namebrk = menu.get_option_by_name('namebrk').get_value()
pid = menu.get_option_by_name('pid').get_value()
self.center_person = database.get_person_from_gramps_id(pid) self.center_person = database.get_person_from_gramps_id(pid)
def apply_filter(self, person_handle, index, generation=1): def apply_filter(self, person_handle, index, generation=1):
@ -125,25 +131,27 @@ class AncestorReport(Report):
# people defined as the birth parents, we will select based on # people defined as the birth parents, we will select based on
# priority in the list # priority in the list
if not father_handle and ref[0].get_father_relation() == ChildRefType.BIRTH: if not father_handle and \
ref[0].get_father_relation() == ChildRefType.BIRTH:
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if not mother_handle and ref[0].get_mother_relation() == ChildRefType.BIRTH: if not mother_handle and \
ref[0].get_mother_relation() == ChildRefType.BIRTH:
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
# Recursively call the function. It is okay if the handle is None, since # Recursively call the function. It is okay if the handle is None,
# routine handles a handle of None # since routine handles a handle of None
self.apply_filter(father_handle, index*2, generation+1) self.apply_filter(father_handle, index*2, generation+1)
self.apply_filter(mother_handle, (index*2)+1, generation+1) self.apply_filter(mother_handle, (index*2)+1, generation+1)
def write_report(self): def write_report(self):
""" """
The routine the actually creates the report. At this point, the document is The routine the actually creates the report. At this point, the document
opened and ready for writing. is opened and ready for writing.
""" """
# Call apply_filter to build the self.map array of people in the database that # Call apply_filter to build the self.map array of people in the
# match the ancestry. # database that match the ancestry.
self.apply_filter(self.center_person.get_handle(), 1) self.apply_filter(self.center_person.get_handle(), 1)
@ -191,8 +199,8 @@ class AncestorReport(Report):
self.doc.write_text(name.strip(), mark) self.doc.write_text(name.strip(), mark)
self.doc.end_bold() self.doc.end_bold()
# terminate with a period if it is not already terminated. This can happen # terminate with a period if it is not already terminated.
# if the person's name ends with something 'Jr.' # This can happen if the person's name ends with something 'Jr.'
if name[-1:] == '.': if name[-1:] == '.':
self.doc.write_text(" ") self.doc.write_text(" ")
else: else:
@ -208,9 +216,12 @@ class AncestorReport(Report):
primary_name = person.get_primary_name() primary_name = person.get_primary_name()
first = primary_name.get_first_name() first = primary_name.get_first_name()
self.doc.write_text(ReportUtils.born_str(self.database,person,first)) self.doc.write_text(
self.doc.write_text(ReportUtils.died_str(self.database,person,0)) ReportUtils.born_str(self.database, person, first))
self.doc.write_text(ReportUtils.buried_str(self.database,person,0)) self.doc.write_text(
ReportUtils.died_str(self.database, person, 0))
self.doc.write_text(
ReportUtils.buried_str(self.database, person, 0))
self.doc.end_paragraph() self.doc.end_paragraph()
@ -243,7 +254,8 @@ class AncestorOptions(MenuReportOptions):
menu.add_option(category_name, "maxgen", maxgen) menu.add_option(category_name, "maxgen", maxgen)
pagebbg = BooleanOption(_("Page break between generations"), False) pagebbg = BooleanOption(_("Page break between generations"), False)
pagebbg.set_help(_("Whether to start a new page after each generation.")) pagebbg.set_help(
_("Whether to start a new page after each generation."))
menu.add_option(category_name, "pagebbg", pagebbg) menu.add_option(category_name, "pagebbg", pagebbg)
namebrk = BooleanOption(_("Add linebreak after each name"), False) namebrk = BooleanOption(_("Add linebreak after each name"), False)

@ -63,7 +63,6 @@ import gtk.glade
# gramps modules # gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gen.lib import Person
import const import const
import Utils import Utils
import ListModel import ListModel
@ -71,14 +70,13 @@ import Errors
import BaseDoc import BaseDoc
from QuestionDialog import WarningDialog, ErrorDialog from QuestionDialog import WarningDialog, ErrorDialog
from PluginUtils import bkitems_list, register_report, Plugins from PluginUtils import bkitems_list, register_report, Plugins
from PluginUtils import PersonOption, PersonFilterOption from PluginUtils import PersonOption, FilterOption, FamilyOption
import ManagedWindow import ManagedWindow
# Import from specific modules in ReportBase # Import from specific modules in ReportBase
from ReportBase._Constants import CATEGORY_BOOK, MODE_GUI, MODE_CLI from ReportBase._Constants import CATEGORY_BOOK, MODE_GUI, MODE_CLI
from ReportBase._BookFormatComboBox import BookFormatComboBox from ReportBase._BookFormatComboBox import BookFormatComboBox
from ReportBase._BareReportDialog import BareReportDialog from ReportBase._BareReportDialog import BareReportDialog
from ReportBase._ReportDialog import ReportDialog
from ReportBase._DocReportDialog import DocReportDialog from ReportBase._DocReportDialog import DocReportDialog
from ReportBase._CommandLineReport import CommandLineReport from ReportBase._CommandLineReport import CommandLineReport
from ReportBase._ReportOptions import ReportOptions from ReportBase._ReportOptions import ReportOptions
@ -90,28 +88,83 @@ from BasicUtils import name_displayer as _nd
# Private Functions # Private Functions
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
def _get_subject(options,db): def _initialize_options(options, dbstate):
"""
Validates all options by making sure that their values are consistent with
the database.
menu: The Menu class
dbase: the database the options will be applied to
"""
dbase = dbstate.get_database()
if not hasattr(options, "menu"):
return
menu = options.menu
for name in menu.get_all_option_names():
option = menu.get_option_by_name(name)
if isinstance(option, PersonOption):
person = dbstate.get_active_person()
option.set_value(person.get_gramps_id())
elif isinstance(option, FamilyOption):
person = dbstate.get_active_person()
family_list = person.get_family_handle_list()
if family_list:
family_handle = family_list[0]
else:
family_handle = dbase.get_family_handles()[0]
family = dbase.get_family_from_handle(family_handle)
option.set_value(family.get_gramps_id())
def _get_subject(options, dbase):
""" """
Attempts to determine the subject of a set of options. The subject would Attempts to determine the subject of a set of options. The subject would
likely be a person (using a PersonOption) or a filter (using a likely be a person (using a PersonOption) or a filter (using a
PersonFilterOption) FilterOption)
options: The ReportOptions class options: The ReportOptions class
db: the database for which it corresponds dbase: the database for which it corresponds
""" """
if not hasattr(options, "menu"): if not hasattr(options, "menu"):
return _("Not Applicable") return _("Not Applicable")
menu = options.menu menu = options.menu
option_names = menu.get_all_option_names() option_names = menu.get_all_option_names()
for name in option_names: for name in option_names:
option = menu.get_option_by_name(name) option = menu.get_option_by_name(name)
if isinstance(option, PersonFilterOption):
if isinstance(option, FilterOption):
return option.get_filter().get_name() return option.get_filter().get_name()
elif isinstance(option, PersonOption): elif isinstance(option, PersonOption):
gid = option.get_value() gid = option.get_value()
person = db.get_person_from_gramps_id(gid) person = dbase.get_person_from_gramps_id(gid)
return _nd.display(person) return _nd.display(person)
elif isinstance(option, FamilyOption):
family = dbase.get_family_from_gramps_id(option.get_value())
family_id = family.get_gramps_id()
fhandle = family.get_father_handle()
mhandle = family.get_mother_handle()
if fhandle:
father = dbase.get_person_from_handle(fhandle)
father_name = _nd.display(father)
else:
father_name = _("unknown father")
if mhandle:
mother = dbase.get_person_from_handle(mhandle)
mother_name = _nd.display(mother)
else:
mother_name = _("unknown mother")
name = _("%s and %s (%s)") % (father_name, mother_name, family_id)
return name
return _("Not Applicable") return _("Not Applicable")
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -686,8 +739,13 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
book_label.set_use_underline(True) book_label.set_use_underline(True)
book_label.set_use_markup(True) book_label.set_use_markup(True)
av_titles = [(_('Name'),0,150),(_('Type'),1,50),('',-1,0)] av_titles = [ (_('Name'), 0, 150),
bk_titles = [(_('Item name'),-1,150),(_('Type'),-1,50),('',-1,0), (_('Type'), 1, 50 ),
( '' , -1, 0 ) ]
bk_titles = [ (_('Item name'), -1, 150),
(_('Type'), -1, 50 ),
( '', -1, 0 ),
(_('Subject'), -1, 50 ) ] (_('Subject'), -1, 50 ) ]
self.av_ncols = len(av_titles) self.av_ncols = len(av_titles)
@ -753,6 +811,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
name = saved_item.get_name() name = saved_item.get_name()
item = BookItem(self.dbstate, name) item = BookItem(self.dbstate, name)
item.option_class = saved_item.option_class item.option_class = saved_item.option_class
_initialize_options(item.option_class, self.dbstate)
item.set_style_name(saved_item.get_style_name()) item.set_style_name(saved_item.get_style_name())
self.book.append_item(item) self.book.append_item(item)
@ -773,6 +832,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
return return
data = self.av_model.get_data(the_iter, range(self.av_ncols)) data = self.av_model.get_data(the_iter, range(self.av_ncols))
item = BookItem(self.dbstate, data[2]) item = BookItem(self.dbstate, data[2])
_initialize_options(item.option_class, self.dbstate)
data[2] = _get_subject(item.option_class, self.db) data[2] = _get_subject(item.option_class, self.db)
self.bk_model.add(data) self.bk_model.add(data)
self.book.append_item(item) self.book.append_item(item)
@ -840,6 +900,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
self.track) self.track)
response = item_dialog.window.run() response = item_dialog.window.run()
if response == RESPONSE_OK: if response == RESPONSE_OK:
_initialize_options(option_class, self.dbstate)
subject = _get_subject(option_class, self.db) subject = _get_subject(option_class, self.db)
self.bk_model.model.set_value(the_iter, 2, subject) self.bk_model.model.set_value(the_iter, 2, subject)
self.book.set_item(row, item) self.book.set_item(row, item)
@ -932,7 +993,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
""" """
Save the current book in the xml booklist file. Save the current book in the xml booklist file.
""" """
self.book_list = BookList(self.file,dbstate) self.book_list = BookList(self.file, self.dbstate)
name = unicode(self.name_entry.get_text()) name = unicode(self.name_entry.get_text())
self.book.set_name(name) self.book.set_name(name)
self.book.set_dbname(self.db.get_save_path()) self.book.set_dbname(self.db.get_save_path())
@ -1138,9 +1199,10 @@ def cl_report(database,name,category,options_str_dict):
style_name = item.option_class.handler.get_default_stylesheet_name() style_name = item.option_class.handler.get_default_stylesheet_name()
style_sheet = style_list.get_style_sheet(style_name) style_sheet = style_list.get_style_sheet(style_name)
for this_style_name in style_sheet.get_names(): for this_style_name in style_sheet.get_paragraph_style_names():
selected_style.add_style( selected_style.add_paragraph_style(
this_style_name,style_sheet.get_style(this_style_name)) this_style_name,
style_sheet.get_paragraph_style(this_style_name))
# write report # write report
doc = clr.format(selected_style, clr.paper, clr.template_name, clr.orien) doc = clr.format(selected_style, clr.paper, clr.template_name, clr.orien)

@ -37,7 +37,7 @@ import time
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import Tool, register_tool, PluginWindows, \ from PluginUtils import Tool, register_tool, PluginWindows, \
MenuToolOptions, BooleanOption, PersonFilterOption, StringOption, \ MenuToolOptions, BooleanOption, FilterOption, StringOption, \
NumberOption, PersonOption NumberOption, PersonOption
import gen.lib import gen.lib
import Config import Config
@ -59,16 +59,17 @@ class CalcEstDateOptions(MenuToolOptions):
""" Adds the options """ """ Adds the options """
category_name = _("Options") category_name = _("Options")
self.__filter = FilterOption(_("Filter"), 0)
self.__filter.set_help(_("Select filter to restrict people"))
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
self.__pid = PersonOption(_("Filter Person")) self.__pid = PersonOption(_("Filter Person"))
self.__pid.set_help(_("The center person for the filter")) self.__pid.set_help(_("The center person for the filter"))
menu.add_option(category_name, "pid", self.__pid) menu.add_option(category_name, "pid", self.__pid)
self.__pid.connect('value-changed', self.__update_filters) self.__pid.connect('value-changed', self.__update_filters)
self.__filter = PersonFilterOption(_("Filter"), 0)
self.__filter.set_help(_("Select filter to restrict people"))
self.__update_filters() self.__update_filters()
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
source_text = StringOption(_("Source text"), source_text = StringOption(_("Source text"),
_("Calculated Date Estimates")) _("Calculated Date Estimates"))

@ -46,7 +46,7 @@ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_DRAW, CATEGORY_TEXT, \ CATEGORY_DRAW, CATEGORY_TEXT, \
MODE_GUI, MODE_BKI, MODE_CLI MODE_GUI, MODE_BKI, MODE_CLI
from PluginUtils import NumberOption, BooleanOption, StringOption, \ from PluginUtils import NumberOption, BooleanOption, StringOption, \
PersonFilterOption, EnumeratedListOption, PersonOption FilterOption, EnumeratedListOption, PersonOption
import GrampsLocale import GrampsLocale
import gen.lib import gen.lib
from Utils import probably_alive, ProgressMeter from Utils import probably_alive, ProgressMeter
@ -122,30 +122,32 @@ class Calendar(Report):
""" """
def __init__(self, database, person, options_class): def __init__(self, database, person, options_class):
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
if 'titletext' in options_class.handler.options_dict.keys(): menu = options_class.menu
if 'titletext' in menu.get_all_option_names():
# report and graphic share most of the same code # report and graphic share most of the same code
# but calendar doesn't have a title # but calendar doesn't have a title
self.titletext = options_class.handler.options_dict['titletext'] self.titletext = menu.get_option_by_name('titletext').get_value()
if 'relationships' in options_class.handler.options_dict.keys(): if 'relationships' in menu.get_all_option_names():
# report and graphic share most of the same code # report and graphic share most of the same code
# but calendar doesn't show relationships # but calendar doesn't show relationships
self.relationships = options_class.handler.options_dict['relationships'] self.relationships = \
menu.get_option_by_name('relationships').get_value()
else: else:
self.relationships = False self.relationships = False
self.year = options_class.handler.options_dict['year'] self.year = menu.get_option_by_name('year').get_value()
self.name_format = options_class.handler.options_dict['name_format'] self.name_format = menu.get_option_by_name('name_format').get_value()
self.country = options_class.handler.options_dict['country'] self.country = menu.get_option_by_name('country').get_value()
self.anniversaries = options_class.handler.options_dict['anniversaries'] self.anniversaries = menu.get_option_by_name('anniversaries').get_value()
self.start_dow = options_class.handler.options_dict['start_dow'] self.start_dow = menu.get_option_by_name('start_dow').get_value()
self.maiden_name = options_class.handler.options_dict['maiden_name'] self.maiden_name = menu.get_option_by_name('maiden_name').get_value()
self.alive = options_class.handler.options_dict['alive'] self.alive = menu.get_option_by_name('alive').get_value()
self.birthdays = options_class.handler.options_dict['birthdays'] self.birthdays = menu.get_option_by_name('birthdays').get_value()
self.text1 = options_class.handler.options_dict['text1'] self.text1 = menu.get_option_by_name('text1').get_value()
self.text2 = options_class.handler.options_dict['text2'] self.text2 = menu.get_option_by_name('text2').get_value()
self.text3 = options_class.handler.options_dict['text3'] self.text3 = menu.get_option_by_name('text3').get_value()
self.filter_option = options_class.menu.get_option_by_name('filter') self.filter_option = menu.get_option_by_name('filter')
self.filter = self.filter_option.get_filter() self.filter = self.filter_option.get_filter()
self.pid = options_class.handler.options_dict['pid'] self.pid = menu.get_option_by_name('pid').get_value()
self.title = _("Calendar Report") #% name self.title = _("Calendar Report") #% name
@ -488,17 +490,18 @@ class CalendarOptions(MenuReportOptions):
year.set_help(_("Year of calendar")) year.set_help(_("Year of calendar"))
menu.add_option(category_name,"year", year) menu.add_option(category_name,"year", year)
self.__filter = FilterOption(_("Filter"), 0)
self.__filter.set_help(
_("Select filter to restrict people that appear on calendar"))
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
self.__pid = PersonOption(_("Filter Person")) self.__pid = PersonOption(_("Filter Person"))
self.__pid.set_help(_("The center person for the filter")) self.__pid.set_help(_("The center person for the filter"))
menu.add_option(category_name, "pid", self.__pid) menu.add_option(category_name, "pid", self.__pid)
self.__pid.connect('value-changed', self.__update_filters) self.__pid.connect('value-changed', self.__update_filters)
self.__filter = PersonFilterOption(_("Filter"), 0)
self.__filter.set_help(
_("Select filter to restrict people that appear on calendar"))
self.__update_filters() self.__update_filters()
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
name_format = EnumeratedListOption(_("Name format"), -1) name_format = EnumeratedListOption(_("Name format"), -1)
for num, name, fmt_str, act in name_displayer.get_name_format(): for num, name, fmt_str, act in name_displayer.get_name_format():

@ -71,9 +71,10 @@ class CustomText(Report):
""" """
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
self.top_text = options_class.handler.options_dict['top'] menu = options_class.menu
self.middle_text = options_class.handler.options_dict['mid'] self.top_text = menu.get_option_by_name('top').get_value()
self.bottom_text = options_class.handler.options_dict['bot'] self.middle_text = menu.get_option_by_name('mid').get_value()
self.bottom_text = menu.get_option_by_name('bot').get_value()
def write_report(self): def write_report(self):
self.doc.start_paragraph('CBT-Initial') self.doc.start_paragraph('CBT-Initial')

@ -36,7 +36,6 @@ from ReportBase import Report, MenuReportOptions, \
from SubstKeywords import SubstKeywords from SubstKeywords import SubstKeywords
from gettext import gettext as _ from gettext import gettext as _
import BaseDoc import BaseDoc
import math
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -121,11 +120,12 @@ class DescendChart(Report):
""" """
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
self.display = options_class.handler.options_dict['dispf'] menu = options_class.menu
self.max_generations = options_class.handler.options_dict['maxgen'] self.display = menu.get_option_by_name('dispf').get_value()
self.force_fit = options_class.handler.options_dict['singlep'] self.max_generations = menu.get_option_by_name('maxgen').get_value()
self.incblank = options_class.handler.options_dict['incblank'] self.force_fit = menu.get_option_by_name('singlep').get_value()
pid = options_class.handler.options_dict['pid'] self.incblank = menu.get_option_by_name('incblank').get_value()
pid = menu.get_option_by_name('pid').get_value()
center_person = database.get_person_from_gramps_id(pid) center_person = database.get_person_from_gramps_id(pid)
name = name_displayer.display_formal(center_person) name = name_displayer.display_formal(center_person)

@ -28,7 +28,6 @@
# standard python modules # standard python modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import os
from gettext import gettext as _ from gettext import gettext as _
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -40,19 +39,10 @@ from PluginUtils import register_report, NumberOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
import BaseDoc import BaseDoc
import Errors
import Sort import Sort
from QuestionDialog import ErrorDialog
from BasicUtils import name_displayer from BasicUtils import name_displayer
import DateHandler import DateHandler
#------------------------------------------------------------------------
#
# GTK/GNOME modules
#
#------------------------------------------------------------------------
import gtk
_BORN = _('b.') _BORN = _('b.')
_DIED = _('d.') _DIED = _('d.')
@ -82,8 +72,9 @@ class DescendantReport(Report):
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
self.max_generations = options_class.handler.options_dict['gen'] menu = options_class.menu
pid = options_class.handler.options_dict['pid'] self.max_generations = menu.get_option_by_name('gen').get_value()
pid = menu.get_option_by_name('pid').get_value()
self.center_person = database.get_person_from_gramps_id(pid) self.center_person = database.get_person_from_gramps_id(pid)
sort = Sort.Sort(self.database) sort = Sort.Sort(self.database)
self.by_birthdate = sort.by_birthdate self.by_birthdate = sort.by_birthdate

@ -76,53 +76,54 @@ class DetAncestorReport(Report):
gen - Maximum number of generations to include. gen - Maximum number of generations to include.
pagebgg - Whether to include page breaks between generations. pagebgg - Whether to include page breaks between generations.
firstName - Whether to use first names instead of pronouns. firstName - Whether to use first names instead of pronouns.
fullDate - Whether to use full dates instead of just year. fulldate - Whether to use full dates instead of just year.
listChildren - Whether to list children. listchildren - Whether to list children.
includeNotes - Whether to include notes. includenotes - Whether to include notes.
includeAttrs - Whether to include attributes incattrs - Whether to include attributes
blankPlace - Whether to replace missing Places with ___________. blankplace - Whether to replace missing Places with ___________.
blankDate - Whether to replace missing Dates with ___________. blankDate - Whether to replace missing Dates with ___________.
calcAgeFlag - Whether to compute age. calcageflag - Whether to compute age.
dupPerson - Whether to omit duplicate ancestors (e.g. when distant cousins mary). dupperson - Whether to omit duplicate ancestors (e.g. when distant cousins mary).
verbose - Whether to use complete sentences verbose - Whether to use complete sentences
childRef - Whether to add descendant references in child list. childref - Whether to add descendant references in child list.
addImages - Whether to include images. addimages - Whether to include images.
pid - The Gramps ID of the center person for the report. pid - The Gramps ID of the center person for the report.
""" """
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
self.map = {} self.map = {}
self.max_generations = options_class.handler.options_dict['gen'] menu = options_class.menu
self.pgbrk = options_class.handler.options_dict['pagebbg'] self.max_generations = menu.get_option_by_name('gen').get_value()
self.fullDate = options_class.handler.options_dict['fulldates'] self.pgbrk = menu.get_option_by_name('pagebbg').get_value()
self.listChildren = options_class.handler.options_dict['listc'] self.fulldate = menu.get_option_by_name('fulldates').get_value()
self.includeNotes = options_class.handler.options_dict['incnotes'] self.listchildren = menu.get_option_by_name('listc').get_value()
self.usecall = options_class.handler.options_dict['usecall'] self.includenotes = menu.get_option_by_name('incnotes').get_value()
self.blankPlace = options_class.handler.options_dict['repplace'] self.usecall = menu.get_option_by_name('usecall').get_value()
self.blankDate = options_class.handler.options_dict['repdate'] blankplace = menu.get_option_by_name('repplace').get_value()
self.calcAgeFlag = options_class.handler.options_dict['computeage'] blankdate = menu.get_option_by_name('repdate').get_value()
self.dupPerson = options_class.handler.options_dict['omitda'] self.calcageflag = menu.get_option_by_name('computeage').get_value()
self.verbose = options_class.handler.options_dict['verbose'] self.dupperson = menu.get_option_by_name('omitda').get_value()
self.childRef = options_class.handler.options_dict['desref'] self.verbose = menu.get_option_by_name('verbose').get_value()
self.addImages = options_class.handler.options_dict['incphotos'] self.childref = menu.get_option_by_name('desref').get_value()
self.includeNames = options_class.handler.options_dict['incnames'] self.addimages = menu.get_option_by_name('incphotos').get_value()
self.includeEvents = options_class.handler.options_dict['incevents'] self.inc_names = menu.get_option_by_name('incnames').get_value()
self.includeAddr = options_class.handler.options_dict['incaddresses'] self.inc_events = menu.get_option_by_name('incevents').get_value()
self.includeSources= options_class.handler.options_dict['incsources'] self.inc_addr = menu.get_option_by_name('incaddresses').get_value()
self.includeAttrs = options_class.handler.options_dict['incattrs'] self.inc_sources = menu.get_option_by_name('incsources').get_value()
pid = options_class.handler.options_dict['pid'] self.inc_attrs = menu.get_option_by_name('incattrs').get_value()
pid = menu.get_option_by_name('pid').get_value()
self.center_person = database.get_person_from_gramps_id(pid) self.center_person = database.get_person_from_gramps_id(pid)
self.gen_handles = {} self.gen_handles = {}
self.prev_gen_handles = {} self.prev_gen_handles = {}
if self.blankDate: if blankdate:
self.EMPTY_DATE = EMPTY_ENTRY self.EMPTY_DATE = EMPTY_ENTRY
else: else:
self.EMPTY_DATE = "" self.EMPTY_DATE = ""
if self.blankPlace: if blankplace:
self.EMPTY_PLACE = EMPTY_ENTRY self.EMPTY_PLACE = EMPTY_ENTRY
else: else:
self.EMPTY_PLACE = "" self.EMPTY_PLACE = ""
@ -166,26 +167,26 @@ class DetAncestorReport(Report):
self.doc.write_text(text,mark) self.doc.write_text(text,mark)
self.doc.end_paragraph() self.doc.end_paragraph()
generation = generation + 1 generation = generation + 1
if self.childRef: if self.childref:
self.prev_gen_handles= self.gen_handles.copy() self.prev_gen_handles= self.gen_handles.copy()
self.gen_handles.clear() self.gen_handles.clear()
person_handle = self.map[key] person_handle = self.map[key]
person = self.database.get_person_from_handle(person_handle) person = self.database.get_person_from_handle(person_handle)
self.gen_handles[person_handle] = key self.gen_handles[person_handle] = key
dupPerson = self.write_person(key) dupperson = self.write_person(key)
if dupPerson == 0: # Is this a duplicate ind record if dupperson == 0: # Is this a duplicate ind record
if self.listChildren or self.includeEvents: if self.listchildren or self.inc_events:
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle) family = self.database.get_family_from_handle(family_handle)
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
if mother_handle == None or \ if mother_handle == None or \
person.get_gender() == gen.lib.Person.FEMALE: person.get_gender() == gen.lib.Person.FEMALE:
if self.listChildren: if self.listchildren:
self.write_children(family) self.write_children(family)
if self.includeEvents: if self.inc_events:
self.write_family_events(family) self.write_family_events(family)
if self.includeSources: if self.inc_sources:
Endnotes.write_endnotes(self.bibli,self.database,self.doc) Endnotes.write_endnotes(self.bibli,self.database,self.doc)
def write_person(self, key): def write_person(self, key):
@ -195,7 +196,7 @@ class DetAncestorReport(Report):
person = self.database.get_person_from_handle(person_handle) person = self.database.get_person_from_handle(person_handle)
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.database,self.doc,photo) ReportUtils.insert_image(self.database,self.doc,photo)
@ -212,7 +213,7 @@ class DetAncestorReport(Report):
self.doc.write_text("%s. " % self.endnotes(person)) self.doc.write_text("%s. " % self.endnotes(person))
self.doc.end_bold() self.doc.end_bold()
if self.dupPerson: if self.dupperson:
# Check for duplicate record (result of distant cousins marrying) # Check for duplicate record (result of distant cousins marrying)
keys = self.map.keys() keys = self.map.keys()
keys.sort() keys.sort()
@ -274,7 +275,7 @@ class DetAncestorReport(Report):
self.write_mate(person) self.write_mate(person)
notelist = person.get_note_list() notelist = person.get_note_list()
if len(notelist) > 0 and self.includeNotes: if len(notelist) > 0 and self.includenotes:
self.doc.start_paragraph("DAR-NoteHeader") self.doc.start_paragraph("DAR-NoteHeader")
self.doc.write_text(_("Notes for %s") % name) self.doc.write_text(_("Notes for %s") % name)
self.doc.end_paragraph() self.doc.end_paragraph()
@ -283,7 +284,7 @@ class DetAncestorReport(Report):
self.doc.write_note(note.get(),note.get_format(),"DAR-Entry") self.doc.write_note(note.get(),note.get_format(),"DAR-Entry")
first = True first = True
if self.includeNames: 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('DAR-MoreHeader') self.doc.start_paragraph('DAR-MoreHeader')
@ -301,7 +302,7 @@ class DetAncestorReport(Report):
}) })
self.doc.end_paragraph() self.doc.end_paragraph()
if self.includeEvents: if self.inc_events:
birth_ref = person.get_birth_ref() birth_ref = person.get_birth_ref()
death_ref = person.get_death_ref() death_ref = person.get_death_ref()
for event_ref in person.get_primary_event_ref_list(): for event_ref in person.get_primary_event_ref_list():
@ -317,7 +318,7 @@ class DetAncestorReport(Report):
self.write_event(event_ref) self.write_event(event_ref)
if self.includeAddr: if self.inc_addr:
for addr in person.get_address_list(): for addr in person.get_address_list():
if first: if first:
self.doc.start_paragraph('DAR-MoreHeader') self.doc.start_paragraph('DAR-MoreHeader')
@ -336,7 +337,7 @@ class DetAncestorReport(Report):
self.doc.write_text( self.endnotes(addr) ) self.doc.write_text( self.endnotes(addr) )
self.doc.end_paragraph() self.doc.end_paragraph()
if self.includeAttrs: 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('DAR-MoreHeader') self.doc.start_paragraph('DAR-MoreHeader')
@ -394,7 +395,7 @@ class DetAncestorReport(Report):
self.doc.write_text(text) self.doc.write_text(text)
if self.includeAttrs: if self.inc_attrs:
text = "" text = ""
attr_list = event.get_attribute_list() attr_list = event.get_attribute_list()
attr_list.extend(event_ref.get_attribute_list()) attr_list.extend(event_ref.get_attribute_list())
@ -410,7 +411,7 @@ class DetAncestorReport(Report):
self.doc.end_paragraph() self.doc.end_paragraph()
if self.includeNotes: if self.includenotes:
# if the event or event reference has a note attached to it, # if the event or event reference has a note attached to it,
# get the text and format it correctly # get the text and format it correctly
notelist = event.get_note_list() notelist = event.get_note_list()
@ -509,7 +510,7 @@ class DetAncestorReport(Report):
child_name = _nd.display(child) child_name = _nd.display(child)
child_mark = ReportUtils.get_person_mark(self.database,child) child_mark = ReportUtils.get_person_mark(self.database,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))
child_name += " [%s]" % value child_name += " [%s]" % value
@ -629,9 +630,9 @@ class DetAncestorReport(Report):
self.doc.end_paragraph() self.doc.end_paragraph()
if person_name and mate.get_gender()==gen.lib.Person.MALE: if person_name and mate.get_gender()==gen.lib.Person.MALE:
if self.listChildren: if self.listchildren:
self.write_children(family) self.write_children(family)
if self.includeEvents: if self.inc_events:
self.write_family_events(family) self.write_family_events(family)
def calc_age(self,ind): def calc_age(self,ind):
@ -645,13 +646,13 @@ class DetAncestorReport(Report):
months: 2 months: 2
days: 3 days: 3
""" """
if self.calcAgeFlag: if self.calcageflag:
return ReportUtils.old_calc_age(self.database,ind) return ReportUtils.old_calc_age(self.database,ind)
else: else:
return (0,0) return (0,0)
def endnotes(self,obj): def endnotes(self,obj):
if not obj or not self.includeSources: if not obj or not self.inc_sources:
return "" return ""
txt = Endnotes.cite_source(self.bibli,obj) txt = Endnotes.cite_source(self.bibli,obj)

@ -78,44 +78,45 @@ class DetDescendantReport(Report):
gen - Maximum number of generations to include. gen - Maximum number of generations to include.
pagebgg - Whether to include page breaks between generations. pagebgg - Whether to include page breaks between generations.
firstName - Whether to use first names instead of pronouns. firstName - Whether to use first names instead of pronouns.
fullDate - Whether to use full dates instead of just year. fulldate - Whether to use full dates instead of just year.
listChildren - Whether to list children. listchildren - Whether to list children.
includeMates - Whether to include information about spouses inc_mates - Whether to include information about spouses
includeNotes - Whether to include notes. inc_notes - Whether to include notes.
includeAttrs - Whether to include attributes inc_attrs - Whether to include attributes
blankPlace - Whether to replace missing Places with ___________. blankPlace - Whether to replace missing Places with ___________.
blankDate - Whether to replace missing Dates with ___________. blankDate - Whether to replace missing Dates with ___________.
calcAgeFlag - Whether to compute age. calcageflag - Whether to compute age.
dupPerson - Whether to omit duplicate ancestors (e.g. when distant cousins mary). dubperson - Whether to omit duplicate ancestors (e.g. when distant cousins mary).
verbose - Whether to use complete sentences verbose - Whether to use complete sentences
childRef - Whether to add descendant references in child list. childref - Whether to add descendant references in child list.
addImages - Whether to include images. addimages - Whether to include images.
pid - The Gramps ID of the center person for the report. pid - The Gramps ID of the center person for the report.
""" """
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
self.map = {} self.map = {}
self.max_generations = options_class.handler.options_dict['gen'] menu = options_class.menu
self.pgbrk = options_class.handler.options_dict['pagebbg'] self.max_generations = menu.get_option_by_name('gen').get_value()
self.fullDate = options_class.handler.options_dict['fulldates'] self.pgbrk = menu.get_option_by_name('pagebbg').get_value()
self.listChildren = options_class.handler.options_dict['listc'] self.fulldate = menu.get_option_by_name('fulldates').get_value()
self.includeNotes = options_class.handler.options_dict['incnotes'] self.listchildren = menu.get_option_by_name('listc').get_value()
self.usecall = options_class.handler.options_dict['usecall'] self.inc_notes = menu.get_option_by_name('incnotes').get_value()
self.blankPlace = options_class.handler.options_dict['repplace'] self.usecall = menu.get_option_by_name('usecall').get_value()
self.blankDate = options_class.handler.options_dict['repdate'] blankplace = menu.get_option_by_name('repplace').get_value()
self.calcAgeFlag = options_class.handler.options_dict['computeage'] blankdate = menu.get_option_by_name('repdate').get_value()
self.dupPerson = options_class.handler.options_dict['omitda'] self.calcageflag = menu.get_option_by_name('computeage').get_value()
self.verbose = options_class.handler.options_dict['verbose'] self.dubperson = menu.get_option_by_name('omitda').get_value()
self.childRef = options_class.handler.options_dict['desref'] self.verbose = menu.get_option_by_name('verbose').get_value()
self.addImages = options_class.handler.options_dict['incphotos'] self.childref = menu.get_option_by_name('desref').get_value()
self.includeNames = options_class.handler.options_dict['incnames'] self.addimages = menu.get_option_by_name('incphotos').get_value()
self.includeEvents = options_class.handler.options_dict['incevents'] self.inc_names = menu.get_option_by_name('incnames').get_value()
self.includeAddr = options_class.handler.options_dict['incaddresses'] self.inc_events = menu.get_option_by_name('incevents').get_value()
self.includeSources= options_class.handler.options_dict['incsources'] self.inc_addr = menu.get_option_by_name('incaddresses').get_value()
self.includeMates = options_class.handler.options_dict['incmates'] self.inc_sources = menu.get_option_by_name('incsources').get_value()
self.includeAttrs = options_class.handler.options_dict['incattrs'] self.inc_mates = menu.get_option_by_name('incmates').get_value()
pid = options_class.handler.options_dict['pid'] self.inc_attrs = menu.get_option_by_name('incattrs').get_value()
pid = menu.get_option_by_name('pid').get_value()
self.center_person = database.get_person_from_gramps_id(pid) self.center_person = database.get_person_from_gramps_id(pid)
self.gen_handles = {} self.gen_handles = {}
@ -123,12 +124,12 @@ class DetDescendantReport(Report):
self.gen_keys = [] self.gen_keys = []
self.henry = {} self.henry = {}
if self.blankDate: if blankdate:
self.EMPTY_DATE = EMPTY_ENTRY self.EMPTY_DATE = EMPTY_ENTRY
else: else:
self.EMPTY_DATE = "" self.EMPTY_DATE = ""
if self.blankPlace: if blankplace:
self.EMPTY_PLACE = EMPTY_ENTRY self.EMPTY_PLACE = EMPTY_ENTRY
else: else:
self.EMPTY_PLACE = "" self.EMPTY_PLACE = ""
@ -195,7 +196,7 @@ class DetDescendantReport(Report):
mark = BaseDoc.IndexMark(text,BaseDoc.INDEX_TYPE_TOC,2) mark = BaseDoc.IndexMark(text,BaseDoc.INDEX_TYPE_TOC,2)
self.doc.write_text(text,mark) self.doc.write_text(text,mark)
self.doc.end_paragraph() self.doc.end_paragraph()
if self.childRef: if self.childref:
self.prev_gen_handles = self.gen_handles.copy() self.prev_gen_handles = self.gen_handles.copy()
self.gen_handles.clear() self.gen_handles.clear()
@ -205,7 +206,7 @@ class DetDescendantReport(Report):
self.gen_handles[person_handle] = key self.gen_handles[person_handle] = key
self.write_person(key) self.write_person(key)
if self.includeSources: if self.inc_sources:
Endnotes.write_endnotes(self.bibli,self.database,self.doc) Endnotes.write_endnotes(self.bibli,self.database,self.doc)
def write_person(self, key): def write_person(self, key):
@ -228,7 +229,7 @@ class DetDescendantReport(Report):
self.doc.write_text("%s. " % self.endnotes(person)) self.doc.write_text("%s. " % self.endnotes(person))
self.doc.end_bold() self.doc.end_bold()
if self.dupPerson: if self.dubperson:
# Check for duplicate record (result of distant cousins marrying) # Check for duplicate record (result of distant cousins marrying)
keys = self.map.keys() keys = self.map.keys()
keys.sort() keys.sort()
@ -245,10 +246,10 @@ class DetDescendantReport(Report):
self.write_person_info(person) self.write_person_info(person)
if self.listChildren or self.includeEvents or self.includeMates: if self.listchildren or self.inc_events or self.inc_mates:
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle) family = self.database.get_family_from_handle(family_handle)
if self.includeMates: if self.inc_mates:
if person.get_gender() == gen.lib.Person.MALE: if person.get_gender() == gen.lib.Person.MALE:
mate_handle = family.get_mother_handle() mate_handle = family.get_mother_handle()
else: else:
@ -256,9 +257,9 @@ class DetDescendantReport(Report):
if mate_handle: if mate_handle:
mate = self.database.get_person_from_handle(mate_handle) mate = self.database.get_person_from_handle(mate_handle)
self.write_person_info(mate) self.write_person_info(mate)
if self.listChildren: if self.listchildren:
self.write_children(family) self.write_children(family)
if self.includeEvents: if self.inc_events:
self.write_family_events(family) self.write_family_events(family)
def write_event(self, event_ref): def write_event(self, event_ref):
@ -298,7 +299,7 @@ class DetDescendantReport(Report):
self.doc.write_text(text) self.doc.write_text(text)
if self.includeAttrs: if self.inc_attrs:
text = "" text = ""
attr_list = event.get_attribute_list() attr_list = event.get_attribute_list()
attr_list.extend(event_ref.get_attribute_list()) attr_list.extend(event_ref.get_attribute_list())
@ -314,7 +315,7 @@ class DetDescendantReport(Report):
self.doc.end_paragraph() self.doc.end_paragraph()
if self.includeNotes: if self.inc_notes:
# if the event or event reference has a note attached to it, # if the event or event reference has a note attached to it,
# get the text and format it correctly # get the text and format it correctly
notelist = event.get_note_list() notelist = event.get_note_list()
@ -414,7 +415,7 @@ class DetDescendantReport(Report):
child_name = _nd.display(child) child_name = _nd.display(child)
child_mark = ReportUtils.get_person_mark(self.database,child) child_mark = ReportUtils.get_person_mark(self.database,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))
child_name += " [%s]" % value child_name += " [%s]" % value
@ -470,7 +471,7 @@ class DetDescendantReport(Report):
name = _nd.display_formal(person) name = _nd.display_formal(person)
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.database,self.doc,photo) ReportUtils.insert_image(self.database,self.doc,photo)
@ -517,7 +518,7 @@ class DetDescendantReport(Report):
self.doc.end_paragraph() self.doc.end_paragraph()
notelist = person.get_note_list() notelist = person.get_note_list()
if len(notelist) > 0 and self.includeNotes: if len(notelist) > 0 and self.inc_notes:
self.doc.start_paragraph("DDR-NoteHeader") self.doc.start_paragraph("DDR-NoteHeader")
self.doc.write_text(_("Notes for %s") % name) self.doc.write_text(_("Notes for %s") % name)
self.doc.end_paragraph() self.doc.end_paragraph()
@ -526,7 +527,7 @@ class DetDescendantReport(Report):
self.doc.write_note(note.get(),note.get_format(),"DDR-Entry") self.doc.write_note(note.get(),note.get_format(),"DDR-Entry")
first = True first = True
if self.includeNames: 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')
@ -544,7 +545,7 @@ class DetDescendantReport(Report):
}) })
self.doc.end_paragraph() self.doc.end_paragraph()
if self.includeEvents: 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')
@ -555,7 +556,7 @@ class DetDescendantReport(Report):
self.write_event(event_ref) self.write_event(event_ref)
if self.includeAddr: if self.inc_addr:
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')
@ -574,7 +575,7 @@ class DetDescendantReport(Report):
self.doc.write_text( self.endnotes(addr) ) self.doc.write_text( self.endnotes(addr) )
self.doc.end_paragraph() self.doc.end_paragraph()
if self.includeAttrs: 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')
@ -603,13 +604,13 @@ class DetDescendantReport(Report):
months: 2 months: 2
days: 3 days: 3
""" """
if self.calcAgeFlag: if self.calcageflag:
return ReportUtils.old_calc_age(self.database, ind) return ReportUtils.old_calc_age(self.database, ind)
else: else:
return (0, 0) return (0, 0)
def endnotes(self, obj): def endnotes(self, obj):
if not obj or not self.includeSources: if not obj or not self.inc_sources:
return "" return ""
txt = Endnotes.cite_source(self.bibli, obj) txt = Endnotes.cite_source(self.bibli, obj)

@ -64,7 +64,8 @@ class EndOfLineReport(Report):
""" """
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
pid = options_class.handler.options_dict['pid'] menu = options_class.menu
pid = menu.get_option_by_name('pid').get_value()
self.center_person = database.get_person_from_gramps_id(pid) self.center_person = database.get_person_from_gramps_id(pid)
# eol_map is a map whose: # eol_map is a map whose:
@ -85,6 +86,9 @@ class EndOfLineReport(Report):
self.get_eol(self.center_person, 1, []) self.get_eol(self.center_person, 1, [])
def get_eol(self, person, gen, pedigree): def get_eol(self, person, gen, pedigree):
"""
Recursively find the end of the line for each person
"""
name = name_displayer.display(person) name = name_displayer.display(person)
pedigree = pedigree + [name] pedigree = pedigree + [name]
person_is_eol = False person_is_eol = False

@ -61,24 +61,25 @@ class FamilyGroup(Report):
includeAttrs - Whether to include attributes includeAttrs - Whether to include attributes
""" """
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
menu = options_class.menu
self.family_handle = None self.family_handle = None
family_id = options_class.handler.options_dict['family_id'] family_id = menu.get_option_by_name('family_id').get_value()
family = database.get_family_from_gramps_id(family_id) family = database.get_family_from_gramps_id(family_id)
self.family_handle = family.get_handle() self.family_handle = family.get_handle()
self.recursive = options_class.handler.options_dict['recursive'] self.recursive = menu.get_option_by_name('recursive').get_value()
self.missingInfo = options_class.handler.options_dict['missinginfo'] self.missingInfo = menu.get_option_by_name('missinginfo').get_value()
self.generations = options_class.handler.options_dict['generations'] self.generations = menu.get_option_by_name('generations').get_value()
self.incParEvents = options_class.handler.options_dict['incParEvents'] self.incParEvents = menu.get_option_by_name('incParEvents').get_value()
self.incParAddr = options_class.handler.options_dict['incParAddr'] self.incParAddr = menu.get_option_by_name('incParAddr').get_value()
self.incParNotes = options_class.handler.options_dict['incParNotes'] self.incParNotes = menu.get_option_by_name('incParNotes').get_value()
self.incParNames = options_class.handler.options_dict['incParNames'] self.incParNames = menu.get_option_by_name('incParNames').get_value()
self.incParMar = options_class.handler.options_dict['incParMar'] self.incParMar = menu.get_option_by_name('incParMar').get_value()
self.incRelDates = options_class.handler.options_dict['incRelDates'] self.incRelDates = menu.get_option_by_name('incRelDates').get_value()
self.incChiMar = options_class.handler.options_dict['incChiMar'] self.incChiMar = menu.get_option_by_name('incChiMar').get_value()
self.includeAttrs = options_class.handler.options_dict['incattrs'] self.includeAttrs = menu.get_option_by_name('incattrs').get_value()
def dump_parent_event(self,name,event): def dump_parent_event(self,name,event):
place = "" place = ""

@ -83,11 +83,12 @@ class FanChart(Report):
radial - Print radial texts roundabout or as upright as possible. radial - Print radial texts roundabout or as upright as possible.
""" """
self.max_generations = options_class.handler.options_dict['maxgen'] menu = options_class.menu
self.circle = options_class.handler.options_dict['circle'] self.max_generations = menu.get_option_by_name('maxgen').get_value()
self.background = options_class.handler.options_dict['background'] self.circle = menu.get_option_by_name('circle').get_value()
self.radial = options_class.handler.options_dict['radial'] self.background = menu.get_option_by_name('background').get_value()
pid = options_class.handler.options_dict['pid'] self.radial = menu.get_option_by_name('radial').get_value()
pid = menu.get_option_by_name('pid').get_value()
self.center_person = database.get_person_from_gramps_id(pid) self.center_person = database.get_person_from_gramps_id(pid)
self.background_style = [] self.background_style = []

@ -17,7 +17,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id: $ # $Id$
""" """
Generate an hourglass graph using the GraphViz generator. Generate an hourglass graph using the GraphViz generator.
@ -55,9 +55,11 @@ class HourGlassReport(Report):
""" """
Report.__init__(self, database, person, options_class) 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'] menu = options_class.menu
pid = options_class.handler.options_dict['pid'] self.max_descend = menu.get_option_by_name('maxdescend').get_value()
self.max_ascend = menu.get_option_by_name('maxascend').get_value()
pid = menu.get_option_by_name('pid').get_value()
self.center_person = database.get_person_from_gramps_id(pid) self.center_person = database.get_person_from_gramps_id(pid)
def write_report(self): def write_report(self):

@ -23,7 +23,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id: $ # $Id$
""" """
Create a relationship graph using Graphviz Create a relationship graph using Graphviz
@ -41,7 +41,7 @@ from TransUtils import sgettext as _
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import register_report, PersonFilterOption, \ from PluginUtils import register_report, FilterOption, \
EnumeratedListOption, BooleanOption, PersonOption EnumeratedListOption, BooleanOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ
@ -116,22 +116,22 @@ class RelGraphReport(Report):
} }
self.database = database self.database = database
options = options_class.handler.options_dict menu = options_class.menu
self.includeid = options['incid'] self.includeid = menu.get_option_by_name('incid').get_value()
self.includedates = options['incdate'] self.includedates = menu.get_option_by_name('incdate').get_value()
self.includeurl = options['url'] self.includeurl = menu.get_option_by_name('url').get_value()
self.includeimg = options['includeImages'] self.includeimg = menu.get_option_by_name('includeImages').get_value()
self.imgpos = options['imageOnTheSide'] self.imgpos = menu.get_option_by_name('imageOnTheSide').get_value()
self.adoptionsdashed = options['dashed'] self.adoptionsdashed = menu.get_option_by_name('dashed').get_value()
self.show_families = options['showfamily'] self.show_families = menu.get_option_by_name('showfamily').get_value()
self.just_years = options['justyears'] self.just_years = menu.get_option_by_name('justyears').get_value()
self.placecause = options['placecause'] self.placecause = menu.get_option_by_name('placecause').get_value()
self.colorize = options['color'] self.colorize = menu.get_option_by_name('color').get_value()
if self.colorize == 'colored': if self.colorize == 'colored':
self.colors = colored self.colors = colored
elif self.colorize == 'filled': elif self.colorize == 'filled':
self.colors = filled self.colors = filled
arrow_str = options['arrow'] arrow_str = menu.get_option_by_name('arrow').get_value()
if arrow_str.find('a') + 1: if arrow_str.find('a') + 1:
self.arrowheadstyle = 'normal' self.arrowheadstyle = 'normal'
else: else:
@ -142,10 +142,10 @@ class RelGraphReport(Report):
self.arrowtailstyle = 'none' self.arrowtailstyle = 'none'
filter_option = options_class.menu.get_option_by_name('filter') filter_option = options_class.menu.get_option_by_name('filter')
self.filter = filter_option.get_filter() self._filter = filter_option.get_filter()
def write_report(self): def write_report(self):
self.person_handles = self.filter.apply(self.database, self.person_handles = self._filter.apply(self.database,
self.database.get_person_handles(sort_handles=False)) self.database.get_person_handles(sort_handles=False))
if len(self.person_handles) > 1: if len(self.person_handles) > 1:
@ -428,17 +428,18 @@ class RelGraphOptions(MenuReportOptions):
category_name = _("Report Options") category_name = _("Report Options")
################################ ################################
self.__filter = FilterOption(_("Filter"), 0)
self.__filter.set_help(
_("Determines what people are included in the graph"))
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
self.__pid = PersonOption(_("Filter Person")) self.__pid = PersonOption(_("Filter Person"))
self.__pid.set_help(_("The center person for the filter")) self.__pid.set_help(_("The center person for the filter"))
menu.add_option(category_name, "pid", self.__pid) menu.add_option(category_name, "pid", self.__pid)
self.__pid.connect('value-changed', self.__update_filters) self.__pid.connect('value-changed', self.__update_filters)
self.__filter = PersonFilterOption(_("Filter"), 0)
self.__filter.set_help(
_("Determines what people are included in the graph"))
self.__update_filters() self.__update_filters()
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
incdate = BooleanOption( incdate = BooleanOption(
_("Include Birth, Marriage and Death dates"), True) _("Include Birth, Marriage and Death dates"), True)

@ -37,7 +37,7 @@ from gettext import gettext as _
import gen.lib import gen.lib
import BaseDoc import BaseDoc
import DateHandler import DateHandler
from PluginUtils import register_report, PersonFilterOption, BooleanOption, \ from PluginUtils import register_report, FilterOption, BooleanOption, \
PersonOption PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
@ -73,7 +73,8 @@ class IndivCompleteReport(Report):
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
self.use_srcs = options_class.handler.options_dict['cites'] menu = options_class.menu
self.use_srcs = menu.get_option_by_name('cites').get_value()
filter_option = options_class.menu.get_option_by_name('filter') filter_option = options_class.menu.get_option_by_name('filter')
self.filter = filter_option.get_filter() self.filter = filter_option.get_filter()
@ -345,35 +346,6 @@ class IndivCompleteReport(Report):
self.doc.start_paragraph('IDS-Normal') self.doc.start_paragraph('IDS-Normal')
self.doc.end_paragraph() self.doc.end_paragraph()
def write_sources(self):
keys = self.sref_map.keys()
if not keys:
return
self.doc.start_table("three","IDS-IndTable")
self.doc.start_row()
self.doc.start_cell("IDS-TableHead",2)
self.doc.start_paragraph("IDS-TableTitle")
self.doc.write_text(_("Sources"))
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
keys.sort()
for key in keys:
srcref = self.sref_map[key]
base = self.database.get_source_from_handle(
srcref.get_reference_handle())
self.doc.start_row()
self.doc.start_cell('IDS-NormalCell',2)
self.doc.start_paragraph("IDS-Normal","%d." % key)
self.doc.write_text(base.get_title())
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
self.doc.end_table()
def write_facts(self): def write_facts(self):
self.doc.start_table("two","IDS-IndTable") self.doc.start_table("two","IDS-IndTable")
self.doc.start_row() self.doc.start_row()
@ -540,17 +512,18 @@ class IndivCompleteOptions(MenuReportOptions):
category_name = _("Report Options") category_name = _("Report Options")
################################ ################################
self.__filter = FilterOption(_("Filter"), 0)
self.__filter.set_help(
_("Select the filter to be applied to the report"))
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
self.__pid = PersonOption(_("Filter Person")) self.__pid = PersonOption(_("Filter Person"))
self.__pid.set_help(_("The center person for the filter")) self.__pid.set_help(_("The center person for the filter"))
menu.add_option(category_name, "pid", self.__pid) menu.add_option(category_name, "pid", self.__pid)
self.__pid.connect('value-changed', self.__update_filters) self.__pid.connect('value-changed', self.__update_filters)
self.__filter = PersonFilterOption(_("Filter"), 0)
self.__filter.set_help(
_("Select the filter to be applied to the report"))
self.__update_filters() self.__update_filters()
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
cites = BooleanOption(_("Include Source Information"), True) cites = BooleanOption(_("Include Source Information"), True)
cites.set_help(_("Whether to cite sources.")) cites.set_help(_("Whether to cite sources."))

@ -72,16 +72,17 @@ class KinshipReport(Report):
""" """
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
self.max_descend = options_class.handler.options_dict['maxdescend'] menu = options_class.menu
self.max_ascend = options_class.handler.options_dict['maxascend'] self.max_descend = menu.get_option_by_name('maxdescend').get_value()
self.incSpouses = options_class.handler.options_dict['incspouses'] self.max_ascend = menu.get_option_by_name('maxascend').get_value()
self.incCousins = options_class.handler.options_dict['inccousins'] self.inc_spouses = menu.get_option_by_name('incspouses').get_value()
self.incAunts = options_class.handler.options_dict['incaunts'] self.inc_cousins = menu.get_option_by_name('inccousins').get_value()
pid = options_class.handler.options_dict['pid'] self.inc_aunts = menu.get_option_by_name('incaunts').get_value()
pid = menu.get_option_by_name('pid').get_value()
self.person = database.get_person_from_gramps_id(pid) self.person = database.get_person_from_gramps_id(pid)
self.db = database self.__db = database
self.relCalc = relationship_class() self.rel_calc = relationship_class()
self.kinship_map = {} self.kinship_map = {}
self.spouse_map = {} self.spouse_map = {}
@ -98,7 +99,7 @@ class KinshipReport(Report):
self.doc.write_text(title, mark) self.doc.write_text(title, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
if self.incSpouses: if self.inc_spouses:
spouse_handles = self.get_spouse_handles(self.person.get_handle()) spouse_handles = self.get_spouse_handles(self.person.get_handle())
if spouse_handles: if spouse_handles:
self.write_people(_("Spouses"), spouse_handles) self.write_people(_("Spouses"), spouse_handles)
@ -117,15 +118,15 @@ class KinshipReport(Report):
x = min (Ga,Gb) x = min (Ga,Gb)
y = abs(Ga-Gb) y = abs(Ga-Gb)
# Skip unrequested people # Skip unrequested people
if x == 1 and y > 0 and not self.incAunts: if x == 1 and y > 0 and not self.inc_aunts:
continue continue
elif x > 1 and not self.incCousins: elif x > 1 and not self.inc_cousins:
continue continue
title = self.relCalc.get_plural_relationship_string(Ga,Gb) title = self.rel_calc.get_plural_relationship_string(Ga,Gb)
self.write_people(title,self.kinship_map[Ga][Gb]) self.write_people(title,self.kinship_map[Ga][Gb])
if self.incSpouses and \ if self.inc_spouses and \
self.spouse_map.has_key(Ga) and \ self.spouse_map.has_key(Ga) and \
self.spouse_map[Ga].has_key(Gb): self.spouse_map[Ga].has_key(Gb):
title = _("spouses of %s") % title title = _("spouses of %s") % title
@ -153,7 +154,7 @@ class KinshipReport(Report):
if child_handle != skip_handle: if child_handle != skip_handle:
self.add_kin(child_handle,Ga,Gb) self.add_kin(child_handle,Ga,Gb)
if self.incSpouses: if self.inc_spouses:
for spouse_handle in self.get_spouse_handles(child_handle): for spouse_handle in self.get_spouse_handles(child_handle):
self.add_spouse(spouse_handle,Ga,Gb) self.add_spouse(spouse_handle,Ga,Gb)
@ -210,10 +211,10 @@ class KinshipReport(Report):
given person handle. given person handle.
""" """
parent_handles = [] parent_handles = []
person = self.db.get_person_from_handle(person_handle) person = self.__db.get_person_from_handle(person_handle)
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)
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if father_handle: if father_handle:
parent_handles.append(father_handle) parent_handles.append(father_handle)
@ -228,9 +229,9 @@ class KinshipReport(Report):
given person handle. given person handle.
""" """
spouses = [] spouses = []
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)
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
spouse_handle = None spouse_handle = None
@ -249,9 +250,9 @@ class KinshipReport(Report):
given person handle. given person handle.
""" """
children = [] children = []
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():
children.append(child_ref.get_reference_handle()) children.append(child_ref.get_reference_handle())
return children return children
@ -262,10 +263,10 @@ class KinshipReport(Report):
given person handle. given person handle.
""" """
siblings = [] siblings = []
person = self.db.get_person_from_handle(person_handle) person = self.__db.get_person_from_handle(person_handle)
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)
for child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
sibling_handle = child_ref.get_reference_handle() sibling_handle = child_ref.get_reference_handle()
if sibling_handle != person_handle: if sibling_handle != person_handle:

@ -66,7 +66,8 @@ class MarkerReport(Report):
marker - The marker each object must match to be included. marker - The marker each object must match to be included.
""" """
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
self.marker = options_class.handler.options_dict['marker'] menu = options_class.menu
self.marker = menu.get_option_by_name('marker').get_value()
def write_report(self): def write_report(self):
markerstr = self.marker markerstr = self.marker

@ -48,7 +48,7 @@ from gen.lib import Person, FamilyRelType, EventType
# gender and report type names # gender and report type names
import BaseDoc import BaseDoc
from PluginUtils import register_report from PluginUtils import register_report
from PluginUtils import BooleanOption, PersonFilterOption, PersonOption, \ from PluginUtils import BooleanOption, FilterOption, PersonOption, \
EnumeratedListOption, NumberOption EnumeratedListOption, NumberOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI
@ -389,7 +389,7 @@ class Extract:
chart[1][key] = 1 chart[1][key] = 1
def collect_data(self, db, filter_func, options, genders, def collect_data(self, db, filter_func, menu, genders,
year_from, year_to, no_years): year_from, year_to, no_years):
"""goes through the database and collects the selected personal """goes through the database and collects the selected personal
data persons fitting the filter and birth year criteria. The data persons fitting the filter and birth year criteria. The
@ -412,10 +412,10 @@ class Extract:
data = [] data = []
ext = self.extractors ext = self.extractors
# which methods to use # which methods to use
for key in options: for name in menu.get_all_option_names():
if options[key] and key in self.extractors: if name in self.extractors:
# localized data title, value dict, type and data method # localized data title, value dict, type and data method
data.append((ext[key][1], {}, ext[key][2], ext[key][3])) data.append((ext[name][1], {}, ext[name][2], ext[name][3]))
# go through the people and collect data # go through the people and collect data
for person_handle in filter_func.apply(db, db.get_person_handles(sort_handles=False)): for person_handle in filter_func.apply(db, db.get_person_handles(sort_handles=False)):
@ -476,11 +476,11 @@ class StatisticsChart(Report):
self.filter_option = options_class.menu.get_option_by_name('filter') self.filter_option = options_class.menu.get_option_by_name('filter')
self.filter = self.filter_option.get_filter() self.filter = self.filter_option.get_filter()
options = options_class.handler.options_dict menu = options_class.menu
self.bar_items = options['bar_items'] self.bar_items = menu.get_option_by_name('bar_items').get_value()
year_from = options['year_from'] year_from = menu.get_option_by_name('year_from').get_value()
year_to = options['year_to'] year_to = menu.get_option_by_name('year_to').get_value()
gender = options['gender'] gender = menu.get_option_by_name('gender').get_value()
# title needs both data extraction method name + gender name # title needs both data extraction method name + gender name
if gender == Person.MALE: if gender == Person.MALE:
@ -500,14 +500,15 @@ class StatisticsChart(Report):
# extract requested items from the database and count them # extract requested items from the database and count them
self.progress.set_pass(_('Collecting data...'), 1) self.progress.set_pass(_('Collecting data...'), 1)
tables = _Extract.collect_data(database, self.filter, options, tables = _Extract.collect_data(database, self.filter, menu,
gender, year_from, year_to, options['no_years']) gender, year_from, year_to,
menu.get_option_by_name('no_years').get_value())
self.progress.step() self.progress.step()
self.progress.set_pass(_('Sorting data...'), len(tables)) self.progress.set_pass(_('Sorting data...'), len(tables))
self.data = [] self.data = []
sortby = options['sortby'] sortby = menu.get_option_by_name('sortby').get_value()
reverse = options['reverse'] reverse = menu.get_option_by_name('reverse').get_value()
for table in tables: for table in tables:
# generate sorted item lookup index index # generate sorted item lookup index index
lookup = self.index_items(table[1], sortby, reverse) lookup = self.index_items(table[1], sortby, reverse)
@ -670,17 +671,18 @@ class StatisticsChartOptions(MenuReportOptions):
""" """
category_name = _("Report Options") category_name = _("Report Options")
self.__filter = FilterOption(_("Filter"), 0)
self.__filter.set_help(
_("Determines what people are included in the report"))
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
self.__pid = PersonOption(_("Filter Person")) self.__pid = PersonOption(_("Filter Person"))
self.__pid.set_help(_("The center person for the filter")) self.__pid.set_help(_("The center person for the filter"))
menu.add_option(category_name, "pid", self.__pid) menu.add_option(category_name, "pid", self.__pid)
self.__pid.connect('value-changed', self.__update_filters) self.__pid.connect('value-changed', self.__update_filters)
self.__filter = PersonFilterOption(_("Filter"), 0)
self.__filter.set_help(
_("Determines what people are included in the report"))
self.__update_filters() self.__update_filters()
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
sortby = EnumeratedListOption(_('Sort chart items by'), sortby = EnumeratedListOption(_('Sort chart items by'),
_options.SORT_VALUE ) _options.SORT_VALUE )

@ -38,13 +38,12 @@ from TransUtils import sgettext as _
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import register_report from PluginUtils import register_report
from PluginUtils import PersonFilterOption, EnumeratedListOption, \ from PluginUtils import FilterOption, EnumeratedListOption, \
PersonOption PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI
pt2cm = ReportUtils.pt2cm pt2cm = ReportUtils.pt2cm
import BaseDoc import BaseDoc
from Filters import GenericFilter, Rules
import Sort import Sort
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog
from BasicUtils import name_displayer from BasicUtils import name_displayer
@ -87,14 +86,12 @@ class TimeLine(Report):
""" """
Report.__init__(self, database, person, options_class) Report.__init__(self, database, person, options_class)
menu = options_class.menu
filter_num = options_class.handler.options_dict['filter'] self.filter = menu.get_option_by_name('filter').get_filter()
self.filter_option = options_class.menu.get_option_by_name('filter')
self.filter = self.filter_option.get_filter()
self.title = _("Timeline Graph for %s") % self.filter.get_name() self.title = _("Timeline Graph for %s") % self.filter.get_name()
sort_func_num = options_class.handler.options_dict['sortby'] sort_func_num = menu.get_option_by_name('sortby').get_value()
sort_functions = _get_sort_functions(Sort.Sort(database)) sort_functions = _get_sort_functions(Sort.Sort(database))
self.sort_func = sort_functions[sort_func_num][1] self.sort_func = sort_functions[sort_func_num][1]
@ -305,17 +302,18 @@ class TimeLineOptions(MenuReportOptions):
def add_menu_options(self,menu,dbstate): def add_menu_options(self,menu,dbstate):
category_name = _("Report Options") category_name = _("Report Options")
self.__filter = FilterOption(_("Filter"), 0)
self.__filter.set_help(
_("Determines what people are included in the report"))
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
self.__pid = PersonOption(_("Filter Person")) self.__pid = PersonOption(_("Filter Person"))
self.__pid.set_help(_("The center person for the filter")) self.__pid.set_help(_("The center person for the filter"))
menu.add_option(category_name, "pid", self.__pid) menu.add_option(category_name, "pid", self.__pid)
self.__pid.connect('value-changed', self.__update_filters) self.__pid.connect('value-changed', self.__update_filters)
self.__filter = PersonFilterOption(_("Filter"), 0)
self.__filter.set_help(
_("Determines what people are included in the report"))
self.__update_filters() self.__update_filters()
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
sortby = EnumeratedListOption(_('Sort by'), 0 ) sortby = EnumeratedListOption(_('Sort by'), 0 )
idx = 0 idx = 0