Fixed line ending issues, and syntax errors introduced by translation changes

svn: r11860
This commit is contained in:
Doug Blank
2009-02-05 02:10:10 +00:00
parent de03d3d5a9
commit fc5dcee88b
3 changed files with 1010 additions and 1008 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,500 +1,501 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2008-2009 Brian G. Matherly # Copyright (C) 2008-2009 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# 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
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# python modules # python modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gettext import gettext as _ from gettext import gettext as _
from gettext import ngettext from gettext import ngettext
import datetime import datetime
import time import time
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import BaseDoc import BaseDoc
from BasicUtils import name_displayer from BasicUtils import name_displayer
from gen.plug import PluginManager from gen.plug import PluginManager
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
from gen.plug.menu import BooleanOption, StringOption, NumberOption, \ from gen.plug.menu import BooleanOption, StringOption, NumberOption, \
EnumeratedListOption, FilterOption, PersonOption EnumeratedListOption, FilterOption, PersonOption
import GrampsLocale import GrampsLocale
import gen.lib import gen.lib
from Utils import probably_alive, ProgressMeter from Utils import probably_alive, ProgressMeter
import libholiday import libholiday
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Calendar # Calendar
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class CalendarReport(Report): class CalendarReport(Report):
""" """
Create the Calendar object that produces the report. Create the Calendar object that produces the report.
""" """
def __init__(self, database, options_class): def __init__(self, database, options_class):
Report.__init__(self, database, options_class) Report.__init__(self, database, options_class)
menu = options_class.menu menu = options_class.menu
self.titletext = menu.get_option_by_name('titletext').get_value() self.titletext = menu.get_option_by_name('titletext').get_value()
self.relationships = \ self.relationships = \
menu.get_option_by_name('relationships').get_value() menu.get_option_by_name('relationships').get_value()
self.year = menu.get_option_by_name('year').get_value() self.year = menu.get_option_by_name('year').get_value()
self.name_format = menu.get_option_by_name('name_format').get_value() self.name_format = menu.get_option_by_name('name_format').get_value()
self.country = menu.get_option_by_name('country').get_value() self.country = menu.get_option_by_name('country').get_value()
self.anniversaries = menu.get_option_by_name('anniversaries').get_value() self.anniversaries = menu.get_option_by_name('anniversaries').get_value()
self.start_dow = menu.get_option_by_name('start_dow').get_value() self.start_dow = menu.get_option_by_name('start_dow').get_value()
self.maiden_name = menu.get_option_by_name('maiden_name').get_value() self.maiden_name = menu.get_option_by_name('maiden_name').get_value()
self.alive = menu.get_option_by_name('alive').get_value() self.alive = menu.get_option_by_name('alive').get_value()
self.birthdays = menu.get_option_by_name('birthdays').get_value() self.birthdays = menu.get_option_by_name('birthdays').get_value()
self.text1 = menu.get_option_by_name('text1').get_value() self.text1 = menu.get_option_by_name('text1').get_value()
self.text2 = menu.get_option_by_name('text2').get_value() self.text2 = menu.get_option_by_name('text2').get_value()
self.text3 = menu.get_option_by_name('text3').get_value() self.text3 = menu.get_option_by_name('text3').get_value()
self.filter_option = 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()
pid = menu.get_option_by_name('pid').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 get_name(self, person, maiden_name = None): def get_name(self, person, maiden_name = None):
""" """
Return person's name, unless maiden_name given, unless married_name Return person's name, unless maiden_name given, unless married_name
listed. listed.
""" """
# Get all of a person's names: # Get all of a person's names:
primary_name = person.get_primary_name() primary_name = person.get_primary_name()
married_name = None married_name = None
names = [primary_name] + person.get_alternate_names() names = [primary_name] + person.get_alternate_names()
for name in names: for name in names:
if int(name.get_type()) == gen.lib.NameType.MARRIED: if int(name.get_type()) == gen.lib.NameType.MARRIED:
married_name = name married_name = name
break # use first break # use first
# Now, decide which to use: # Now, decide which to use:
if maiden_name is not None: if maiden_name is not None:
if married_name is not None: if married_name is not None:
name = gen.lib.Name(married_name) name = gen.lib.Name(married_name)
else: else:
name = gen.lib.Name(primary_name) name = gen.lib.Name(primary_name)
name.set_surname(maiden_name) name.set_surname(maiden_name)
else: else:
name = gen.lib.Name(primary_name) name = gen.lib.Name(primary_name)
name.set_display_as(self.name_format) name.set_display_as(self.name_format)
return name_displayer.display_name(name) return name_displayer.display_name(name)
def add_day_item(self, text, month, day): def add_day_item(self, text, month, day):
""" Add an item to a day. """ """ Add an item to a day. """
month_dict = self.calendar.get(month, {}) month_dict = self.calendar.get(month, {})
day_list = month_dict.get(day, []) day_list = month_dict.get(day, [])
day_list.append(text) day_list.append(text)
month_dict[day] = day_list month_dict[day] = day_list
self.calendar[month] = month_dict self.calendar[month] = month_dict
def __get_holidays(self): def __get_holidays(self):
""" Get the holidays for the specified country and year """ """ Get the holidays for the specified country and year """
holiday_table = libholiday.HolidayTable() holiday_table = libholiday.HolidayTable()
country = holiday_table.get_countries()[self.country] country = holiday_table.get_countries()[self.country]
holiday_table.load_holidays(self.year, country) holiday_table.load_holidays(self.year, country)
for month in range(1, 13): for month in range(1, 13):
for day in range(1, 32): for day in range(1, 32):
holiday_names = holiday_table.get_holidays(month, day) holiday_names = holiday_table.get_holidays(month, day)
for holiday_name in holiday_names: for holiday_name in holiday_names:
self.add_day_item(holiday_name, month, day) self.add_day_item(holiday_name, month, day)
def write_report(self): def write_report(self):
""" The short method that runs through each month and creates a page. """ """ The short method that runs through each month and creates a page. """
# initialize the dict to fill: # initialize the dict to fill:
self.progress = ProgressMeter(_('Birthday and Anniversary Report')) self.progress = ProgressMeter(_('Birthday and Anniversary Report'))
self.calendar = {} self.calendar = {}
# get the information, first from holidays: # get the information, first from holidays:
if self.country != 0: if self.country != 0:
self.__get_holidays() self.__get_holidays()
# get data from database: # get data from database:
self.collect_data() self.collect_data()
# generate the report: # generate the report:
self.doc.start_paragraph('BIR-Title') self.doc.start_paragraph('BIR-Title')
self.doc.write_text(str(self.titletext) + ": " + str(self.year)) self.doc.write_text(str(self.titletext) + ": " + str(self.year))
self.doc.end_paragraph() self.doc.end_paragraph()
if self.text1.strip() != "": if self.text1.strip() != "":
self.doc.start_paragraph('BIR-Text1style') self.doc.start_paragraph('BIR-Text1style')
self.doc.write_text(str(self.text1)) self.doc.write_text(str(self.text1))
self.doc.end_paragraph() self.doc.end_paragraph()
if self.text2.strip() != "": if self.text2.strip() != "":
self.doc.start_paragraph('BIR-Text2style') self.doc.start_paragraph('BIR-Text2style')
self.doc.write_text(str(self.text2)) self.doc.write_text(str(self.text2))
self.doc.end_paragraph() self.doc.end_paragraph()
if self.text3.strip() != "": if self.text3.strip() != "":
self.doc.start_paragraph('BIR-Text3style') self.doc.start_paragraph('BIR-Text3style')
self.doc.write_text(str(self.text3)) self.doc.write_text(str(self.text3))
self.doc.end_paragraph() self.doc.end_paragraph()
if self.relationships: if self.relationships:
name = self.center_person.get_primary_name() name = self.center_person.get_primary_name()
self.doc.start_paragraph('BIR-Text3style') self.doc.start_paragraph('BIR-Text3style')
self.doc.write_text(_("Relationships shown are to %s") % name_displayer.display_name(name)) self.doc.write_text(_("Relationships shown are to %s") % name_displayer.display_name(name))
self.doc.end_paragraph() self.doc.end_paragraph()
self.progress.set_pass(_('Formatting months...'), 12) self.progress.set_pass(_('Formatting months...'), 12)
for month in range(1, 13): for month in range(1, 13):
self.progress.step() self.progress.step()
self.print_page(month) self.print_page(month)
self.progress.close() self.progress.close()
def print_page(self, month): def print_page(self, month):
""" Prints a month as a page """ """ Prints a month as a page """
year = self.year year = self.year
self.doc.start_paragraph('BIR-Monthstyle') self.doc.start_paragraph('BIR-Monthstyle')
self.doc.write_text(GrampsLocale.long_months[month].capitalize()) self.doc.write_text(GrampsLocale.long_months[month].capitalize())
self.doc.end_paragraph() self.doc.end_paragraph()
current_date = datetime.date(year, month, 1) current_date = datetime.date(year, month, 1)
current_ord = current_date.toordinal() current_ord = current_date.toordinal()
started_day = {} started_day = {}
for i in range(31): for i in range(31):
thisday = current_date.fromordinal(current_ord) thisday = current_date.fromordinal(current_ord)
if thisday.month == month: if thisday.month == month:
list = self.calendar.get(month, {}).get(thisday.day, []) list = self.calendar.get(month, {}).get(thisday.day, [])
for p in list: for p in list:
p = p.replace("\n", " ") p = p.replace("\n", " ")
if thisday not in started_day: if thisday not in started_day:
self.doc.start_paragraph("BIR-Daystyle") self.doc.start_paragraph("BIR-Daystyle")
self.doc.write_text(str(thisday.day)) self.doc.write_text(str(thisday.day))
self.doc.end_paragraph() self.doc.end_paragraph()
started_day[thisday] = 1 started_day[thisday] = 1
self.doc.start_paragraph("BIR-Datastyle") self.doc.start_paragraph("BIR-Datastyle")
self.doc.write_text(p) self.doc.write_text(p)
self.doc.end_paragraph() self.doc.end_paragraph()
current_ord += 1 current_ord += 1
def collect_data(self): def collect_data(self):
""" """
This method runs through the data, and collects the relevant dates This method runs through the data, and collects the relevant dates
and text. and text.
""" """
people = self.database.get_person_handles(sort_handles=False) people = self.database.get_person_handles(sort_handles=False)
self.progress.set_pass(_('Applying Filter...'), len(people)) self.progress.set_pass(_('Applying Filter...'), len(people))
people = self.filter.apply(self.database, people, self.progress) people = self.filter.apply(self.database, people, self.progress)
pmgr = PluginManager.get_instance() pmgr = PluginManager.get_instance()
rel_calc = pmgr.get_relationship_calculator() rel_calc = pmgr.get_relationship_calculator()
self.progress.set_pass(_('Reading database...'), len(people)) self.progress.set_pass(_('Reading database...'), len(people))
for person_handle in people: for person_handle in people:
self.progress.step() self.progress.step()
person = self.database.get_person_from_handle(person_handle) person = self.database.get_person_from_handle(person_handle)
birth_ref = person.get_birth_ref() birth_ref = person.get_birth_ref()
birth_date = None birth_date = None
if birth_ref: if birth_ref:
birth_event = self.database.get_event_from_handle(birth_ref.ref) birth_event = self.database.get_event_from_handle(birth_ref.ref)
birth_date = birth_event.get_date_object() birth_date = birth_event.get_date_object()
if self.birthdays and birth_date is not None: if self.birthdays and birth_date is not None:
year = birth_date.get_year() year = birth_date.get_year()
month = birth_date.get_month() month = birth_date.get_month()
day = birth_date.get_day() day = birth_date.get_day()
prob_alive_date = gen.lib.Date(self.year, month, day) prob_alive_date = gen.lib.Date(self.year, month, day)
nyears = self.year - year nyears = self.year - year
# add some things to handle maiden name: # add some things to handle maiden name:
father_lastname = None # husband, actually father_lastname = None # husband, actually
if self.maiden_name in ['spouse_first', 'spouse_last']: # get husband's last name: if self.maiden_name in ['spouse_first', 'spouse_last']: # get husband's last name:
if person.get_gender() == gen.lib.Person.FEMALE: if person.get_gender() == gen.lib.Person.FEMALE:
family_list = person.get_family_handle_list() family_list = person.get_family_handle_list()
if len(family_list) > 0: if len(family_list) > 0:
if self.maiden_name == 'spouse_first': if self.maiden_name == 'spouse_first':
fhandle = family_list[0] fhandle = family_list[0]
else: else:
fhandle = family_list[-1] fhandle = family_list[-1]
fam = self.database.get_family_from_handle(fhandle) fam = self.database.get_family_from_handle(fhandle)
father_handle = fam.get_father_handle() father_handle = fam.get_father_handle()
mother_handle = fam.get_mother_handle() mother_handle = fam.get_mother_handle()
if mother_handle == person_handle: if mother_handle == person_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)
if father is not None: if father is not None:
father_lastname = father.get_primary_name().surname father_lastname = father.get_primary_name().surname
short_name = self.get_name(person, father_lastname) short_name = self.get_name(person, father_lastname)
alive = probably_alive(person, self.database, prob_alive_date) alive = probably_alive(person, self.database, prob_alive_date)
if ((self.alive and alive) or not self.alive): if ((self.alive and alive) or not self.alive):
comment = "" comment = ""
if self.relationships: if self.relationships:
relation = rel_calc.get_one_relationship( relation = rel_calc.get_one_relationship(
self.database, self.database,
self.center_person, self.center_person,
person) person)
if relation: if relation:
comment = " --- %s" % relation comment = " --- %s" % relation
if nyears == 0: if nyears == 0:
text = _('%(person)s, birth%(relation)s') % { text = _('%(person)s, birth%(relation)s') % {
'person' : short_name, 'person' : short_name,
'relation' : comment} 'relation' : comment}
else: else:
text = ngettext('%(person)s, %(age)d%(relation)s', text = (ngettext('%(person)s, %(age)d%(relation)s',
'%(person)s, %(age)d%(relation)s', nyears) '%(person)s, %(age)d%(relation)s', nyears)
% {'person' : short_name, % {'person' : short_name,
'age' : nyears, 'age' : nyears,
'relation' : comment} 'relation' : comment})
self.add_day_item(text, month, day) self.add_day_item(text, month, day)
if self.anniversaries: if self.anniversaries:
family_list = person.get_family_handle_list() family_list = person.get_family_handle_list()
for fhandle in family_list: for fhandle in family_list:
fam = self.database.get_family_from_handle(fhandle) fam = self.database.get_family_from_handle(fhandle)
father_handle = fam.get_father_handle() father_handle = fam.get_father_handle()
mother_handle = fam.get_mother_handle() mother_handle = fam.get_mother_handle()
if father_handle == person.get_handle(): if father_handle == person.get_handle():
spouse_handle = mother_handle spouse_handle = mother_handle
else: else:
continue # with next person if the father is not "person" continue # with next person if the father is not "person"
# this will keep from duplicating the anniversary # this will keep from duplicating the anniversary
if spouse_handle: if spouse_handle:
spouse = self.database.get_person_from_handle(spouse_handle) spouse = self.database.get_person_from_handle(spouse_handle)
if spouse: if spouse:
spouse_name = self.get_name(spouse) spouse_name = self.get_name(spouse)
short_name = self.get_name(person) short_name = self.get_name(person)
# TEMP: this will hanlde ordered events # TEMP: this will hanlde ordered events
# GRAMPS 3.0 will have a new mechanism for start/stop events # GRAMPS 3.0 will have a new mechanism for start/stop events
are_married = None are_married = None
for event_ref in fam.get_event_ref_list(): for event_ref in fam.get_event_ref_list():
event = self.database.get_event_from_handle(event_ref.ref) event = self.database.get_event_from_handle(event_ref.ref)
if event.type in [gen.lib.EventType.MARRIAGE, if event.type in [gen.lib.EventType.MARRIAGE,
gen.lib.EventType.MARR_ALT]: gen.lib.EventType.MARR_ALT]:
are_married = event are_married = event
elif event.type in [gen.lib.EventType.DIVORCE, elif event.type in [gen.lib.EventType.DIVORCE,
gen.lib.EventType.ANNULMENT, gen.lib.EventType.ANNULMENT,
gen.lib.EventType.DIV_FILING]: gen.lib.EventType.DIV_FILING]:
are_married = None are_married = None
if are_married is not None: if are_married is not None:
for event_ref in fam.get_event_ref_list(): for event_ref in fam.get_event_ref_list():
event = self.database.get_event_from_handle(event_ref.ref) event = self.database.get_event_from_handle(event_ref.ref)
event_obj = event.get_date_object() event_obj = event.get_date_object()
year = event_obj.get_year() year = event_obj.get_year()
month = event_obj.get_month() month = event_obj.get_month()
day = event_obj.get_day() day = event_obj.get_day()
nyears = self.year - year nyears = self.year - year
if nyears == 0: if nyears == 0:
text = _("%(spouse)s and\n %(person)s, wedding") % { text = _("%(spouse)s and\n %(person)s, wedding") % {
'spouse' : spouse_name, 'spouse' : spouse_name,
'person' : short_name} 'person' : short_name}
else: else:
text = ngettext("%(spouse)s and\n %(person)s, %(nyears)d", text = (ngettext("%(spouse)s and\n %(person)s, %(nyears)d",
"%(spouse)s and\n %(person)s, %(nyears)d", nyears) "%(spouse)s and\n %(person)s, %(nyears)d", nyears)
% {'spouse' : spouse_name, % {'spouse' : spouse_name,
'person' : short_name, 'person' : short_name,
'nyears' : nyears} 'nyears' : nyears})
prob_alive_date = gen.lib.Date(self.year, month, day) prob_alive_date = gen.lib.Date(self.year, month, day)
alive1 = probably_alive(person, self.database, \ alive1 = probably_alive(person, self.database, \
prob_alive_date) prob_alive_date)
alive2 = probably_alive(spouse, self.database, \ alive2 = probably_alive(spouse, self.database, \
prob_alive_date) prob_alive_date)
if (self.alive and alive1 and alive2) or not self.alive: if (self.alive and alive1 and alive2) or not self.alive:
self.add_day_item(text, month, day) self.add_day_item(text, month, day)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# CalendarOptions # CalendarOptions
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class CalendarOptions(MenuReportOptions): class CalendarOptions(MenuReportOptions):
""" Options for the Birthday/Anniversary Report """ """ Options for the Birthday/Anniversary Report """
def __init__(self, name, dbase): def __init__(self, name, dbase):
self.__db = dbase self.__db = dbase
self.__pid = None self.__pid = None
self.__filter = None self.__filter = None
MenuReportOptions.__init__(self, name, dbase) MenuReportOptions.__init__(self, name, dbase)
def add_menu_options(self, menu): def add_menu_options(self, menu):
""" Add the options for the graphical calendar """ """ Add the options for the graphical calendar """
category_name = _("Report Options") category_name = _("Report Options")
year = NumberOption(_("Year of calendar"), time.localtime()[0], year = NumberOption(_("Year of calendar"), time.localtime()[0],
1000, 3000) 1000, 3000)
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 = FilterOption(_("Filter"), 0)
self.__filter.set_help( self.__filter.set_help(
_("Select filter to restrict people that appear on calendar")) _("Select filter to restrict people that appear on calendar"))
menu.add_option(category_name, "filter", self.__filter) menu.add_option(category_name, "filter", self.__filter)
self.__pid = PersonOption(_("Center Person")) self.__pid = PersonOption(_("Center Person"))
self.__pid.set_help(_("The center person for the report")) self.__pid.set_help(_("The center person for the report"))
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.__update_filters() self.__update_filters()
# We must figure out the value of the first option before we can # We must figure out the value of the first option before we can
# create the EnumeratedListOption # create the EnumeratedListOption
fmt_list = name_displayer.get_name_format() fmt_list = name_displayer.get_name_format()
name_format = EnumeratedListOption(_("Name format"), fmt_list[0][0]) name_format = EnumeratedListOption(_("Name format"), fmt_list[0][0])
for num, name, fmt_str, act in fmt_list: for num, name, fmt_str, act in fmt_list:
name_format.add_item(num, name) name_format.add_item(num, name)
name_format.set_help(_("Select the format to display names")) name_format.set_help(_("Select the format to display names"))
menu.add_option(category_name, "name_format", name_format) menu.add_option(category_name, "name_format", name_format)
country = EnumeratedListOption(_("Country for holidays"), 0) country = EnumeratedListOption(_("Country for holidays"), 0)
holiday_table = libholiday.HolidayTable() holiday_table = libholiday.HolidayTable()
count = 0 count = 0
for c in holiday_table.get_countries(): for c in holiday_table.get_countries():
country.add_item(count, c) country.add_item(count, c)
count += 1 count += 1
country.set_help(_("Select the country to see associated holidays")) country.set_help(_("Select the country to see associated holidays"))
menu.add_option(category_name, "country", country) menu.add_option(category_name, "country", country)
start_dow = EnumeratedListOption(_("First day of week"), 1) start_dow = EnumeratedListOption(_("First day of week"), 1)
for count in range(1, 8): for count in range(1, 8):
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below # conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
start_dow.add_item((count+5) % 7 + 1, GrampsLocale.long_days[count].capitalize()) start_dow.add_item((count+5) % 7 + 1, GrampsLocale.long_days[count].capitalize())
start_dow.set_help(_("Select the first day of the week for the calendar")) start_dow.set_help(_("Select the first day of the week for the calendar"))
menu.add_option(category_name, "start_dow", start_dow) menu.add_option(category_name, "start_dow", start_dow)
maiden_name = EnumeratedListOption(_("Birthday surname"), "own") maiden_name = EnumeratedListOption(_("Birthday surname"), "own")
maiden_name.add_item("spouse_first", _("Wives use husband's surname (from first family listed)")) maiden_name.add_item("spouse_first", _("Wives use husband's surname (from first family listed)"))
maiden_name.add_item("spouse_last", _("Wives use husband's surname (from last family listed)")) maiden_name.add_item("spouse_last", _("Wives use husband's surname (from last family listed)"))
maiden_name.add_item("own", _("Wives use their own surname")) maiden_name.add_item("own", _("Wives use their own surname"))
maiden_name.set_help(_("Select married women's displayed surname")) maiden_name.set_help(_("Select married women's displayed surname"))
menu.add_option(category_name, "maiden_name", maiden_name) menu.add_option(category_name, "maiden_name", maiden_name)
alive = BooleanOption(_("Include only living people"), True) alive = BooleanOption(_("Include only living people"), True)
alive.set_help(_("Include only living people in the calendar")) alive.set_help(_("Include only living people in the calendar"))
menu.add_option(category_name, "alive", alive) menu.add_option(category_name, "alive", alive)
birthdays = BooleanOption(_("Include birthdays"), True) birthdays = BooleanOption(_("Include birthdays"), True)
birthdays.set_help(_("Include birthdays in the calendar")) birthdays.set_help(_("Include birthdays in the calendar"))
menu.add_option(category_name, "birthdays", birthdays) menu.add_option(category_name, "birthdays", birthdays)
anniversaries = BooleanOption(_("Include anniversaries"), True) anniversaries = BooleanOption(_("Include anniversaries"), True)
anniversaries.set_help(_("Include anniversaries in the calendar")) anniversaries.set_help(_("Include anniversaries in the calendar"))
menu.add_option(category_name, "anniversaries", anniversaries) menu.add_option(category_name, "anniversaries", anniversaries)
option = BooleanOption(_("Include relationships to center person"), option = BooleanOption(_("Include relationships to center person"),
False) False)
option.set_help(_("Include relationships to center person (slower)")) option.set_help(_("Include relationships to center person (slower)"))
menu.add_option(category_name, "relationships", option) menu.add_option(category_name, "relationships", option)
category_name = _("Text Options") category_name = _("Text Options")
titletext = StringOption(_("Title text"), titletext = StringOption(_("Title text"),
_("Birthday and Anniversary Report")) _("Birthday and Anniversary Report"))
titletext.set_help(_("Title of calendar")) titletext.set_help(_("Title of calendar"))
menu.add_option(category_name, "titletext", titletext) menu.add_option(category_name, "titletext", titletext)
text1 = StringOption(_("Text Area 1"), _("My Calendar")) text1 = StringOption(_("Text Area 1"), _("My Calendar"))
text1.set_help(_("First line of text at bottom of calendar")) text1.set_help(_("First line of text at bottom of calendar"))
menu.add_option(category_name, "text1", text1) menu.add_option(category_name, "text1", text1)
text2 = StringOption(_("Text Area 2"), _("Produced with GRAMPS")) text2 = StringOption(_("Text Area 2"), _("Produced with GRAMPS"))
text2.set_help(_("Second line of text at bottom of calendar")) text2.set_help(_("Second line of text at bottom of calendar"))
menu.add_option(category_name, "text2", text2) menu.add_option(category_name, "text2", text2)
text3 = StringOption(_("Text Area 3"), "http://gramps-project.org/",) text3 = StringOption(_("Text Area 3"), "http://gramps-project.org/",)
text3.set_help(_("Third line of text at bottom of calendar")) text3.set_help(_("Third line of text at bottom of calendar"))
menu.add_option(category_name, "text3", text3) menu.add_option(category_name, "text3", text3)
def __update_filters(self): def __update_filters(self):
""" """
Update the filter list based on the selected person Update the filter list based on the selected person
""" """
gid = self.__pid.get_value() gid = self.__pid.get_value()
person = self.__db.get_person_from_gramps_id(gid) person = self.__db.get_person_from_gramps_id(gid)
filter_list = ReportUtils.get_person_filters(person, False) filter_list = ReportUtils.get_person_filters(person, False)
self.__filter.set_filters(filter_list) self.__filter.set_filters(filter_list)
def make_my_style(self, default_style, name, description, def make_my_style(self, default_style, name, description,
size=9, font=BaseDoc.FONT_SERIF, justified ="left", size=9, font=BaseDoc.FONT_SERIF, justified ="left",
color=None, align=BaseDoc.PARA_ALIGN_CENTER, color=None, align=BaseDoc.PARA_ALIGN_CENTER,
shadow = None, italic=0, bold=0, borders=0, indent=None): shadow = None, italic=0, bold=0, borders=0, indent=None):
""" Create paragraph and graphic styles of the same name """ """ Create paragraph and graphic styles of the same name """
# Paragraph: # Paragraph:
f = BaseDoc.FontStyle() f = BaseDoc.FontStyle()
f.set_size(size) f.set_size(size)
f.set_type_face(font) f.set_type_face(font)
f.set_italic(italic) f.set_italic(italic)
f.set_bold(bold) f.set_bold(bold)
p = BaseDoc.ParagraphStyle() p = BaseDoc.ParagraphStyle()
p.set_font(f) p.set_font(f)
p.set_alignment(align) p.set_alignment(align)
p.set_description(description) p.set_description(description)
p.set_top_border(borders) p.set_top_border(borders)
p.set_left_border(borders) p.set_left_border(borders)
p.set_bottom_border(borders) p.set_bottom_border(borders)
p.set_right_border(borders) p.set_right_border(borders)
if indent: if indent:
p.set(first_indent=indent) p.set(first_indent=indent)
if justified == "left": if justified == "left":
p.set_alignment(BaseDoc.PARA_ALIGN_LEFT) p.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
elif justified == "right": elif justified == "right":
p.set_alignment(BaseDoc.PARA_ALIGN_RIGHT) p.set_alignment(BaseDoc.PARA_ALIGN_RIGHT)
elif justified == "center": elif justified == "center":
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER) p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
default_style.add_paragraph_style(name, p) default_style.add_paragraph_style(name, p)
# Graphics: # Graphics:
g = BaseDoc.GraphicsStyle() g = BaseDoc.GraphicsStyle()
g.set_paragraph_style(name) g.set_paragraph_style(name)
if shadow: if shadow:
g.set_shadow(*shadow) g.set_shadow(*shadow)
if color is not None: if color is not None:
g.set_fill_color(color) g.set_fill_color(color)
if not borders: if not borders:
g.set_line_width(0) g.set_line_width(0)
default_style.add_draw_style(name, g) default_style.add_draw_style(name, g)
def make_default_style(self, default_style): def make_default_style(self, default_style):
""" Add the styles used in this report """ """ Add the styles used in this report """
self.make_my_style(default_style, "BIR-Title", self.make_my_style(default_style, "BIR-Title",
_('Title text style'), 14, _('Title text style'), 14,
bold=1, justified="center") bold=1, justified="center")
self.make_my_style(default_style, "BIR-Datastyle", self.make_my_style(default_style, "BIR-Datastyle",
_('Data text display'), 12, indent=1.0) _('Data text display'), 12, indent=1.0)
self.make_my_style(default_style, "BIR-Daystyle", self.make_my_style(default_style, "BIR-Daystyle",
_('Day text style'), 12, indent=.5, _('Day text style'), 12, indent=.5,
italic=1, bold=1) italic=1, bold=1)
self.make_my_style(default_style, "BIR-Monthstyle", self.make_my_style(default_style, "BIR-Monthstyle",
_('Month text style'), 14, bold=1) _('Month text style'), 14, bold=1)
self.make_my_style(default_style, "BIR-Text1style", self.make_my_style(default_style, "BIR-Text1style",
_('Text at bottom, line 1'), 12, justified="center") _('Text at bottom, line 1'), 12, justified="center")
self.make_my_style(default_style, "BIR-Text2style", self.make_my_style(default_style, "BIR-Text2style",
_('Text at bottom, line 2'), 12, justified="center") _('Text at bottom, line 2'), 12, justified="center")
self.make_my_style(default_style, "BIR-Text3style", self.make_my_style(default_style, "BIR-Text3style",
_('Text at bottom, line 3'), 12, justified="center") _('Text at bottom, line 3'), 12, justified="center")
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Register the plugins # Register the plugins
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
pmgr = PluginManager.get_instance() pmgr = PluginManager.get_instance()
pmgr.register_report( pmgr.register_report(
name = 'birthday_report', name = 'birthday_report',
category = CATEGORY_TEXT, category = CATEGORY_TEXT,
report_class = CalendarReport, report_class = CalendarReport,
options_class = CalendarOptions, options_class = CalendarOptions,
modes = PluginManager.REPORT_MODE_GUI | \ modes = PluginManager.REPORT_MODE_GUI | \
PluginManager.REPORT_MODE_BKI | \ PluginManager.REPORT_MODE_BKI | \
PluginManager.REPORT_MODE_CLI, PluginManager.REPORT_MODE_CLI,
translated_name = _("Birthday and Anniversary Report"), translated_name = _("Birthday and Anniversary Report"),
status = _("Stable"), status = _("Stable"),
author_name = "Douglas S. Blank", author_name = "Douglas S. Blank",
author_email = "dblank@cs.brynmawr.edu", author_email = "dblank@cs.brynmawr.edu",
description = _("Produces a report of birthdays and anniversaries"), description = _("Produces a report of birthdays and anniversaries"),
) )

