More refactoring in the report system. Book report should work again.
svn: r9916
This commit is contained in:
parent
f01bbb3bc9
commit
2f0d587bec
25
ChangeLog
25
ChangeLog
@ -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.
|
||||||
@ -74,16 +78,18 @@ 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):
|
||||||
"""
|
"""
|
||||||
Recursive function to walk back all parents of the current person.
|
Recursive function to walk back all parents of the current person.
|
||||||
When max_generations are hit, we stop the traversal.
|
When max_generations are hit, we stop the traversal.
|
||||||
@ -125,34 +131,36 @@ 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)
|
||||||
|
|
||||||
# Write the title line. Set in INDEX marker so that this section will be
|
# Write the title line. Set in INDEX marker so that this section will be
|
||||||
# identified as a major category if this is included in a Book report.
|
# identified as a major category if this is included in a Book report.
|
||||||
|
|
||||||
name = name_displayer.display_formal(self.center_person)
|
name = name_displayer.display_formal(self.center_person)
|
||||||
title = _("Ahnentafel Report for %s") % name
|
title = _("Ahnentafel Report for %s") % name
|
||||||
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC,1 )
|
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 1)
|
||||||
self.doc.start_paragraph("AHN-Title")
|
self.doc.start_paragraph("AHN-Title")
|
||||||
self.doc.write_text(title, mark)
|
self.doc.write_text(title, mark)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
@ -174,9 +182,9 @@ class AncestorReport(Report):
|
|||||||
generation += 1
|
generation += 1
|
||||||
|
|
||||||
# Create the Generation title, set an index marker
|
# Create the Generation title, set an index marker
|
||||||
mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,2)
|
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 2)
|
||||||
self.doc.start_paragraph("AHN-Generation")
|
self.doc.start_paragraph("AHN-Generation")
|
||||||
self.doc.write_text(_("Generation %d") % generation,mark)
|
self.doc.write_text(_("Generation %d") % generation, mark)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
|
|
||||||
# Build the entry
|
# Build the entry
|
||||||
@ -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()
|
||||||
|
|
||||||
@ -225,10 +236,10 @@ class AncestorOptions(MenuReportOptions):
|
|||||||
Defines options and provides handling interface.
|
Defines options and provides handling interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,name,dbstate=None):
|
def __init__(self, name, dbstate=None):
|
||||||
MenuReportOptions.__init__(self,name,dbstate)
|
MenuReportOptions.__init__(self, name, dbstate)
|
||||||
|
|
||||||
def add_menu_options(self,menu,dbstate):
|
def add_menu_options(self, menu, dbstate):
|
||||||
"""
|
"""
|
||||||
Add options to the menu for the ancestor report.
|
Add options to the menu for the ancestor report.
|
||||||
"""
|
"""
|
||||||
@ -236,21 +247,22 @@ class AncestorOptions(MenuReportOptions):
|
|||||||
|
|
||||||
pid = PersonOption(_("Center Person"))
|
pid = PersonOption(_("Center Person"))
|
||||||
pid.set_help(_("The center person for the report"))
|
pid.set_help(_("The center person for the report"))
|
||||||
menu.add_option(category_name,"pid",pid)
|
menu.add_option(category_name, "pid", pid)
|
||||||
|
|
||||||
maxgen = NumberOption(_("Generations"),10,1,15)
|
maxgen = NumberOption(_("Generations"), 10, 1, 15)
|
||||||
maxgen.set_help(_("The number of generations to include in the report"))
|
maxgen.set_help(_("The number of generations to include in the report"))
|
||||||
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(
|
||||||
menu.add_option(category_name,"pagebbg",pagebbg)
|
_("Whether to start a new page after each generation."))
|
||||||
|
menu.add_option(category_name, "pagebbg", pagebbg)
|
||||||
|
|
||||||
namebrk = BooleanOption(_("Add linebreak after each name"),False)
|
namebrk = BooleanOption(_("Add linebreak after each name"), False)
|
||||||
namebrk.set_help(_("Indicates if a line break should follow the name."))
|
namebrk.set_help(_("Indicates if a line break should follow the name."))
|
||||||
menu.add_option(category_name,"namebrk",namebrk)
|
menu.add_option(category_name, "namebrk", namebrk)
|
||||||
|
|
||||||
def make_default_style(self,default_style):
|
def make_default_style(self, default_style):
|
||||||
"""
|
"""
|
||||||
Make the default output style for the Ahnentafel report.
|
Make the default output style for the Ahnentafel report.
|
||||||
|
|
||||||
@ -284,7 +296,7 @@ class AncestorOptions(MenuReportOptions):
|
|||||||
# AHN-Title
|
# AHN-Title
|
||||||
#
|
#
|
||||||
font = BaseDoc.FontStyle()
|
font = BaseDoc.FontStyle()
|
||||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=16,bold=1)
|
font.set(face=BaseDoc.FONT_SANS_SERIF, size=16, bold=1)
|
||||||
para = BaseDoc.ParagraphStyle()
|
para = BaseDoc.ParagraphStyle()
|
||||||
para.set_font(font)
|
para.set_font(font)
|
||||||
para.set_header_level(1)
|
para.set_header_level(1)
|
||||||
@ -292,30 +304,30 @@ class AncestorOptions(MenuReportOptions):
|
|||||||
para.set_bottom_margin(0.25)
|
para.set_bottom_margin(0.25)
|
||||||
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||||
para.set_description(_('The style used for the title of the page.'))
|
para.set_description(_('The style used for the title of the page.'))
|
||||||
default_style.add_paragraph_style("AHN-Title",para)
|
default_style.add_paragraph_style("AHN-Title", para)
|
||||||
|
|
||||||
#
|
#
|
||||||
# AHN-Generation
|
# AHN-Generation
|
||||||
#
|
#
|
||||||
font = BaseDoc.FontStyle()
|
font = BaseDoc.FontStyle()
|
||||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
font.set(face=BaseDoc.FONT_SANS_SERIF, size=14, italic=1)
|
||||||
para = BaseDoc.ParagraphStyle()
|
para = BaseDoc.ParagraphStyle()
|
||||||
para.set_font(font)
|
para.set_font(font)
|
||||||
para.set_header_level(2)
|
para.set_header_level(2)
|
||||||
para.set_top_margin(0.125)
|
para.set_top_margin(0.125)
|
||||||
para.set_bottom_margin(0.125)
|
para.set_bottom_margin(0.125)
|
||||||
para.set_description(_('The style used for the generation header.'))
|
para.set_description(_('The style used for the generation header.'))
|
||||||
default_style.add_paragraph_style("AHN-Generation",para)
|
default_style.add_paragraph_style("AHN-Generation", para)
|
||||||
|
|
||||||
#
|
#
|
||||||
# AHN-Entry
|
# AHN-Entry
|
||||||
#
|
#
|
||||||
para = BaseDoc.ParagraphStyle()
|
para = BaseDoc.ParagraphStyle()
|
||||||
para.set(first_indent=-1.0,lmargin=1.0)
|
para.set(first_indent=-1.0, lmargin=1.0)
|
||||||
para.set_top_margin(0.125)
|
para.set_top_margin(0.125)
|
||||||
para.set_bottom_margin(0.125)
|
para.set_bottom_margin(0.125)
|
||||||
para.set_description(_('The basic style used for the text display.'))
|
para.set_description(_('The basic style used for the text display.'))
|
||||||
default_style.add_paragraph_style("AHN-Entry",para)
|
default_style.add_paragraph_style("AHN-Entry", para)
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -46,9 +46,9 @@ log = logging.getLogger(".BookReport")
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
try:
|
try:
|
||||||
from xml.sax import make_parser,handler,SAXParseException
|
from xml.sax import make_parser, handler, SAXParseException
|
||||||
except:
|
except:
|
||||||
from _xmlplus.sax import make_parser,handler,SAXParseException
|
from _xmlplus.sax import make_parser, handler, SAXParseException
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -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")
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -124,7 +177,7 @@ class BookItem:
|
|||||||
Interface into the book item -- a smallest element of the book.
|
Interface into the book item -- a smallest element of the book.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,dbstate,name=None):
|
def __init__(self, dbstate, name=None):
|
||||||
"""
|
"""
|
||||||
Creates a new empty BookItem.
|
Creates a new empty BookItem.
|
||||||
|
|
||||||
@ -152,7 +205,7 @@ class BookItem:
|
|||||||
self.make_default_style = None
|
self.make_default_style = None
|
||||||
self.name = ""
|
self.name = ""
|
||||||
|
|
||||||
def get_registered_item(self,name):
|
def get_registered_item(self, name):
|
||||||
"""
|
"""
|
||||||
Retrieve the item from the book item registry.
|
Retrieve the item from the book item registry.
|
||||||
|
|
||||||
@ -169,7 +222,7 @@ class BookItem:
|
|||||||
self.category = item[1]
|
self.category = item[1]
|
||||||
self.write_item = item[2]
|
self.write_item = item[2]
|
||||||
self.name = item[4]
|
self.name = item[4]
|
||||||
self.option_class = item[3](self.name,self.dbstate)
|
self.option_class = item[3](self.name, self.dbstate)
|
||||||
self.option_class.load_previous_values()
|
self.option_class.load_previous_values()
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
@ -196,7 +249,7 @@ class BookItem:
|
|||||||
"""
|
"""
|
||||||
return self.write_item
|
return self.write_item
|
||||||
|
|
||||||
def set_style_name(self,style_name):
|
def set_style_name(self, style_name):
|
||||||
"""
|
"""
|
||||||
Sets the style name for the item.
|
Sets the style name for the item.
|
||||||
|
|
||||||
@ -232,7 +285,7 @@ class Book:
|
|||||||
Interface into the user-defined book -- a collection of book items.
|
Interface into the user-defined book -- a collection of book items.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,obj=None):
|
def __init__(self, obj=None):
|
||||||
"""
|
"""
|
||||||
Creates a new empty Book.
|
Creates a new empty Book.
|
||||||
|
|
||||||
@ -247,7 +300,7 @@ class Book:
|
|||||||
else:
|
else:
|
||||||
self.item_list = []
|
self.item_list = []
|
||||||
|
|
||||||
def set_name(self,name):
|
def set_name(self, name):
|
||||||
"""
|
"""
|
||||||
Sets the name of the book.
|
Sets the name of the book.
|
||||||
|
|
||||||
@ -267,7 +320,7 @@ class Book:
|
|||||||
"""
|
"""
|
||||||
return self.dbname
|
return self.dbname
|
||||||
|
|
||||||
def set_dbname(self,name):
|
def set_dbname(self, name):
|
||||||
"""
|
"""
|
||||||
Sets the name of the database file used for the book.
|
Sets the name of the database file used for the book.
|
||||||
|
|
||||||
@ -281,7 +334,7 @@ class Book:
|
|||||||
"""
|
"""
|
||||||
self.item_list = []
|
self.item_list = []
|
||||||
|
|
||||||
def append_item(self,item):
|
def append_item(self, item):
|
||||||
"""
|
"""
|
||||||
Adds an item to the book.
|
Adds an item to the book.
|
||||||
|
|
||||||
@ -289,16 +342,16 @@ class Book:
|
|||||||
"""
|
"""
|
||||||
self.item_list.append(item)
|
self.item_list.append(item)
|
||||||
|
|
||||||
def insert_item(self,index,item):
|
def insert_item(self, index, item):
|
||||||
"""
|
"""
|
||||||
Inserts an item into the given position in the book.
|
Inserts an item into the given position in the book.
|
||||||
|
|
||||||
index: a position index.
|
index: a position index.
|
||||||
item: an item to append.
|
item: an item to append.
|
||||||
"""
|
"""
|
||||||
self.item_list.insert(index,item)
|
self.item_list.insert(index, item)
|
||||||
|
|
||||||
def pop_item(self,index):
|
def pop_item(self, index):
|
||||||
"""
|
"""
|
||||||
Pop an item from given position in the book.
|
Pop an item from given position in the book.
|
||||||
|
|
||||||
@ -306,7 +359,7 @@ class Book:
|
|||||||
"""
|
"""
|
||||||
return self.item_list.pop(index)
|
return self.item_list.pop(index)
|
||||||
|
|
||||||
def get_item(self,index):
|
def get_item(self, index):
|
||||||
"""
|
"""
|
||||||
Returns an item at a given position in the book.
|
Returns an item at a given position in the book.
|
||||||
|
|
||||||
@ -314,7 +367,7 @@ class Book:
|
|||||||
"""
|
"""
|
||||||
return self.item_list[index]
|
return self.item_list[index]
|
||||||
|
|
||||||
def set_item(self,index,item):
|
def set_item(self, index, item):
|
||||||
"""
|
"""
|
||||||
Sets an item at a given position in the book.
|
Sets an item at a given position in the book.
|
||||||
|
|
||||||
@ -341,7 +394,7 @@ class BookList:
|
|||||||
BookList is loaded from a specified XML file if it exists.
|
BookList is loaded from a specified XML file if it exists.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,filename,dbstate):
|
def __init__(self, filename, dbstate):
|
||||||
"""
|
"""
|
||||||
Creates a new BookList from the books that may be defined in the
|
Creates a new BookList from the books that may be defined in the
|
||||||
specified file.
|
specified file.
|
||||||
@ -350,10 +403,10 @@ class BookList:
|
|||||||
"""
|
"""
|
||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
self.bookmap = {}
|
self.bookmap = {}
|
||||||
self.file = os.path.join(const.HOME_DIR,filename)
|
self.file = os.path.join(const.HOME_DIR, filename)
|
||||||
self.parse()
|
self.parse()
|
||||||
|
|
||||||
def delete_book(self,name):
|
def delete_book(self, name):
|
||||||
"""
|
"""
|
||||||
Removes a book from the list. Since each book must have a
|
Removes a book from the list. Since each book must have a
|
||||||
unique name, the name is used to delete the book.
|
unique name, the name is used to delete the book.
|
||||||
@ -368,7 +421,7 @@ class BookList:
|
|||||||
"""
|
"""
|
||||||
return self.bookmap
|
return self.bookmap
|
||||||
|
|
||||||
def get_book(self,name):
|
def get_book(self, name):
|
||||||
"""
|
"""
|
||||||
Returns the Book associated with the name
|
Returns the Book associated with the name
|
||||||
|
|
||||||
@ -380,7 +433,7 @@ class BookList:
|
|||||||
"Returns a list of all the book names in the BookList"
|
"Returns a list of all the book names in the BookList"
|
||||||
return self.bookmap.keys()
|
return self.bookmap.keys()
|
||||||
|
|
||||||
def set_book(self,name,book):
|
def set_book(self, name, book):
|
||||||
"""
|
"""
|
||||||
Adds or replaces a Book in the BookList.
|
Adds or replaces a Book in the BookList.
|
||||||
|
|
||||||
@ -393,21 +446,21 @@ class BookList:
|
|||||||
"""
|
"""
|
||||||
Saves the current BookList to the associated file.
|
Saves the current BookList to the associated file.
|
||||||
"""
|
"""
|
||||||
f = open(self.file,"w")
|
f = open(self.file, "w")
|
||||||
f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||||
f.write('<booklist>\n')
|
f.write('<booklist>\n')
|
||||||
|
|
||||||
for name in self.bookmap.keys():
|
for name in self.bookmap.keys():
|
||||||
book = self.get_book(name)
|
book = self.get_book(name)
|
||||||
dbname = book.get_dbname()
|
dbname = book.get_dbname()
|
||||||
f.write('<book name="%s" database="%s">\n' % (name,dbname) )
|
f.write('<book name="%s" database="%s">\n' % (name, dbname) )
|
||||||
for item in book.get_item_list():
|
for item in book.get_item_list():
|
||||||
f.write(' <item name="%s" trans_name="%s">\n' %
|
f.write(' <item name="%s" trans_name="%s">\n' %
|
||||||
(item.get_name(),item.get_translated_name() ) )
|
(item.get_name(),item.get_translated_name() ) )
|
||||||
option_handler = item.option_class.handler
|
option_handler = item.option_class.handler
|
||||||
for option_name in option_handler.options_dict.keys():
|
for option_name in option_handler.options_dict.keys():
|
||||||
option_value = option_handler.options_dict[option_name]
|
option_value = option_handler.options_dict[option_name]
|
||||||
if type(option_value) in (list,tuple):
|
if type(option_value) in (list, tuple):
|
||||||
f.write(' <option name="%s" length="%d">\n' % (
|
f.write(' <option name="%s" length="%d">\n' % (
|
||||||
option_name, len(option_value) ) )
|
option_name, len(option_value) ) )
|
||||||
for list_index in range(len(option_value)):
|
for list_index in range(len(option_value)):
|
||||||
@ -434,7 +487,7 @@ class BookList:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
p = make_parser()
|
p = make_parser()
|
||||||
p.setContentHandler(BookParser(self,self.dbstate))
|
p.setContentHandler(BookParser(self, self.dbstate))
|
||||||
the_file = open(self.file)
|
the_file = open(self.file)
|
||||||
p.parse(the_file)
|
p.parse(the_file)
|
||||||
the_file.close()
|
the_file.close()
|
||||||
@ -452,7 +505,7 @@ class BookParser(handler.ContentHandler):
|
|||||||
SAX parsing class for the Books XML file.
|
SAX parsing class for the Books XML file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,booklist,dbstate):
|
def __init__(self, booklist, dbstate):
|
||||||
"""
|
"""
|
||||||
Creates a BookParser class that populates the passed booklist.
|
Creates a BookParser class that populates the passed booklist.
|
||||||
|
|
||||||
@ -471,7 +524,7 @@ class BookParser(handler.ContentHandler):
|
|||||||
self.bname = None
|
self.bname = None
|
||||||
self.iname = None
|
self.iname = None
|
||||||
|
|
||||||
def startElement(self,tag,attrs):
|
def startElement(self, tag, attrs):
|
||||||
"""
|
"""
|
||||||
Overridden class that handles the start of a XML element
|
Overridden class that handles the start of a XML element
|
||||||
"""
|
"""
|
||||||
@ -482,7 +535,7 @@ class BookParser(handler.ContentHandler):
|
|||||||
self.dbname = attrs['database']
|
self.dbname = attrs['database']
|
||||||
self.b.set_dbname(self.dbname)
|
self.b.set_dbname(self.dbname)
|
||||||
elif tag == "item":
|
elif tag == "item":
|
||||||
self.i = BookItem(self.dbstate,attrs['name'])
|
self.i = BookItem(self.dbstate, attrs['name'])
|
||||||
self.o = {}
|
self.o = {}
|
||||||
elif tag == "option":
|
elif tag == "option":
|
||||||
self.an_o_name = attrs['name']
|
self.an_o_name = attrs['name']
|
||||||
@ -499,7 +552,7 @@ class BookParser(handler.ContentHandler):
|
|||||||
elif tag == "person":
|
elif tag == "person":
|
||||||
self.p = attrs['gramps_id']
|
self.p = attrs['gramps_id']
|
||||||
|
|
||||||
def endElement(self,tag):
|
def endElement(self, tag):
|
||||||
"Overridden class that handles the end of a XML element"
|
"Overridden class that handles the end of a XML element"
|
||||||
if tag == "option":
|
if tag == "option":
|
||||||
self.o[self.an_o_name] = self.an_o_value
|
self.o[self.an_o_name] = self.an_o_value
|
||||||
@ -509,7 +562,7 @@ class BookParser(handler.ContentHandler):
|
|||||||
self.i.set_style_name(self.s)
|
self.i.set_style_name(self.s)
|
||||||
self.b.append_item(self.i)
|
self.b.append_item(self.i)
|
||||||
elif tag == "book":
|
elif tag == "book":
|
||||||
self.booklist.set_book(self.bname,self.b)
|
self.booklist.set_book(self.bname, self.b)
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -523,7 +576,7 @@ class BookListDisplay:
|
|||||||
Allows the user to select and/or delete a book from the list.
|
Allows the user to select and/or delete a book from the list.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,booklist,nodelete=0,dosave=0):
|
def __init__(self, booklist, nodelete=0, dosave=0):
|
||||||
"""
|
"""
|
||||||
Creates a BookListDisplay object that displays the books in BookList.
|
Creates a BookListDisplay object that displays the books in BookList.
|
||||||
|
|
||||||
@ -536,7 +589,7 @@ class BookListDisplay:
|
|||||||
self.dosave = dosave
|
self.dosave = dosave
|
||||||
base = os.path.dirname(__file__)
|
base = os.path.dirname(__file__)
|
||||||
glade_file = os.path.join(base,"book.glade")
|
glade_file = os.path.join(base,"book.glade")
|
||||||
self.xml = gtk.glade.XML(glade_file,"booklist","gramps")
|
self.xml = gtk.glade.XML(glade_file, "booklist", "gramps")
|
||||||
self.top = self.xml.get_widget('booklist')
|
self.top = self.xml.get_widget('booklist')
|
||||||
|
|
||||||
ManagedWindow.set_titles(self.top,
|
ManagedWindow.set_titles(self.top,
|
||||||
@ -574,30 +627,30 @@ class BookListDisplay:
|
|||||||
if the_iter:
|
if the_iter:
|
||||||
self.blist.selection.select_iter(the_iter)
|
self.blist.selection.select_iter(the_iter)
|
||||||
|
|
||||||
def on_booklist_ok_clicked(self,obj):
|
def on_booklist_ok_clicked(self, obj):
|
||||||
"""Returns selected book. Saves the current list into xml file."""
|
"""Returns selected book. Saves the current list into xml file."""
|
||||||
store,the_iter = self.blist.get_selected()
|
store, the_iter = self.blist.get_selected()
|
||||||
if the_iter:
|
if the_iter:
|
||||||
data = self.blist.get_data(the_iter,[0])
|
data = self.blist.get_data(the_iter, [0])
|
||||||
self.selection = self.booklist.get_book(unicode(data[0]))
|
self.selection = self.booklist.get_book(unicode(data[0]))
|
||||||
if self.dosave:
|
if self.dosave:
|
||||||
self.booklist.save()
|
self.booklist.save()
|
||||||
|
|
||||||
def on_booklist_delete_clicked(self,obj):
|
def on_booklist_delete_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Deletes selected book from the list.
|
Deletes selected book from the list.
|
||||||
|
|
||||||
This change is not final. OK button has to be clicked to save the list.
|
This change is not final. OK button has to be clicked to save the list.
|
||||||
"""
|
"""
|
||||||
store,the_iter = self.blist.get_selected()
|
store, the_iter = self.blist.get_selected()
|
||||||
if not the_iter:
|
if not the_iter:
|
||||||
return
|
return
|
||||||
data = self.blist.get_data(the_iter,[0])
|
data = self.blist.get_data(the_iter, [0])
|
||||||
self.booklist.delete_book(data[0])
|
self.booklist.delete_book(data[0])
|
||||||
self.blist.remove(the_iter)
|
self.blist.remove(the_iter)
|
||||||
self.top.run()
|
self.top.run()
|
||||||
|
|
||||||
def on_booklist_cancel_clicked(self,obj):
|
def on_booklist_cancel_clicked(self, obj):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -611,8 +664,8 @@ class BookOptions(ReportOptions):
|
|||||||
Defines options and provides handling interface.
|
Defines options and provides handling interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,name,person_id=None):
|
def __init__(self, name, person_id=None):
|
||||||
ReportOptions.__init__(self,name,person_id)
|
ReportOptions.__init__(self, name, person_id)
|
||||||
|
|
||||||
# Options specific for this report
|
# Options specific for this report
|
||||||
self.options_dict = {
|
self.options_dict = {
|
||||||
@ -637,7 +690,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
|
|||||||
and to clear/load/save/edit whole books.
|
and to clear/load/save/edit whole books.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,dbstate,uistate,person):
|
def __init__(self, dbstate, uistate, person):
|
||||||
self.db = dbstate.db
|
self.db = dbstate.db
|
||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
@ -645,15 +698,15 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
|
|||||||
self.title = _('Book Report')
|
self.title = _('Book Report')
|
||||||
self.file = "books.xml"
|
self.file = "books.xml"
|
||||||
|
|
||||||
ManagedWindow.ManagedWindow.__init__(self,uistate, [], self.__class__)
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||||
|
|
||||||
base = os.path.dirname(__file__)
|
base = os.path.dirname(__file__)
|
||||||
glade_file = os.path.join(base,"book.glade")
|
glade_file = os.path.join(base,"book.glade")
|
||||||
|
|
||||||
self.xml = gtk.glade.XML(glade_file,"top","gramps")
|
self.xml = gtk.glade.XML(glade_file, "top", "gramps")
|
||||||
window = self.xml.get_widget("top")
|
window = self.xml.get_widget("top")
|
||||||
title_label = self.xml.get_widget('title')
|
title_label = self.xml.get_widget('title')
|
||||||
self.set_window(window,title_label,self.title)
|
self.set_window(window, title_label, self.title)
|
||||||
|
|
||||||
self.xml.signal_autoconnect({
|
self.xml.signal_autoconnect({
|
||||||
"on_add_clicked" : self.on_add_clicked,
|
"on_add_clicked" : self.on_add_clicked,
|
||||||
@ -671,8 +724,8 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
|
|||||||
|
|
||||||
self.avail_tree = self.xml.get_widget("avail_tree")
|
self.avail_tree = self.xml.get_widget("avail_tree")
|
||||||
self.book_tree = self.xml.get_widget("book_tree")
|
self.book_tree = self.xml.get_widget("book_tree")
|
||||||
self.avail_tree.connect('button-press-event',self.av_button_press)
|
self.avail_tree.connect('button-press-event', self.av_button_press)
|
||||||
self.book_tree.connect('button-press-event',self.bk_button_press)
|
self.book_tree.connect('button-press-event', self.bk_button_press)
|
||||||
|
|
||||||
self.name_entry = self.xml.get_widget("name_entry")
|
self.name_entry = self.xml.get_widget("name_entry")
|
||||||
self.name_entry.set_text(_('New Book'))
|
self.name_entry.set_text(_('New Book'))
|
||||||
@ -686,21 +739,26 @@ 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 ),
|
||||||
(_('Subject'),-1,50)]
|
( '' , -1, 0 ) ]
|
||||||
|
|
||||||
|
bk_titles = [ (_('Item name'), -1, 150),
|
||||||
|
(_('Type'), -1, 50 ),
|
||||||
|
( '', -1, 0 ),
|
||||||
|
(_('Subject'), -1, 50 ) ]
|
||||||
|
|
||||||
self.av_ncols = len(av_titles)
|
self.av_ncols = len(av_titles)
|
||||||
self.bk_ncols = len(bk_titles)
|
self.bk_ncols = len(bk_titles)
|
||||||
|
|
||||||
self.av_model = ListModel.ListModel(self.avail_tree,av_titles)
|
self.av_model = ListModel.ListModel(self.avail_tree, av_titles)
|
||||||
self.bk_model = ListModel.ListModel(self.book_tree,bk_titles)
|
self.bk_model = ListModel.ListModel(self.book_tree, bk_titles)
|
||||||
self.draw_avail_list()
|
self.draw_avail_list()
|
||||||
|
|
||||||
self.book = Book()
|
self.book = Book()
|
||||||
|
|
||||||
def build_menu_names(self,obj):
|
def build_menu_names(self, obj):
|
||||||
return (_("Book selection list"),self.title)
|
return (_("Book selection list"), self.title)
|
||||||
|
|
||||||
def draw_avail_list(self):
|
def draw_avail_list(self):
|
||||||
"""
|
"""
|
||||||
@ -727,9 +785,9 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
|
|||||||
self.av_model.selection.select_iter(new_iter)
|
self.av_model.selection.select_iter(new_iter)
|
||||||
path = self.av_model.model.get_path(new_iter)
|
path = self.av_model.model.get_path(new_iter)
|
||||||
col = self.avail_tree.get_column(0)
|
col = self.avail_tree.get_column(0)
|
||||||
self.avail_tree.scroll_to_cell(path,col,1,1,0.0)
|
self.avail_tree.scroll_to_cell(path, col, 1, 1, 0.0)
|
||||||
|
|
||||||
def open_book(self,book):
|
def open_book(self, book):
|
||||||
"""
|
"""
|
||||||
Open the book: set the current set of selections to this book's items.
|
Open the book: set the current set of selections to this book's items.
|
||||||
|
|
||||||
@ -751,101 +809,104 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
|
|||||||
self.bk_model.clear()
|
self.bk_model.clear()
|
||||||
for saved_item in book.get_item_list():
|
for saved_item in book.get_item_list():
|
||||||
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)
|
||||||
|
|
||||||
data = [ item.get_translated_name(),
|
data = [ item.get_translated_name(),
|
||||||
item.get_category(), item.get_name() ]
|
item.get_category(), item.get_name() ]
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
def on_add_clicked(self,obj):
|
def on_add_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Add an item to the current selections.
|
Add an item to the current selections.
|
||||||
|
|
||||||
Use the selected available item to get the item's name in the registry.
|
Use the selected available item to get the item's name in the registry.
|
||||||
"""
|
"""
|
||||||
store,the_iter = self.av_model.get_selected()
|
store, the_iter = self.av_model.get_selected()
|
||||||
if not the_iter:
|
if not the_iter:
|
||||||
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])
|
||||||
data[2] = _get_subject(item.option_class,self.db)
|
_initialize_options(item.option_class, self.dbstate)
|
||||||
|
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)
|
||||||
|
|
||||||
def on_remove_clicked(self,obj):
|
def on_remove_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Remove the item from the current list of selections.
|
Remove the item from the current list of selections.
|
||||||
"""
|
"""
|
||||||
store,the_iter = self.bk_model.get_selected()
|
store, the_iter = self.bk_model.get_selected()
|
||||||
if not the_iter:
|
if not the_iter:
|
||||||
return
|
return
|
||||||
row = self.bk_model.get_selected_row()
|
row = self.bk_model.get_selected_row()
|
||||||
self.book.pop_item(row)
|
self.book.pop_item(row)
|
||||||
self.bk_model.remove(the_iter)
|
self.bk_model.remove(the_iter)
|
||||||
|
|
||||||
def on_clear_clicked(self,obj):
|
def on_clear_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Clear the whole current book.
|
Clear the whole current book.
|
||||||
"""
|
"""
|
||||||
self.bk_model.clear()
|
self.bk_model.clear()
|
||||||
self.book.clear()
|
self.book.clear()
|
||||||
|
|
||||||
def on_up_clicked(self,obj):
|
def on_up_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Move the currently selected item one row up in the selection list.
|
Move the currently selected item one row up in the selection list.
|
||||||
"""
|
"""
|
||||||
row = self.bk_model.get_selected_row()
|
row = self.bk_model.get_selected_row()
|
||||||
if not row or row == -1:
|
if not row or row == -1:
|
||||||
return
|
return
|
||||||
store,the_iter = self.bk_model.get_selected()
|
store, the_iter = self.bk_model.get_selected()
|
||||||
data = self.bk_model.get_data(the_iter,range(self.bk_ncols))
|
data = self.bk_model.get_data(the_iter, range(self.bk_ncols))
|
||||||
self.bk_model.remove(the_iter)
|
self.bk_model.remove(the_iter)
|
||||||
self.bk_model.insert(row-1,data,None,1)
|
self.bk_model.insert(row-1, data, None, 1)
|
||||||
item = self.book.pop_item(row)
|
item = self.book.pop_item(row)
|
||||||
self.book.insert_item(row-1,item)
|
self.book.insert_item(row-1, item)
|
||||||
|
|
||||||
def on_down_clicked(self,obj):
|
def on_down_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Move the currently selected item one row down in the selection list.
|
Move the currently selected item one row down in the selection list.
|
||||||
"""
|
"""
|
||||||
row = self.bk_model.get_selected_row()
|
row = self.bk_model.get_selected_row()
|
||||||
if row + 1 >= self.bk_model.count or row == -1:
|
if row + 1 >= self.bk_model.count or row == -1:
|
||||||
return
|
return
|
||||||
store,the_iter = self.bk_model.get_selected()
|
store, the_iter = self.bk_model.get_selected()
|
||||||
data = self.bk_model.get_data(the_iter,range(self.bk_ncols))
|
data = self.bk_model.get_data(the_iter, range(self.bk_ncols))
|
||||||
self.bk_model.remove(the_iter)
|
self.bk_model.remove(the_iter)
|
||||||
self.bk_model.insert(row+1,data,None,1)
|
self.bk_model.insert(row+1, data, None, 1)
|
||||||
item = self.book.pop_item(row)
|
item = self.book.pop_item(row)
|
||||||
self.book.insert_item(row+1,item)
|
self.book.insert_item(row+1, item)
|
||||||
|
|
||||||
def on_setup_clicked(self,obj):
|
def on_setup_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Configure currently selected item.
|
Configure currently selected item.
|
||||||
"""
|
"""
|
||||||
store,the_iter = self.bk_model.get_selected()
|
store, the_iter = self.bk_model.get_selected()
|
||||||
if not the_iter:
|
if not the_iter:
|
||||||
return
|
return
|
||||||
data = self.bk_model.get_data(the_iter,range(self.bk_ncols))
|
data = self.bk_model.get_data(the_iter, range(self.bk_ncols))
|
||||||
row = self.bk_model.get_selected_row()
|
row = self.bk_model.get_selected_row()
|
||||||
item = self.book.get_item(row)
|
item = self.book.get_item(row)
|
||||||
option_class = item.option_class
|
option_class = item.option_class
|
||||||
item_dialog = BookItemDialog(self.dbstate,self.uistate,option_class,
|
item_dialog = BookItemDialog(self.dbstate, self.uistate, option_class,
|
||||||
item.get_name(),
|
item.get_name(),
|
||||||
item.get_translated_name(),
|
item.get_translated_name(),
|
||||||
self.track)
|
self.track)
|
||||||
response = item_dialog.window.run()
|
response = item_dialog.window.run()
|
||||||
if response == RESPONSE_OK:
|
if response == RESPONSE_OK:
|
||||||
subject = _get_subject(option_class,self.db)
|
_initialize_options(option_class, self.dbstate)
|
||||||
self.bk_model.model.set_value(the_iter,2,subject)
|
subject = _get_subject(option_class, self.db)
|
||||||
self.book.set_item(row,item)
|
self.bk_model.model.set_value(the_iter, 2, subject)
|
||||||
|
self.book.set_item(row, item)
|
||||||
item_dialog.close()
|
item_dialog.close()
|
||||||
|
|
||||||
def bk_button_press(self,obj,event):
|
def bk_button_press(self, obj, event):
|
||||||
"""
|
"""
|
||||||
Double-click on the current book selection is the same as setup.
|
Double-click on the current book selection is the same as setup.
|
||||||
Right click evokes the context menu.
|
Right click evokes the context menu.
|
||||||
@ -855,7 +916,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
|
|||||||
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||||
self.build_bk_context_menu(event)
|
self.build_bk_context_menu(event)
|
||||||
|
|
||||||
def av_button_press(self,obj,event):
|
def av_button_press(self, obj, event):
|
||||||
"""
|
"""
|
||||||
Double-click on the available selection is the same as add.
|
Double-click on the available selection is the same as add.
|
||||||
Right click evokes the context menu.
|
Right click evokes the context menu.
|
||||||
@ -865,10 +926,10 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
|
|||||||
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||||
self.build_av_context_menu(event)
|
self.build_av_context_menu(event)
|
||||||
|
|
||||||
def build_bk_context_menu(self,event):
|
def build_bk_context_menu(self, event):
|
||||||
"""Builds the menu with item-centered and book-centered options."""
|
"""Builds the menu with item-centered and book-centered options."""
|
||||||
|
|
||||||
store,the_iter = self.bk_model.get_selected()
|
store, the_iter = self.bk_model.get_selected()
|
||||||
if the_iter:
|
if the_iter:
|
||||||
sensitivity = 1
|
sensitivity = 1
|
||||||
else:
|
else:
|
||||||
@ -887,19 +948,19 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
|
|||||||
|
|
||||||
menu = gtk.Menu()
|
menu = gtk.Menu()
|
||||||
menu.set_title(_('Book Menu'))
|
menu.set_title(_('Book Menu'))
|
||||||
for stock_id,callback,sensitivity in entries:
|
for stock_id, callback, sensitivity in entries:
|
||||||
item = gtk.ImageMenuItem(stock_id)
|
item = gtk.ImageMenuItem(stock_id)
|
||||||
if callback:
|
if callback:
|
||||||
item.connect("activate",callback)
|
item.connect("activate", callback)
|
||||||
item.set_sensitive(sensitivity)
|
item.set_sensitive(sensitivity)
|
||||||
item.show()
|
item.show()
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
menu.popup(None,None,None,event.button,event.time)
|
menu.popup(None, None, None, event.button, event.time)
|
||||||
|
|
||||||
def build_av_context_menu(self,event):
|
def build_av_context_menu(self, event):
|
||||||
"""Builds the menu with the single Add option."""
|
"""Builds the menu with the single Add option."""
|
||||||
|
|
||||||
store,the_iter = self.av_model.get_selected()
|
store, the_iter = self.av_model.get_selected()
|
||||||
if the_iter:
|
if the_iter:
|
||||||
sensitivity = 1
|
sensitivity = 1
|
||||||
else:
|
else:
|
||||||
@ -910,53 +971,53 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
|
|||||||
|
|
||||||
menu = gtk.Menu()
|
menu = gtk.Menu()
|
||||||
menu.set_title(_('Available Items Menu'))
|
menu.set_title(_('Available Items Menu'))
|
||||||
for stock_id,callback,sensitivity in entries:
|
for stock_id, callback, sensitivity in entries:
|
||||||
item = gtk.ImageMenuItem(stock_id)
|
item = gtk.ImageMenuItem(stock_id)
|
||||||
if callback:
|
if callback:
|
||||||
item.connect("activate",callback)
|
item.connect("activate", callback)
|
||||||
item.set_sensitive(sensitivity)
|
item.set_sensitive(sensitivity)
|
||||||
item.show()
|
item.show()
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
menu.popup(None,None,None,event.button,event.time)
|
menu.popup(None, None, None, event.button, event.time)
|
||||||
|
|
||||||
def on_book_ok_clicked(self,obj):
|
def on_book_ok_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Run final BookReportDialog with the current book.
|
Run final BookReportDialog with the current book.
|
||||||
"""
|
"""
|
||||||
if self.book.item_list:
|
if self.book.item_list:
|
||||||
BookReportDialog(self.dbstate,self.uistate,self.person,
|
BookReportDialog(self.dbstate, self.uistate, self.person,
|
||||||
self.book,BookOptions)
|
self.book, BookOptions)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def on_save_clicked(self,obj):
|
def on_save_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
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())
|
||||||
self.book_list.set_book(name,self.book)
|
self.book_list.set_book(name, self.book)
|
||||||
self.book_list.save()
|
self.book_list.save()
|
||||||
|
|
||||||
def on_open_clicked(self,obj):
|
def on_open_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Run the BookListDisplay dialog to present the choice of books to open.
|
Run the BookListDisplay dialog to present the choice of books to open.
|
||||||
"""
|
"""
|
||||||
self.book_list = BookList(self.file,self.dbstate)
|
self.book_list = BookList(self.file, self.dbstate)
|
||||||
booklistdisplay = BookListDisplay(self.book_list,1,0)
|
booklistdisplay = BookListDisplay(self.book_list, 1, 0)
|
||||||
booklistdisplay.top.destroy()
|
booklistdisplay.top.destroy()
|
||||||
book = booklistdisplay.selection
|
book = booklistdisplay.selection
|
||||||
if book:
|
if book:
|
||||||
self.open_book(book)
|
self.open_book(book)
|
||||||
self.name_entry.set_text(book.get_name())
|
self.name_entry.set_text(book.get_name())
|
||||||
|
|
||||||
def on_edit_clicked(self,obj):
|
def on_edit_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Run the BookListDisplay dialog to present the choice of books to delete.
|
Run the BookListDisplay dialog to present the choice of books to delete.
|
||||||
"""
|
"""
|
||||||
self.book_list = BookList(self.file,self.dbstate)
|
self.book_list = BookList(self.file, self.dbstate)
|
||||||
booklistdisplay = BookListDisplay(self.book_list,0,1)
|
booklistdisplay = BookListDisplay(self.book_list, 0, 1)
|
||||||
booklistdisplay.top.destroy()
|
booklistdisplay.top.destroy()
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -971,13 +1032,13 @@ class BookItemDialog(BareReportDialog):
|
|||||||
in a way specific for this report. This is a book item dialog.
|
in a way specific for this report. This is a book item dialog.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,dbstate,uistate,option_class,name,translated_name,
|
def __init__(self, dbstate, uistate, option_class, name, translated_name,
|
||||||
track=[]):
|
track=[]):
|
||||||
|
|
||||||
self.database = dbstate.db
|
self.database = dbstate.db
|
||||||
self.option_class = option_class
|
self.option_class = option_class
|
||||||
BareReportDialog.__init__(self,dbstate,uistate,None,
|
BareReportDialog.__init__(self, dbstate, uistate, None,
|
||||||
option_class,name,translated_name,track)
|
option_class, name, translated_name, track)
|
||||||
|
|
||||||
def on_ok_clicked(self, obj):
|
def on_ok_clicked(self, obj):
|
||||||
"""The user is satisfied with the dialog choices. Parse all options
|
"""The user is satisfied with the dialog choices. Parse all options
|
||||||
@ -1001,11 +1062,11 @@ class BookReportDialog(DocReportDialog):
|
|||||||
Creates a dialog selecting target, format, and paper/HTML options.
|
Creates a dialog selecting target, format, and paper/HTML options.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,dbstate,uistate,person,book,options):
|
def __init__(self, dbstate, uistate, person, book, options):
|
||||||
self.options = options
|
self.options = options
|
||||||
self.page_html_added = False
|
self.page_html_added = False
|
||||||
DocReportDialog.__init__(self,dbstate,uistate,person,options,
|
DocReportDialog.__init__(self, dbstate, uistate, person, options,
|
||||||
'book',_("Book Report"))
|
'book', _("Book Report"))
|
||||||
self.book = book
|
self.book = book
|
||||||
self.database = dbstate.db
|
self.database = dbstate.db
|
||||||
self.person = person
|
self.person = person
|
||||||
@ -1019,7 +1080,7 @@ class BookReportDialog(DocReportDialog):
|
|||||||
|
|
||||||
# Read all style sheets available for this item
|
# Read all style sheets available for this item
|
||||||
style_file = item.option_class.handler.get_stylesheet_savefile()
|
style_file = item.option_class.handler.get_stylesheet_savefile()
|
||||||
style_list = BaseDoc.StyleSheetList(style_file,default_style)
|
style_list = BaseDoc.StyleSheetList(style_file, default_style)
|
||||||
|
|
||||||
# Get the selected stylesheet
|
# Get the selected stylesheet
|
||||||
style_name = item.option_class.handler.get_default_stylesheet_name()
|
style_name = item.option_class.handler.get_default_stylesheet_name()
|
||||||
@ -1066,7 +1127,7 @@ class BookReportDialog(DocReportDialog):
|
|||||||
"""Needed solely for forming sane filename for the output."""
|
"""Needed solely for forming sane filename for the output."""
|
||||||
return "book.xml"
|
return "book.xml"
|
||||||
|
|
||||||
def make_doc_menu(self,active=None):
|
def make_doc_menu(self, active=None):
|
||||||
"""Build a menu of document types that are appropriate for
|
"""Build a menu of document types that are appropriate for
|
||||||
this text report. This menu will be generated based upon
|
this text report. This menu will be generated based upon
|
||||||
whether the document requires table support, etc."""
|
whether the document requires table support, etc."""
|
||||||
@ -1083,8 +1144,8 @@ class BookReportDialog(DocReportDialog):
|
|||||||
for item in self.book.get_item_list():
|
for item in self.book.get_item_list():
|
||||||
item.option_class.set_document(self.doc)
|
item.option_class.set_document(self.doc)
|
||||||
report_class = item.get_write_item()
|
report_class = item.get_write_item()
|
||||||
obj = write_book_item(self.database,self.person,
|
obj = write_book_item(self.database, self.person,
|
||||||
report_class,item.option_class)
|
report_class, item.option_class)
|
||||||
self.rptlist.append(obj)
|
self.rptlist.append(obj)
|
||||||
self.doc.open(self.target_path)
|
self.doc.open(self.target_path)
|
||||||
|
|
||||||
@ -1110,16 +1171,16 @@ class BookReportDialog(DocReportDialog):
|
|||||||
# Function to write books from command line
|
# Function to write books from command line
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
def cl_report(database,name,category,options_str_dict):
|
def cl_report(database, name, category, options_str_dict):
|
||||||
|
|
||||||
clr = CommandLineReport(database,name,category,
|
clr = CommandLineReport(database, name, category,
|
||||||
BookOptions,options_str_dict)
|
BookOptions, options_str_dict)
|
||||||
|
|
||||||
# Exit here if show option was given
|
# Exit here if show option was given
|
||||||
if clr.show:
|
if clr.show:
|
||||||
return
|
return
|
||||||
|
|
||||||
book_list = BookList('books.xml',None)
|
book_list = BookList('books.xml', None)
|
||||||
book_name = clr.options_dict['bookname']
|
book_name = clr.options_dict['bookname']
|
||||||
book = book_list.get_book(book_name)
|
book = book_list.get_book(book_name)
|
||||||
selected_style = BaseDoc.StyleSheet()
|
selected_style = BaseDoc.StyleSheet()
|
||||||
@ -1132,24 +1193,25 @@ def cl_report(database,name,category,options_str_dict):
|
|||||||
|
|
||||||
# Read all style sheets available for this item
|
# Read all style sheets available for this item
|
||||||
style_file = item.option_class.handler.get_stylesheet_savefile()
|
style_file = item.option_class.handler.get_stylesheet_savefile()
|
||||||
style_list = BaseDoc.StyleSheetList(style_file,default_style)
|
style_list = BaseDoc.StyleSheetList(style_file, default_style)
|
||||||
|
|
||||||
# Get the selected stylesheet
|
# Get the selected stylesheet
|
||||||
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)
|
||||||
rptlist = []
|
rptlist = []
|
||||||
for item in book.get_item_list():
|
for item in book.get_item_list():
|
||||||
item.option_class.set_document(doc)
|
item.option_class.set_document(doc)
|
||||||
report_class = item.get_write_item()
|
report_class = item.get_write_item()
|
||||||
obj = write_book_item(database,clr.person,
|
obj = write_book_item(database, clr.person,
|
||||||
report_class,item.option_class)
|
report_class, item.option_class)
|
||||||
rptlist.append(obj)
|
rptlist.append(obj)
|
||||||
|
|
||||||
doc.open(clr.option_class.get_output())
|
doc.open(clr.option_class.get_output())
|
||||||
@ -1168,20 +1230,20 @@ def cl_report(database,name,category,options_str_dict):
|
|||||||
# Generic task function for book report
|
# Generic task function for book report
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
def write_book_item(database,person,report_class,options_class):
|
def write_book_item(database, person, report_class, options_class):
|
||||||
"""Write the Timeline Graph using options set.
|
"""Write the Timeline Graph using options set.
|
||||||
All user dialog has already been handled and the output file opened."""
|
All user dialog has already been handled and the output file opened."""
|
||||||
try:
|
try:
|
||||||
if options_class.handler.get_person_id():
|
if options_class.handler.get_person_id():
|
||||||
person = database.get_person_from_gramps_id(
|
person = database.get_person_from_gramps_id(
|
||||||
options_class.handler.get_person_id())
|
options_class.handler.get_person_id())
|
||||||
return report_class(database,person,options_class)
|
return report_class(database, person, options_class)
|
||||||
except Errors.ReportError, msg:
|
except Errors.ReportError, msg:
|
||||||
(m1,m2) = msg.messages()
|
(m1, m2) = msg.messages()
|
||||||
ErrorDialog(m1,m2)
|
ErrorDialog(m1, m2)
|
||||||
except Errors.FilterError, msg:
|
except Errors.FilterError, msg:
|
||||||
(m1,m2) = msg.messages()
|
(m1, m2) = msg.messages()
|
||||||
ErrorDialog(m1,m2)
|
ErrorDialog(m1, m2)
|
||||||
except:
|
except:
|
||||||
log.error("Failed to write book item.", exc_info=True)
|
log.error("Failed to write book item.", exc_info=True)
|
||||||
return None
|
return None
|
||||||
|
@ -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
|
||||||
@ -120,32 +120,34 @@ class Calendar(Report):
|
|||||||
"""
|
"""
|
||||||
Creates the Calendar object that produces the report.
|
Creates the Calendar object that produces the 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():
|
||||||
|
@ -69,11 +69,12 @@ class CustomText(Report):
|
|||||||
mid - Text in the middle.
|
mid - Text in the middle.
|
||||||
bot - Text on the bottom.
|
bot - Text on the bottom.
|
||||||
"""
|
"""
|
||||||
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
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -119,13 +118,14 @@ class DescendChart(Report):
|
|||||||
singlep - Whether to scale to fit on a single page.
|
singlep - Whether to scale to fit on a single page.
|
||||||
maxgen - Maximum number of generations to include.
|
maxgen - Maximum number of generations to include.
|
||||||
"""
|
"""
|
||||||
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.')
|
||||||
|
|
||||||
@ -63,7 +53,7 @@ _DIED = _('d.')
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class DescendantReport(Report):
|
class DescendantReport(Report):
|
||||||
|
|
||||||
def __init__(self,database,person,options_class):
|
def __init__(self, database, person, options_class):
|
||||||
"""
|
"""
|
||||||
Creates the DescendantReport object that produces the report.
|
Creates the DescendantReport object that produces the report.
|
||||||
|
|
||||||
@ -80,10 +70,11 @@ 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
|
||||||
|
@ -60,7 +60,7 @@ EMPTY_ENTRY = "_____________"
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class DetAncestorReport(Report):
|
class DetAncestorReport(Report):
|
||||||
|
|
||||||
def __init__(self,database,person,options_class):
|
def __init__(self, database, person, options_class):
|
||||||
"""
|
"""
|
||||||
Creates the DetAncestorReport object that produces the report.
|
Creates the DetAncestorReport object that produces the report.
|
||||||
|
|
||||||
@ -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)
|
||||||
|
@ -62,7 +62,7 @@ HENRY = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class DetDescendantReport(Report):
|
class DetDescendantReport(Report):
|
||||||
|
|
||||||
def __init__(self,database,person,options_class):
|
def __init__(self, database, person, options_class):
|
||||||
"""
|
"""
|
||||||
Creates the DetDescendantReport object that produces the report.
|
Creates the DetDescendantReport object that produces the report.
|
||||||
|
|
||||||
@ -78,57 +78,58 @@ 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 = {}
|
||||||
self.prev_gen_handles= {}
|
self.prev_gen_handles = {}
|
||||||
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,16 +604,16 @@ 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)
|
||||||
if txt:
|
if txt:
|
||||||
txt = '<super>' + txt + '</super>'
|
txt = '<super>' + txt + '</super>'
|
||||||
return txt
|
return txt
|
||||||
|
@ -62,9 +62,10 @@ class EndOfLineReport(Report):
|
|||||||
that come in the options class.
|
that come in the options class.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
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:
|
||||||
@ -82,9 +83,12 @@ class EndOfLineReport(Report):
|
|||||||
#
|
#
|
||||||
# eol_map is populated by get_eol() which calls itself recursively.
|
# eol_map is populated by get_eol() which calls itself recursively.
|
||||||
self.eol_map = {}
|
self.eol_map = {}
|
||||||
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
|
||||||
@ -99,10 +103,10 @@ class EndOfLineReport(Report):
|
|||||||
mother_handle = family.get_mother_handle()
|
mother_handle = family.get_mother_handle()
|
||||||
if father_handle:
|
if father_handle:
|
||||||
father = self.database.get_person_from_handle(father_handle)
|
father = self.database.get_person_from_handle(father_handle)
|
||||||
self.get_eol(father,gen+1,pedigree)
|
self.get_eol(father, gen+1, pedigree)
|
||||||
if mother_handle:
|
if mother_handle:
|
||||||
mother = self.database.get_person_from_handle(mother_handle)
|
mother = self.database.get_person_from_handle(mother_handle)
|
||||||
self.get_eol(mother,gen+1,pedigree)
|
self.get_eol(mother, gen+1, pedigree)
|
||||||
|
|
||||||
if not father_handle or not mother_handle:
|
if not father_handle or not mother_handle:
|
||||||
person_is_eol = True
|
person_is_eol = True
|
||||||
@ -128,8 +132,8 @@ class EndOfLineReport(Report):
|
|||||||
|
|
||||||
self.doc.start_paragraph("EOL-Title")
|
self.doc.start_paragraph("EOL-Title")
|
||||||
title = _("End of Line Report for %s") % pname
|
title = _("End of Line Report for %s") % pname
|
||||||
mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1)
|
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 1)
|
||||||
self.doc.write_text(title,mark)
|
self.doc.write_text(title, mark)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
|
|
||||||
self.doc.start_paragraph("EOL-Subtitle")
|
self.doc.start_paragraph("EOL-Subtitle")
|
||||||
@ -147,19 +151,19 @@ class EndOfLineReport(Report):
|
|||||||
self.write_pedigree_row(pedigree)
|
self.write_pedigree_row(pedigree)
|
||||||
self.doc.end_table()
|
self.doc.end_table()
|
||||||
|
|
||||||
def write_generation_row(self,generation):
|
def write_generation_row(self, generation):
|
||||||
"""
|
"""
|
||||||
Write out a row in the table showing the generation.
|
Write out a row in the table showing the generation.
|
||||||
"""
|
"""
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell('EOL_GenerationCell',2)
|
self.doc.start_cell('EOL_GenerationCell', 2)
|
||||||
self.doc.start_paragraph('EOL-Generation')
|
self.doc.start_paragraph('EOL-Generation')
|
||||||
self.doc.write_text( _("Generation %d") % generation )
|
self.doc.write_text( _("Generation %d") % generation )
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
self.doc.end_cell()
|
self.doc.end_cell()
|
||||||
self.doc.end_row()
|
self.doc.end_row()
|
||||||
|
|
||||||
def write_person_row(self,person_handle):
|
def write_person_row(self, person_handle):
|
||||||
"""
|
"""
|
||||||
Write a row in the table with information about the given person.
|
Write a row in the table with information about the given person.
|
||||||
"""
|
"""
|
||||||
@ -183,15 +187,15 @@ class EndOfLineReport(Report):
|
|||||||
'death_date' : death_date }
|
'death_date' : death_date }
|
||||||
|
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell('EOL-TableCell',2)
|
self.doc.start_cell('EOL-TableCell', 2)
|
||||||
self.doc.start_paragraph('EOL-Normal')
|
self.doc.start_paragraph('EOL-Normal')
|
||||||
self.doc.write_text(name,mark)
|
self.doc.write_text(name, mark)
|
||||||
self.doc.write_text(dates)
|
self.doc.write_text(dates)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
self.doc.end_cell()
|
self.doc.end_cell()
|
||||||
self.doc.end_row()
|
self.doc.end_row()
|
||||||
|
|
||||||
def write_pedigree_row(self,pedigree):
|
def write_pedigree_row(self, pedigree):
|
||||||
"""
|
"""
|
||||||
Write a row in the table with with the person's family line.
|
Write a row in the table with with the person's family line.
|
||||||
|
|
||||||
@ -218,10 +222,10 @@ class EndOfLineOptions(MenuReportOptions):
|
|||||||
Defines options and provides handling interface.
|
Defines options and provides handling interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,name,dbstate=None):
|
def __init__(self, name, dbstate=None):
|
||||||
MenuReportOptions.__init__(self,name,dbstate)
|
MenuReportOptions.__init__(self, name, dbstate)
|
||||||
|
|
||||||
def add_menu_options(self,menu,dbstate):
|
def add_menu_options(self, menu, dbstate):
|
||||||
"""
|
"""
|
||||||
Add options to the menu for the End of Line report.
|
Add options to the menu for the End of Line report.
|
||||||
"""
|
"""
|
||||||
@ -231,7 +235,7 @@ class EndOfLineOptions(MenuReportOptions):
|
|||||||
pid.set_help(_("The center person for the report"))
|
pid.set_help(_("The center person for the report"))
|
||||||
menu.add_option(category_name, "pid", pid)
|
menu.add_option(category_name, "pid", pid)
|
||||||
|
|
||||||
def make_default_style(self,default_style):
|
def make_default_style(self, default_style):
|
||||||
"""Make the default output style for the End of Line Report."""
|
"""Make the default output style for the End of Line Report."""
|
||||||
# Paragraph Styles
|
# Paragraph Styles
|
||||||
f = BaseDoc.FontStyle()
|
f = BaseDoc.FontStyle()
|
||||||
@ -245,16 +249,16 @@ class EndOfLineOptions(MenuReportOptions):
|
|||||||
p.set_font(f)
|
p.set_font(f)
|
||||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||||
p.set_description(_("The style used for the title of the page."))
|
p.set_description(_("The style used for the title of the page."))
|
||||||
default_style.add_paragraph_style("EOL-Title",p)
|
default_style.add_paragraph_style("EOL-Title", p)
|
||||||
|
|
||||||
font = BaseDoc.FontStyle()
|
font = BaseDoc.FontStyle()
|
||||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=12,italic=1)
|
font.set(face=BaseDoc.FONT_SANS_SERIF, size=12, italic=1)
|
||||||
p = BaseDoc.ParagraphStyle()
|
p = BaseDoc.ParagraphStyle()
|
||||||
p.set_bottom_margin(ReportUtils.pt2cm(6))
|
p.set_bottom_margin(ReportUtils.pt2cm(6))
|
||||||
p.set_font(font)
|
p.set_font(font)
|
||||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||||
p.set_description(_('The style used for the section headers.'))
|
p.set_description(_('The style used for the section headers.'))
|
||||||
default_style.add_paragraph_style("EOL-Subtitle",p)
|
default_style.add_paragraph_style("EOL-Subtitle", p)
|
||||||
|
|
||||||
font = BaseDoc.FontStyle()
|
font = BaseDoc.FontStyle()
|
||||||
font.set_size(10)
|
font.set_size(10)
|
||||||
@ -263,7 +267,7 @@ class EndOfLineOptions(MenuReportOptions):
|
|||||||
p.set_top_margin(ReportUtils.pt2cm(6))
|
p.set_top_margin(ReportUtils.pt2cm(6))
|
||||||
p.set_bottom_margin(ReportUtils.pt2cm(6))
|
p.set_bottom_margin(ReportUtils.pt2cm(6))
|
||||||
p.set_description(_('The basic style used for the text display.'))
|
p.set_description(_('The basic style used for the text display.'))
|
||||||
default_style.add_paragraph_style("EOL-Normal",p)
|
default_style.add_paragraph_style("EOL-Normal", p)
|
||||||
|
|
||||||
font = BaseDoc.FontStyle()
|
font = BaseDoc.FontStyle()
|
||||||
font.set_size(12)
|
font.set_size(12)
|
||||||
@ -272,7 +276,7 @@ class EndOfLineOptions(MenuReportOptions):
|
|||||||
p.set_font(font)
|
p.set_font(font)
|
||||||
p.set_top_margin(ReportUtils.pt2cm(6))
|
p.set_top_margin(ReportUtils.pt2cm(6))
|
||||||
p.set_description(_('The basic style used for generation headings.'))
|
p.set_description(_('The basic style used for generation headings.'))
|
||||||
default_style.add_paragraph_style("EOL-Generation",p)
|
default_style.add_paragraph_style("EOL-Generation", p)
|
||||||
|
|
||||||
font = BaseDoc.FontStyle()
|
font = BaseDoc.FontStyle()
|
||||||
font.set_size(8)
|
font.set_size(8)
|
||||||
@ -281,22 +285,22 @@ class EndOfLineOptions(MenuReportOptions):
|
|||||||
p.set_top_margin(0)
|
p.set_top_margin(0)
|
||||||
p.set_bottom_margin(ReportUtils.pt2cm(6))
|
p.set_bottom_margin(ReportUtils.pt2cm(6))
|
||||||
p.set_description(_('The basic style used for the text display.'))
|
p.set_description(_('The basic style used for the text display.'))
|
||||||
default_style.add_paragraph_style("EOL-Pedigree",p)
|
default_style.add_paragraph_style("EOL-Pedigree", p)
|
||||||
|
|
||||||
#Table Styles
|
#Table Styles
|
||||||
cell = BaseDoc.TableCellStyle()
|
cell = BaseDoc.TableCellStyle()
|
||||||
default_style.add_cell_style('EOL-TableCell',cell)
|
default_style.add_cell_style('EOL-TableCell', cell)
|
||||||
|
|
||||||
cell = BaseDoc.TableCellStyle()
|
cell = BaseDoc.TableCellStyle()
|
||||||
cell.set_bottom_border(1)
|
cell.set_bottom_border(1)
|
||||||
default_style.add_cell_style('EOL_GenerationCell',cell)
|
default_style.add_cell_style('EOL_GenerationCell', cell)
|
||||||
|
|
||||||
table = BaseDoc.TableStyle()
|
table = BaseDoc.TableStyle()
|
||||||
table.set_width(100)
|
table.set_width(100)
|
||||||
table.set_columns(2)
|
table.set_columns(2)
|
||||||
table.set_column_width(0,10)
|
table.set_column_width(0, 10)
|
||||||
table.set_column_width(1,90)
|
table.set_column_width(1, 90)
|
||||||
default_style.add_table_style('EOL-Table',table)
|
default_style.add_table_style('EOL-Table', table)
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -44,7 +44,7 @@ from BasicUtils import name_displayer as _nd
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class FamilyGroup(Report):
|
class FamilyGroup(Report):
|
||||||
|
|
||||||
def __init__(self,database,person,options_class):
|
def __init__(self, database, person, options_class):
|
||||||
"""
|
"""
|
||||||
Creates the DetAncestorReport object that produces the report.
|
Creates the DetAncestorReport object that produces the report.
|
||||||
|
|
||||||
@ -60,25 +60,26 @@ class FamilyGroup(Report):
|
|||||||
family_handle - Handle of the family to write report on.
|
family_handle - Handle of the family to write report on.
|
||||||
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 = ""
|
||||||
|
@ -64,7 +64,7 @@ pt2cm = ReportUtils.pt2cm
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class FanChart(Report):
|
class FanChart(Report):
|
||||||
|
|
||||||
def __init__(self,database,person,options_class):
|
def __init__(self, database, person, options_class):
|
||||||
"""
|
"""
|
||||||
Creates the FanChart object that produces the report.
|
Creates the FanChart object that produces the report.
|
||||||
|
|
||||||
@ -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 = []
|
||||||
@ -101,13 +102,13 @@ class FanChart(Report):
|
|||||||
text_style_name = 'text_style' + '%d' % i
|
text_style_name = 'text_style' + '%d' % i
|
||||||
self.text_style.append(text_style_name)
|
self.text_style.append(text_style_name)
|
||||||
|
|
||||||
Report.__init__(self,database,person,options_class)
|
Report.__init__(self, database, person, options_class)
|
||||||
|
|
||||||
self.height = 0
|
self.height = 0
|
||||||
self.lines = 0
|
self.lines = 0
|
||||||
self.display = "%n"
|
self.display = "%n"
|
||||||
self.map = [None] * 2**self.max_generations
|
self.map = [None] * 2**self.max_generations
|
||||||
self.text= {}
|
self.text = {}
|
||||||
self.box_width = 0
|
self.box_width = 0
|
||||||
|
|
||||||
def apply_filter(self,person_handle,index):
|
def apply_filter(self,person_handle,index):
|
||||||
|
@ -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
|
||||||
@ -72,7 +72,7 @@ _ARROWS = [ { 'name' : _("Descendants <- Ancestors"), 'value' : 'd' },
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class RelGraphReport(Report):
|
class RelGraphReport(Report):
|
||||||
|
|
||||||
def __init__(self,database,person,options_class):
|
def __init__(self, database, person, options_class):
|
||||||
"""
|
"""
|
||||||
Creates ComprehensiveAncestorsReport object that produces the report.
|
Creates ComprehensiveAncestorsReport object that produces the report.
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ class RelGraphReport(Report):
|
|||||||
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.
|
||||||
"""
|
"""
|
||||||
Report.__init__(self,database,person,options_class)
|
Report.__init__(self, database, person, options_class)
|
||||||
|
|
||||||
colored = {
|
colored = {
|
||||||
'male': 'dodgerblue4',
|
'male': 'dodgerblue4',
|
||||||
@ -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
|
||||||
@ -52,7 +52,7 @@ from QuestionDialog import WarningDialog
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class IndivCompleteReport(Report):
|
class IndivCompleteReport(Report):
|
||||||
|
|
||||||
def __init__(self,database,person,options_class):
|
def __init__(self, database, person, options_class):
|
||||||
"""
|
"""
|
||||||
Creates the IndivCompleteReport object that produces the report.
|
Creates the IndivCompleteReport object that produces the report.
|
||||||
|
|
||||||
@ -71,9 +71,10 @@ class IndivCompleteReport(Report):
|
|||||||
cites - Whether or not to include source informaiton.
|
cites - Whether or not to include source informaiton.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
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()
|
||||||
@ -109,10 +110,10 @@ class IndivCompleteReport(Report):
|
|||||||
|
|
||||||
description = event.get_description()
|
description = event.get_description()
|
||||||
if description:
|
if description:
|
||||||
text = '%s%s. ' % (text,description)
|
text = '%s%s. ' % (text, description)
|
||||||
endnotes = ""
|
endnotes = ""
|
||||||
if self.use_srcs:
|
if self.use_srcs:
|
||||||
endnotes = Endnotes.cite_source(self.bibli,event)
|
endnotes = Endnotes.cite_source(self.bibli, event)
|
||||||
|
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.normal_cell(name)
|
self.normal_cell(name)
|
||||||
@ -129,12 +130,12 @@ class IndivCompleteReport(Report):
|
|||||||
note = self.database.get_note_from_handle(notehandle)
|
note = self.database.get_note_from_handle(notehandle)
|
||||||
text = note.get()
|
text = note.get()
|
||||||
format = note.get_format()
|
format = note.get_format()
|
||||||
self.doc.write_note(text,format,'IDS-Normal')
|
self.doc.write_note(text,format, 'IDS-Normal')
|
||||||
|
|
||||||
self.doc.end_cell()
|
self.doc.end_cell()
|
||||||
self.doc.end_row()
|
self.doc.end_row()
|
||||||
|
|
||||||
def write_p_entry(self,label,parent,rel,pmark=None):
|
def write_p_entry(self, label, parent, rel, pmark=None):
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.normal_cell(label)
|
self.normal_cell(label)
|
||||||
|
|
||||||
@ -153,7 +154,7 @@ class IndivCompleteReport(Report):
|
|||||||
return
|
return
|
||||||
self.doc.start_table('note','IDS-IndTable')
|
self.doc.start_table('note','IDS-IndTable')
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell('IDS-TableHead',2)
|
self.doc.start_cell('IDS-TableHead', 2)
|
||||||
self.doc.start_paragraph('IDS-TableTitle')
|
self.doc.start_paragraph('IDS-TableTitle')
|
||||||
self.doc.write_text(_('Notes'))
|
self.doc.write_text(_('Notes'))
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
@ -165,8 +166,8 @@ class IndivCompleteReport(Report):
|
|||||||
text = note.get()
|
text = note.get()
|
||||||
format = note.get_format()
|
format = note.get_format()
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell('IDS-NormalCell',2)
|
self.doc.start_cell('IDS-NormalCell', 2)
|
||||||
self.doc.write_note(text,format,'IDS-Normal')
|
self.doc.write_note(text,format, 'IDS-Normal')
|
||||||
self.doc.end_cell()
|
self.doc.end_cell()
|
||||||
self.doc.end_row()
|
self.doc.end_row()
|
||||||
|
|
||||||
@ -181,7 +182,7 @@ class IndivCompleteReport(Report):
|
|||||||
|
|
||||||
self.doc.start_table("altparents","IDS-IndTable")
|
self.doc.start_table("altparents","IDS-IndTable")
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell("IDS-TableHead",2)
|
self.doc.start_cell("IDS-TableHead", 2)
|
||||||
self.doc.start_paragraph("IDS-TableTitle")
|
self.doc.start_paragraph("IDS-TableTitle")
|
||||||
self.doc.write_text(_("Alternate Parents"))
|
self.doc.write_text(_("Alternate Parents"))
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
@ -293,7 +294,7 @@ class IndivCompleteReport(Report):
|
|||||||
|
|
||||||
self.doc.start_table("three","IDS-IndTable")
|
self.doc.start_table("three","IDS-IndTable")
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell("IDS-TableHead",2)
|
self.doc.start_cell("IDS-TableHead", 2)
|
||||||
self.doc.start_paragraph("IDS-TableTitle")
|
self.doc.start_paragraph("IDS-TableTitle")
|
||||||
self.doc.write_text(_("Marriages/Children"))
|
self.doc.write_text(_("Marriages/Children"))
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
@ -307,16 +308,16 @@ class IndivCompleteReport(Report):
|
|||||||
else:
|
else:
|
||||||
spouse_id = family.get_father_handle()
|
spouse_id = family.get_father_handle()
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell("IDS-NormalCell",2)
|
self.doc.start_cell("IDS-NormalCell", 2)
|
||||||
self.doc.start_paragraph("IDS-Spouse")
|
self.doc.start_paragraph("IDS-Spouse")
|
||||||
if spouse_id:
|
if spouse_id:
|
||||||
spouse = self.database.get_person_from_handle(spouse_id)
|
spouse = self.database.get_person_from_handle(spouse_id)
|
||||||
text = _nd.display(spouse)
|
text = _nd.display(spouse)
|
||||||
mark = ReportUtils.get_person_mark(self.database,spouse)
|
mark = ReportUtils.get_person_mark(self.database, spouse)
|
||||||
else:
|
else:
|
||||||
text = _("unknown")
|
text = _("unknown")
|
||||||
mark = None
|
mark = None
|
||||||
self.doc.write_text(text,mark)
|
self.doc.write_text(text, mark)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
self.doc.end_cell()
|
self.doc.end_cell()
|
||||||
self.doc.end_row()
|
self.doc.end_row()
|
||||||
@ -336,8 +337,8 @@ class IndivCompleteReport(Report):
|
|||||||
self.doc.start_paragraph("IDS-Normal")
|
self.doc.start_paragraph("IDS-Normal")
|
||||||
child = self.database.get_person_from_handle(child_ref.ref)
|
child = self.database.get_person_from_handle(child_ref.ref)
|
||||||
name = _nd.display(child)
|
name = _nd.display(child)
|
||||||
mark = ReportUtils.get_person_mark(self.database,child)
|
mark = ReportUtils.get_person_mark(self.database, child)
|
||||||
self.doc.write_text(name,mark)
|
self.doc.write_text(name, mark)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
self.doc.end_cell()
|
self.doc.end_cell()
|
||||||
self.doc.end_row()
|
self.doc.end_row()
|
||||||
@ -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,21 +512,22 @@ 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."))
|
||||||
menu.add_option(category_name,"cites", cites)
|
menu.add_option(category_name, "cites", cites)
|
||||||
|
|
||||||
def __update_filters(self):
|
def __update_filters(self):
|
||||||
"""
|
"""
|
||||||
|
@ -70,18 +70,19 @@ class KinshipReport(Report):
|
|||||||
incaunts - Whether to include aunts/uncles/nephews/nieces.
|
incaunts - Whether to include aunts/uncles/nephews/nieces.
|
||||||
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.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 = {}
|
||||||
|
|
||||||
@ -94,20 +95,20 @@ class KinshipReport(Report):
|
|||||||
|
|
||||||
self.doc.start_paragraph("KIN-Title")
|
self.doc.start_paragraph("KIN-Title")
|
||||||
title = _("Kinship Report for %s") % pname
|
title = _("Kinship Report for %s") % pname
|
||||||
mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1)
|
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 1)
|
||||||
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)
|
||||||
|
|
||||||
# Collect all descendants of the person
|
# Collect all descendants of the person
|
||||||
self.traverse_down(self.person.get_handle(),0,1)
|
self.traverse_down(self.person.get_handle(), 0, 1)
|
||||||
|
|
||||||
# Collect all ancestors/aunts/uncles/nephews/cousins of the person
|
# Collect all ancestors/aunts/uncles/nephews/cousins of the person
|
||||||
self.traverse_up(self.person.get_handle(),1,0)
|
self.traverse_up(self.person.get_handle(), 1, 0)
|
||||||
|
|
||||||
# Write Kin
|
# Write Kin
|
||||||
for Ga in self.kinship_map.keys():
|
for Ga in self.kinship_map.keys():
|
||||||
@ -117,21 +118,21 @@ 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
|
||||||
self.write_people(title,self.spouse_map[Ga][Gb])
|
self.write_people(title,self.spouse_map[Ga][Gb])
|
||||||
|
|
||||||
def traverse_down(self,person_handle,Ga,Gb,skip_handle=None):
|
def traverse_down(self, person_handle, Ga, Gb, skip_handle=None):
|
||||||
"""
|
"""
|
||||||
Populate a map of arrays containing person handles for the descendants
|
Populate a map of arrays containing person handles for the descendants
|
||||||
of the passed person. This function calls itself recursively until it
|
of the passed person. This function calls itself recursively until it
|
||||||
@ -153,14 +154,14 @@ 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)
|
||||||
|
|
||||||
if Gb < self.max_descend:
|
if Gb < self.max_descend:
|
||||||
self.traverse_down(child_handle,Ga,Gb+1)
|
self.traverse_down(child_handle,Ga,Gb+1)
|
||||||
|
|
||||||
def traverse_up(self,person_handle,Ga,Gb):
|
def traverse_up(self, person_handle, Ga, Gb):
|
||||||
"""
|
"""
|
||||||
Populate a map of arrays containing person handles for the ancestors
|
Populate a map of arrays containing person handles for the ancestors
|
||||||
of the passed person. This function calls itself recursively until it
|
of the passed person. This function calls itself recursively until it
|
||||||
@ -182,7 +183,7 @@ class KinshipReport(Report):
|
|||||||
if Ga < self.max_ascend:
|
if Ga < self.max_ascend:
|
||||||
self.traverse_up(parent_handle,Ga+1,0)
|
self.traverse_up(parent_handle,Ga+1,0)
|
||||||
|
|
||||||
def add_kin(self,person_handle,Ga,Gb):
|
def add_kin(self, person_handle, Ga, Gb):
|
||||||
"""
|
"""
|
||||||
Add a person handle to the kin map.
|
Add a person handle to the kin map.
|
||||||
"""
|
"""
|
||||||
@ -193,7 +194,7 @@ class KinshipReport(Report):
|
|||||||
if person_handle not in self.kinship_map[Ga][Gb]:
|
if person_handle not in self.kinship_map[Ga][Gb]:
|
||||||
self.kinship_map[Ga][Gb].append(person_handle)
|
self.kinship_map[Ga][Gb].append(person_handle)
|
||||||
|
|
||||||
def add_spouse(self,spouse_handle,Ga,Gb):
|
def add_spouse(self, spouse_handle, Ga, Gb):
|
||||||
"""
|
"""
|
||||||
Add a person handle to the spouse map.
|
Add a person handle to the spouse map.
|
||||||
"""
|
"""
|
||||||
@ -204,16 +205,16 @@ class KinshipReport(Report):
|
|||||||
if spouse_handle not in self.spouse_map[Ga][Gb]:
|
if spouse_handle not in self.spouse_map[Ga][Gb]:
|
||||||
self.spouse_map[Ga][Gb].append(spouse_handle)
|
self.spouse_map[Ga][Gb].append(spouse_handle)
|
||||||
|
|
||||||
def get_parent_handles(self,person_handle):
|
def get_parent_handles(self, person_handle):
|
||||||
"""
|
"""
|
||||||
Return an array of handles for all the parents of the
|
Return an array of handles for all the parents of the
|
||||||
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)
|
||||||
@ -222,15 +223,15 @@ class KinshipReport(Report):
|
|||||||
parent_handles.append(mother_handle)
|
parent_handles.append(mother_handle)
|
||||||
return parent_handles
|
return parent_handles
|
||||||
|
|
||||||
def get_spouse_handles(self,person_handle):
|
def get_spouse_handles(self, person_handle):
|
||||||
"""
|
"""
|
||||||
Return an array of handles for all the spouses of the
|
Return an array of handles for all the spouses of the
|
||||||
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
|
||||||
@ -243,36 +244,36 @@ class KinshipReport(Report):
|
|||||||
spouses.append(spouse_handle)
|
spouses.append(spouse_handle)
|
||||||
return spouses
|
return spouses
|
||||||
|
|
||||||
def get_children_handles(self,person_handle):
|
def get_children_handles(self, person_handle):
|
||||||
"""
|
"""
|
||||||
Return an array of handles for all the children of the
|
Return an array of handles for all the children of the
|
||||||
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
|
||||||
|
|
||||||
def get_sibling_handles(self,person_handle):
|
def get_sibling_handles(self, person_handle):
|
||||||
"""
|
"""
|
||||||
Return an array of handles for all the siblings of the
|
Return an array of handles for all the siblings of the
|
||||||
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:
|
||||||
siblings.append(sibling_handle)
|
siblings.append(sibling_handle)
|
||||||
return siblings
|
return siblings
|
||||||
|
|
||||||
def write_people(self,title,people_handles):
|
def write_people(self, title, people_handles):
|
||||||
"""
|
"""
|
||||||
Write information about a group of people - including the title.
|
Write information about a group of people - including the title.
|
||||||
"""
|
"""
|
||||||
@ -284,7 +285,7 @@ class KinshipReport(Report):
|
|||||||
for person_handle in people_handles:
|
for person_handle in people_handles:
|
||||||
self.write_person(person_handle)
|
self.write_person(person_handle)
|
||||||
|
|
||||||
def write_person(self,person_handle):
|
def write_person(self, person_handle):
|
||||||
"""
|
"""
|
||||||
Write information about the given person.
|
Write information about the given person.
|
||||||
"""
|
"""
|
||||||
@ -308,7 +309,7 @@ class KinshipReport(Report):
|
|||||||
'death_date' : death_date }
|
'death_date' : death_date }
|
||||||
|
|
||||||
self.doc.start_paragraph('KIN-Normal')
|
self.doc.start_paragraph('KIN-Normal')
|
||||||
self.doc.write_text(name,mark)
|
self.doc.write_text(name, mark)
|
||||||
self.doc.write_text(dates)
|
self.doc.write_text(dates)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
|
|
||||||
@ -323,10 +324,10 @@ class KinshipOptions(MenuReportOptions):
|
|||||||
Defines options and provides handling interface.
|
Defines options and provides handling interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,name,dbstate=None):
|
def __init__(self, name, dbstate=None):
|
||||||
MenuReportOptions.__init__(self,name,dbstate)
|
MenuReportOptions.__init__(self, name, dbstate)
|
||||||
|
|
||||||
def add_menu_options(self,menu,dbstate):
|
def add_menu_options(self, menu, dbstate):
|
||||||
"""
|
"""
|
||||||
Add options to the menu for the kinship report.
|
Add options to the menu for the kinship report.
|
||||||
"""
|
"""
|
||||||
|
@ -65,8 +65,9 @@ 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)):
|
||||||
@ -471,16 +471,16 @@ class StatisticsChart(Report):
|
|||||||
|
|
||||||
To see what the options are, check the options help in the options class.
|
To see what the options are, check the options help in the options class.
|
||||||
"""
|
"""
|
||||||
Report.__init__(self,database,person,options_class)
|
Report.__init__(self, database, person, options_class)
|
||||||
|
|
||||||
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
|
||||||
@ -67,7 +66,7 @@ def _get_sort_functions(sort):
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class TimeLine(Report):
|
class TimeLine(Report):
|
||||||
|
|
||||||
def __init__(self,database,person,options_class):
|
def __init__(self, database, person, options_class):
|
||||||
"""
|
"""
|
||||||
Creates the Timeline object that produces the report.
|
Creates the Timeline object that produces the report.
|
||||||
|
|
||||||
@ -86,15 +85,13 @@ class TimeLine(Report):
|
|||||||
sortby - Sorting method to be used.
|
sortby - Sorting method to be used.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user