View File

@ -1528,9 +1528,9 @@ def get_day_list(event_date, holiday_list, bday_anniv_list):
txt_str = _('%(person)s, <em>birth</em>') % { txt_str = _('%(person)s, <em>birth</em>') % {
'person' : text} 'person' : text}
else: else:
txt_str = ngettext('%(person)s, <em>%(age)s</em> old', txt_str = (ngettext('%(person)s, <em>%(age)s</em> old',
'%(person)s, <em>%(age)s</em> old', age_str) '%(person)s, <em>%(age)s</em> old', age_str)
% {'person' : text, 'age' : age_str} % {'person' : text, 'age' : age_str})
# an anniversary # an anniversary
elif event == 'Anniversary': elif event == 'Anniversary':
@ -1539,9 +1539,9 @@ def get_day_list(event_date, holiday_list, bday_anniv_list):
txt_str = _('%(couple)s, <em>wedding</em>') % { txt_str = _('%(couple)s, <em>wedding</em>') % {
'couple' : text} 'couple' : text}
else: else:
txt_str = ngettext('%(couple)s, <em>%(years)d</em> year anniversary' txt_str = (ngettext('%(couple)s, <em>%(years)d</em> year anniversary'
'%(couple)s, <em>%(years)d</em> year anniversary', nyears) '%(couple)s, <em>%(years)d</em> year anniversary', nyears)
% {'couple' : text, 'years' : nyears} % {'couple' : text, 'years' : nyears})
txt_str = '<span class="yearsmarried">%s</span>' % txt_str txt_str = '<span class="yearsmarried">%s</span>' % txt_str
if txt_str is not None: if txt_str is not None: