From f7daf18f5d8c9b87d9fbbc598869c94fb5576761 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Mon, 31 Jan 2005 05:31:30 +0000 Subject: [PATCH] * src/ReportUtils.py (born_died_str,married_str): Use NameDisplay to properly display names; (get_birth_death_strings, child_str, born_str, died_str, buried_str): Add functions; (draw_legend): Use correct style for the legend text, using write_at(). * src/docgen/OpenOffice.org (write_at): Accept paragraph style name. * src/docgen/LPRDoc.org (draw_bar): Properly draw and use color for the bar; (write_at): Correctly transform coordinates. * src/plugins/StatisticsChart.py: Replace tabs with spaces. svn: r4005 --- ChangeLog | 9 + src/ReportUtils.py | 610 +++++++++++++++++++++++++++++++-- src/docgen/LPRDoc.py | 21 +- src/docgen/OpenOfficeDoc.py | 332 +++++++++--------- src/plugins/StatisticsChart.py | 172 +++++----- 5 files changed, 854 insertions(+), 290 deletions(-) diff --git a/ChangeLog b/ChangeLog index b12bb0285..961dad000 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,15 @@ * src/WriteGrdb.py: Copy metadata; Remove redundant str conversion. + * src/ReportUtils.py (born_died_str,married_str): Use NameDisplay + to properly display names; (get_birth_death_strings, child_str, + born_str, died_str, buried_str): Add functions; (draw_legend): Use + correct style for the legend text, using write_at(). + * src/docgen/OpenOffice.org (write_at): Accept paragraph style name. + * src/docgen/LPRDoc.org (draw_bar): Properly draw and use color + for the bar; (write_at): Correctly transform coordinates. + * src/plugins/StatisticsChart.py: Replace tabs with spaces. + 2005-01-29 Alex Roitman * src/plugins/GraphViz.py (GraphVizDialog.__init__): Use proper response ID; (GraphVizGraphics.__init__): set up self.doc; diff --git a/src/ReportUtils.py b/src/ReportUtils.py index ee09d84ff..03c0e89f4 100644 --- a/src/ReportUtils.py +++ b/src/ReportUtils.py @@ -21,8 +21,14 @@ # $Id$ +#------------------------------------------------------------------------ +# +# GRAMPS modules +# +#------------------------------------------------------------------------ import Date import RelLib +from NameDisplay import displayer as _nd #------------------------------------------------------------------------- # @@ -115,7 +121,7 @@ def draw_legend(doc, start_x, start_y, data): size = pt2cm(doc.get_style(pstyle).get_font().get_size()) doc.draw_bar(format, start_x, start_y, start_x + (2*size), start_y + size) - doc.write_at(format, legend, start_x + (3*size), start_y - (size*0.25)) + doc.write_at(pstyle, legend, start_x + (3*size), start_y + (size*0.25)) start_y += size * 1.3 def draw_vertical_bar_graph(doc, format, start_x, start_y, height, width, data): @@ -312,17 +318,17 @@ def sanitize_person(db,person): new_person.add_family_handle(handle) # LDS ordinances - ord = person.get_lds_baptism() - if ord: - new_person.set_lds_baptism(ord) + ordinance = person.get_lds_baptism() + if ordinance: + new_person.set_lds_baptism(ordinance) - ord = person.get_lds_endowment() - if ord: - new_person.set_lds_endowment(ord) + ordinance = person.get_lds_endowment() + if ordinance: + new_person.set_lds_endowment(ordinance) - ord = person.get_lds_sealing() - if ord: - new_person.set_lds_sealing(ord) + ordinance = person.get_lds_sealing() + if ordinance: + new_person.set_lds_sealing(ordinance) return new_person @@ -346,6 +352,24 @@ def roman(num): num -= vals[i] * amount return retval +#------------------------------------------------------------------------- +# +# Functions commonly used in reports +# +#------------------------------------------------------------------------- +def insert_images(database, doc, person, w_cm=4.0, h_cm=4.0): + """ + Insert pictures of a person into the document. + """ + + photos = person.get_media_list() + for photo in photos : + object_handle = photo.get_reference_handle() + media_object = database.get_object_from_handle(object_handle) + if media_object.get_mime_type()[0:5] == "image": + filename = media_object.get_path() + doc.add_media_object(filename,"row") + #------------------------------------------------------------------------- # # Strings commonly used in reports @@ -355,6 +379,37 @@ def empty_notes(): # Empty stab function for when endnotes are not needed return "" +def get_birth_death_strings(database,person,empty_date="",empty_place=""): + """ + Returns strings for dates and places of birth and death. + """ + + bplace = dplace = empty_place + bdate = ddate = empty_date + bdate_full = ddate_full = False + + birth_handle = person.get_birth_handle() + if birth_handle: + birth = database.get_event_from_handle(birth_handle) + bdate = birth.get_date() + bplace_handle = birth.get_place_handle() + if bplace_handle: + bplace = database.get_place_from_handle(bplace_handle).get_title() + bdate_obj = birth.get_date_object() + bdate_full = bdate_obj and bdate_obj.get_day_valid() + + death_handle = person.get_death_handle() + if death_handle: + death = database.get_event_from_handle(death_handle) + ddate = death.get_date() + dplace_handle = death.get_place_handle() + if dplace_handle: + dplace = database.get_place_from_handle(dplace_handle).get_title() + ddate_obj = death.get_date_object() + ddate_full = ddate_obj and ddate_obj.get_day_valid() + + return (bdate,bplace,bdate_full,ddate,dplace,ddate_full) + def born_died_str(database,person,endnotes=None,name_object=None,person_name=None): """ Composes a string describing birth and death of a person. @@ -391,32 +446,14 @@ def born_died_str(database,person,endnotes=None,name_object=None,person_name=Non name_object = person.get_primary_name() if person_name == None: - person_name = name_object.get_regular_name() + person_name = _nd.display_name(name_object) elif person_name == 0: if person.get_gender() == RelLib.Person.male: person_name = _('He') else: person_name = _('She') - birth_handle = person.get_birth_handle() - bplace = "" - bdate = "" - if birth_handle: - birth = database.get_event_from_handle(birth_handle) - bdate = birth.get_date() - bplace_handle = birth.get_place_handle() - if bplace_handle: - bplace = database.get_place_from_handle(bplace_handle).get_title() - - death_handle = person.get_death_handle() - dplace = "" - ddate = "" - if death_handle: - death = database.get_event_from_handle(death_handle) - ddate = death.get_date() - dplace_handle = death.get_place_handle() - if dplace_handle: - dplace = database.get_place_from_handle(dplace_handle).get_title() + bdate,bplace,ddate,dplace = get_birth_death_strings(database,person) if person.get_gender() == RelLib.Person.male: if bdate: @@ -674,6 +711,8 @@ def born_died_str(database,person,endnotes=None,name_object=None,person_name=Non else: text = _("%(female_name)s%(endnotes)s.") % { 'female_name' : person_name, 'endnotes' : endnotes(name_object) } + if text: + text = text + " " return text def married_str(database,person,spouse,event,endnotes=None): @@ -704,7 +743,7 @@ def married_str(database,person,spouse,event,endnotes=None): if not endnotes: endnotes = empty_notes - spouse_name = spouse.get_primary_name().get_regular_name() + spouse_name = _nd.display(spouse) date = event.get_date() place_handle = event.get_place_handle() @@ -758,11 +797,13 @@ def married_str(database,person,spouse,event,endnotes=None): text = _('She married %(spouse)s%(endnotes)s.') % { 'spouse' : spouse_name, 'endnotes' : endnotes(event)} + if text: + text = text + " " return text -def child_str(person_gender,father_name,mother_name,dead): +def child_str(person,person_name=0,father_name="",mother_name="",dead=0): """ - Composes a string describing marriage of a person. + Composes a string describing person being a child. The string is composed in the following form: "He/She is/was the son/daughter of father_name and mother_name" @@ -780,8 +821,17 @@ def child_str(person_gender,father_name,mother_name,dead): @rtype: unicode """ + if person_name == None: + person_name = _nd.display_name(person.get_primary_name()) + elif person_name == 0: + if person.get_gender() == RelLib.Person.male: + person_name = _('He') + else: + person_name = _('She') + text = "" - if person_gender == RelLib.Person.male: + + if person.get_gender() == RelLib.Person.male: if mother_name and father_name: if dead: text = _("He was the son of %(father)s and %(mother)s.") % { @@ -830,6 +880,498 @@ def child_str(person_gender,father_name,mother_name,dead): text = _("She is the daughter of %(father)s.") % { 'father' : father_name, } + if text: + text = text + " " + return text + + +def born_str(database,person,person_name=None,empty_date="",empty_place=""): + """ + Check birth record. + Statement formats name precedes this + was born on Date. + was born on Date in Place. + was born in Month_Year. + was born in Month_Year in Place. + was born in Place. + '' + """ + + if person_name == None: + person_name = _nd.display_name(person.get_primary_name()) + elif person_name == 0: + if person.get_gender() == RelLib.Person.male: + person_name = _('He') + else: + person_name = _('She') + + text = "" + + bdate,bplace,bdate_full,ddate,dplace,ddate_full = \ + get_birth_death_strings(database,person,empty_date,empty_place) + + if person.get_gender() == RelLib.Person.male: + if bdate and bdate_full: + if bplace: #male, date, place + text = _("%(male_name)s " + "was born on %(birth_date)s in %(birth_place)s.") % { + 'male_name' : person_name, + 'birth_date' : bdate, 'birth_place' : bplace } + else: #male, date, no place + text = _("%(male_name)s was born on %(birth_date)s.") % { + 'male_name' : person_name, 'birth_date' : bdate } + elif bdate: + if bplace: #male, month_year, place + text = _("%(male_name)s " + "was born in %(month_year)s in %(birth_place)s.") % { + 'male_name' : person_name, + 'month_year' : bdate, 'birth_place' : bplace } + else: #male, month_year, no place + text = _("%(male_name)s was born in %(month_year)s.") % { + 'male_name' : person_name, 'month_year' : bdate } + else: + if bplace: #male, no date, place + text = _("%(male_name)s was born in %(birth_place)s.") % { + 'male_name' : person_name, 'birth_place' : bplace } + else: #male, no date, no place + text = person_name + else: + if bdate and bdate_full: + if bplace: #female, date, place + text = _("%(female_name)s " + "was born on %(birth_date)s in %(birth_place)s.") % { + 'female_name' : person_name, + 'birth_date' : bdate, 'birth_place' : bplace } + else: #female, date, no place + text = _("%(female_name)s was born on %(birth_date)s.") % { + 'female_name' : person_name, 'birth_date' : bdate } + elif bdate: + if bplace: #female, month_year, place + text = _("%(female_name)s " + "was born in %(month_year)s in %(birth_place)s.") % { + 'female_name' : person_name, + 'month_year' : bdate, 'birth_place' : bplace } + else: #female, month_year, no place + text = _("%(female_name)s was born in %(month_year)s.") % { + 'female_name' : person_name, 'month_year' : bdate } + else: + if bplace: #female, no date, place + text = _("%(female_name)s was born in %(birth_place)s.") % { + 'female_name' : person_name, 'birth_place' : bplace } + else: #female, no date, no place + text = person_name + + if text: + text = text + " " + return text + +def died_str(database,person,person_name=None,empty_date="",empty_place="", + age=None,age_units=0): + """ + Write obit sentence. + FIRSTNAME died on Date + FIRSTNAME died on Date at the age of N Years + FIRSTNAME died on Date at the age of N Months + FIRSTNAME died on Date at the age of N Days + FIRSTNAME died on Date in Place + FIRSTNAME died on Date in Place at the age of N Years + FIRSTNAME died on Date in Place at the age of N Months + FIRSTNAME died on Date in Place at the age of N Days + FIRSTNAME died in Month_Year + FIRSTNAME died in Month_Year at the age of N Years + FIRSTNAME died in Month_Year at the age of N Months + FIRSTNAME died in Month_Year at the age of N Days + FIRSTNAME died in Month_Year in Place + FIRSTNAME died in Month_Year in Place at the age of N Years + FIRSTNAME died in Month_Year in Place at the age of N Months + FIRSTNAME died in Month_Year in Place at the age of N Days + FIRSTNAME died in Place + FIRSTNAME died in Place at the age of N Years + FIRSTNAME died in Place at the age of N Months + FIRSTNAME died in Place at the age of N Days + FIRSTNAME died + FIRSTNAME died at the age of N Years + FIRSTNAME died at the age of N Months + FIRSTNAME died at the age of N Days + """ + + if person_name == None: + person_name = _nd.display_name(person.get_primary_name()) + elif person_name == 0: + if person.get_gender() == RelLib.Person.male: + person_name = _('He') + else: + person_name = _('She') + + text = "" + + bdate,bplace,bdate_full,ddate,dplace,ddate_full = \ + get_birth_death_strings(database,person,empty_date,empty_place) + + if person.get_gender() == RelLib.Person.male: + if ddate and ddate_full: + if dplace: + if not age_units: #male, date, place, no age + text = _("%(male_name)s " + "died on %(death_date)s in %(death_place)s.") % { + 'male_name' : person_name, + 'death_date' : ddate, 'death_place' : dplace } + elif age_units == 1: #male, date, place, years + text = _("%(male_name)s " + "died on %(death_date)s in %(death_place)s " + "at the age of %(age)d years.") % { + 'male_name' : person_name, + 'death_date' : ddate, 'death_place' : dplace, + 'age' : age } + elif age_units == 2: #male, date, place, months + text = _("%(male_name)s " + "died on %(death_date)s in %(death_place)s " + "at the age of %(age)d months.") % { + 'male_name' : person_name, + 'death_date' : ddate, 'death_place' : dplace, + 'age' : age } + elif age_units == 3: #male, date, place, days + text = _("%(male_name)s " + "died on %(death_date)s in %(death_place)s " + "at the age of %(age)d days.") % { + 'male_name' : person_name, + 'death_date' : ddate, 'death_place' : dplace, + 'age' : age } + else: + if not age_units: #male, date, no place, no age + text = _("%(male_name)s died on %(death_date)s.") % { + 'male_name' : person_name, 'death_date' : ddate } + elif age_units == 1: #male, date, no place, years + text = _("%(male_name)s died on %(death_date)s" + "at the age of %(age)d years.") % { + 'male_name' : person_name, + 'death_date' : ddate, 'age' : age } + elif age_units == 2: #male, date, no place, months + text = _("%(male_name)s died on %(death_date)s " + "at the age of %(age)d months.") % { + 'male_name' : person_name, + 'death_date' : ddate, 'age' : age } + elif age_units == 3: #male, date, no place, days + text = _("%(male_name)s died on %(death_date)s " + "at the age of %(age)d days.") % { + 'male_name' : person_name, + 'death_date' : ddate, 'age' : age } + elif ddate: + if dplace: + if not age_units: #male, month_year, place, no age + text = _("%(male_name)s " + "died in %(month_year)s in %(death_place)s.") % { + 'male_name' : person_name, + 'month_year' : ddate, 'death_place' : dplace } + elif age_units == 1: #male, month_year, place, years + text = _("%(male_name)s " + "died in %(month_year)s in %(death_place)s " + "at the age of %(age)d years.") % { + 'male_name' : person_name, + 'month_year' : ddate, 'death_place' : dplace, + 'age' : age } + elif age_units == 2: #male, month_year, place, months + text = _("%(male_name)s " + "died in %(month_year)s in %(death_place)s " + "at the age of %(age)d mpnths.") % { + 'male_name' : person_name, + 'month_year' : ddate, 'death_place' : dplace, + 'age' : age } + elif age_units == 3: #male, month_year, place, days + text = _("%(male_name)s " + "died in %(month_year)s in %(death_place)s " + "at the age of %(age)d days.") % { + 'male_name' : person_name, + 'month_year' : ddate, 'death_place' : dplace, + 'age' : age } + else: + if not age_units: #male, month_year, no place, no age + text = _("%(male_name)s died in %(month_year)s.") % { + 'male_name' : person_name, 'month_year' : ddate } + elif age_units == 1: #male, month_year, no place, years + text = _("%(male_name)s died in %(month_year)s " + "at the age of %(age)d years.") % { + 'male_name' : person_name, + 'month_year' : ddate, 'age' : age } + elif age_units == 2: #male, month_year, no place, months + text = _("%(male_name)s died in %(month_year)s " + "at the age of %(age)d months.") % { + 'male_name' : person_name, + 'month_year' : ddate, 'age' : age } + elif age_units == 3: #male, month_year, no place, days + text = _("%(male_name)s died in %(month_year)s " + "at the age of %(age)d days.") % { + 'male_name' : person_name, + 'month_year' : ddate, 'age' : age } + else: + if dplace: + if not age_units: #male, no date, place, no age + text = _("%(male_name)s died in %(death_place)s.") % { + 'male_name' : person_name, 'death_place' : dplace } + elif age_units == 1: #male, no date, place, years + text = _("%(male_name)s died in %(death_place)s " + "at the age of %(age)d years.") % { + 'male_name' : person_name, 'death_place' : dplace, + 'age' : age } + elif age_units == 2: #male, no date, place, months + text = _("%(male_name)s died in %(death_place)s " + "at the age of %(age)d months.") % { + 'male_name' : person_name, 'death_place' : dplace, + 'age' : age } + elif age_units == 3: #male, no date, place, days + text = _("%(male_name)s died in %(death_place)s " + "at the age of %(age)d days.") % { + 'male_name' : person_name, 'death_place' : dplace, + 'age' : age } + else: + if not age_units: #male, no date, no place, no age + text = _("%(male_name)s died.") % { + 'male_name' : person_name } + elif age_units == 1: #male, no date, no place, years + text = _("%(male_name)s died " + "at the age of %(age)d years.") % { + 'male_name' : person_name, 'age' : age } + elif age_units == 2: #male, no date, no place, months + text = _("%(male_name)s died " + "at the age of %(age)d months.") % { + 'male_name' : person_name, 'age' : age } + elif age_units == 3: #male, no date, no place, days + text = _("%(male_name)s died " + "at the age of %(age)d days.") % { + 'male_name' : person_name, 'age' : age } + else: + if ddate and ddate_full: + if dplace: + if not age_units: #female, date, place, no age + text = _("%(female_name)s " + "died on %(death_date)s in %(death_place)s.") % { + 'female_name' : person_name, + 'death_date' : ddate, 'death_place' : dplace } + elif age_units == 1: #female, date, place, years + text = _("%(female_name)s " + "died on %(death_date)s in %(death_place)s " + "at the age of %(age)d years.") % { + 'female_name' : person_name, + 'death_date' : ddate, 'death_place' : dplace, + 'age' : age } + elif age_units == 2: #female, date, place, months + text = _("%(female_name)s " + "died on %(death_date)s in %(death_place)s " + "at the age of %(age)d months.") % { + 'female_name' : person_name, + 'death_date' : ddate, 'death_place' : dplace, + 'age' : age } + elif age_units == 3: #female, date, place, days + text = _("%(female_name)s " + "died on %(death_date)s in %(death_place)s " + "at the age of %(age)d days.") % { + 'female_name' : person_name, + 'death_date' : ddate, 'death_place' : dplace, + 'age' : age } + else: + if not age_units: #female, date, no place, no age + text = _("%(female_name)s died on %(death_date)s.") % { + 'female_name' : person_name, 'death_date' : ddate } + elif age_units == 1: #female, date, no place, years + text = _("%(female_name)s died on %(death_date)s " + "at the age of %(age)d years.") % { + 'female_name' : person_name, + 'death_date' : ddate, 'age' : age } + elif age_units == 2: #female, date, no place, months + text = _("%(female_name)s died on %(death_date)s " + "at the age of %(age)d months.") % { + 'female_name' : person_name, + 'death_date' : ddate, 'age' : age } + elif age_units == 3: #female, date, no place, days + text = _("%(female_name)s died on %(death_date)s " + "at the age of %(age)d days.") % { + 'female_name' : person_name, + 'death_date' : ddate, 'age' : age } + elif ddate: + if dplace: + if not age_units: #female, month_year, place, no age + text = _("%(female_name)s " + "died in %(month_year)s in %(death_place)s.") % { + 'female_name' : person_name, + 'month_year' : ddate, 'death_place' : dplace } + elif age_units == 1: #female, month_year, place, years + text = _("%(female_name)s " + "died in %(month_year)s in %(death_place)s " + "at the age of %(age)d years.") % { + 'female_name' : person_name, + 'month_year' : ddate, 'death_place' : dplace, + 'age' : age } + elif age_units == 2: #female, month_year, place, months + text = _("%(female_name)s " + "died in %(month_year)s in %(death_place)s " + "at the age of %(age)d mpnths.") % { + 'female_name' : person_name, + 'month_year' : ddate, 'death_place' : dplace, + 'age' : age } + elif age_units == 3: #female, month_year, place, days + text = _("%(female_name)s " + "died in %(month_year)s in %(death_place)s " + "at the age of %(age)d days.") % { + 'female_name' : person_name, + 'month_year' : ddate, 'death_place' : dplace, + 'age' : age } + else: + if not age_units: #female, month_year, no place, no age + text = _("%(female_name)s died in %(month_year)s.") % { + 'female_name' : person_name, 'month_year' : ddate } + elif age_units == 1: #female, month_year, no place, years + text = _("%(female_name)s died in %(month_year)s " + "at the age of %(age)d years.") % { + 'female_name' : person_name, + 'month_year' : ddate, 'age' : age } + elif age_units == 2: #female, month_year, no place, months + text = _("%(female_name)s died in %(month_year)s " + "at the age of %(age)d months.") % { + 'female_name' : person_name, + 'month_year' : ddate, 'age' : age } + elif age_units == 3: #female, month_year, no place, days + text = _("%(female_name)s died in %(month_year)s " + "at the age of %(age)d days.") % { + 'female_name' : person_name, + 'month_year' : ddate, 'age' : age } + else: + if dplace: + if not age_units: #female, no date, place, no age + text = _("%(female_name)s died in %(death_place)s.") % { + 'female_name' : person_name, 'death_place' : dplace } + elif age_units == 1: #female, no date, place, years + text = _("%(female_name)s died in %(death_place)s " + "at the age of %(age)d years.") % { + 'female_name' : person_name, 'death_place' : dplace, + 'age' : age } + elif age_units == 2: #female, no date, place, months + text = _("%(female_name)s died in %(death_place)s " + "at the age of %(age)d months.") % { + 'female_name' : person_name, 'death_place' : dplace, + 'age' : age } + elif age_units == 3: #female, no date, place, days + text = _("%(female_name)s died in %(death_place)s " + "at the age of %(age)d days.") % { + 'female_name' : person_name, 'death_place' : dplace, + 'age' : age } + else: + if not age_units: #female, no date, no place, no age + text = _("%(female_name)s died.") % { + 'female_name' : person_name } + elif age_units == 1: #female, no date, no place, years + text = _("%(female_name)s died " + "at the age of %(age)d years.") % { + 'female_name' : person_name, 'age' : age } + elif age_units == 2: #female, no date, no place, months + text = _("%(female_name)s died " + "at the age of %(age)d months.") % { + 'female_name' : person_name, 'age' : age } + elif age_units == 3: #female, no date, no place, days + text = _("%(female_name)s died " + "at the age of %(age)d days.") % { + 'female_name' : person_name, 'age' : age } + if text: + text = text + " " + return text + +def buried_str(database,person,person_name=None,empty_date="",empty_place=""): + """ + Check burial record. + Statement formats name precedes this + was buried on Date. + was buried on Date in Place. + was buried in Month_Year. + was buried in Month_Year in Place. + was buried in Place. + '' + """ + + if person_name == None: + person_name = _nd.display_name(person.get_primary_name()) + elif person_name == 0: + if person.get_gender() == RelLib.Person.male: + person_name = _('He') + else: + person_name = _('She') + + text = "" + + bplace = dplace = empty_place + bdate = ddate = empty_date + bdate_full = False + + burial = None + for event_handle in person.get_event_list(): + event = database.get_event_from_handle(event_handle) + if event and event.get_name() == "Burial": + burial = event + break + + if burial: + bdate = burial.get_date() + bplace_handle = burial.get_place_handle() + if bplace_handle: + bplace = database.get_place_from_handle(bplace_handle).get_title() + bdate_obj = burial.get_date_object() + bdate_full = bdate_obj and bdate_obj.get_day_valid() + else: + return text + + if person.get_gender() == RelLib.Person.male: + if bdate and bdate_full: + if bplace: #male, date, place + text = _("%(male_name)s " + "was buried on %(birth_date)s in %(birth_place)s.") % { + 'male_name' : person_name, + 'birth_date' : bdate, 'birth_place' : bplace } + else: #male, date, no place + text = _("%(male_name)s was buried on %(birth_date)s.") % { + 'male_name' : person_name, 'birth_date' : bdate } + elif bdate: + if bplace: #male, month_year, place + text = _("%(male_name)s " + "was buried in %(month_year)s in %(birth_place)s.") % { + 'male_name' : person_name, + 'month_year' : bdate, 'birth_place' : bplace } + else: #male, month_year, no place + text = _("%(male_name)s was buried in %(month_year)s.") % { + 'male_name' : person_name, 'month_year' : bdate } + else: + if bplace: #male, no date, place + text = _("%(male_name)s was buried in %(birth_place)s.") % { + 'male_name' : person_name, 'birth_place' : bplace } + else: #male, no date, no place + text = _("%(male_name)s was buried.") % { + 'male_name' : person_name } + else: + if bdate and bdate_full: + if bplace: #female, date, place + text = _("%(female_name)s " + "was buried on %(birth_date)s in %(birth_place)s.") % { + 'female_name' : person_name, + 'birth_date' : bdate, 'birth_place' : bplace } + else: #female, date, no place + text = _("%(female_name)s was buried on %(birth_date)s.") % { + 'female_name' : person_name, 'birth_date' : bdate } + elif bdate: + if bplace: #female, month_year, place + text = _("%(female_name)s " + "was buried in %(month_year)s in %(birth_place)s.") % { + 'female_name' : person_name, + 'month_year' : bdate, 'birth_place' : bplace } + else: #female, month_year, no place + text = _("%(female_name)s was buried in %(month_year)s.") % { + 'female_name' : person_name, 'month_year' : bdate } + else: + if bplace: #female, no date, place + text = _("%(female_name)s was buried in %(birth_place)s.") % { + 'female_name' : person_name, 'birth_place' : bplace } + else: #female, no date, no place + text = _("%(female_name)s was buried.") % { + 'female_name' : person_name } + + if text: + text = text + " " return text #------------------------------------------------------------------------- diff --git a/src/docgen/LPRDoc.py b/src/docgen/LPRDoc.py index 16137cb7c..c1c6124a3 100644 --- a/src/docgen/LPRDoc.py +++ b/src/docgen/LPRDoc.py @@ -1070,13 +1070,28 @@ class LPRDoc(BaseDoc.BaseDoc): fontstyle = para_style.get_font() self.gpc.setfont(find_font_from_fontstyle(fontstyle)) - self.gpc.moveto(cm2u(x), cm2u(y)) + x = self.left_margin + cm2u(x) + y = self.top_margin - cm2u(y) + self.gpc.moveto(x,y) self.gpc.show(text) def draw_bar(self, style, x1, y1, x2, y2): self.brand_new_page = 0 - self.gpc.moveto(x1, y1) - self.gpc.lineto(x2, y2) + + style = self.draw_styles[style] + fill_color = [ val/255.0 for val in style.get_fill_color() ] + color = [ val/255.0 for val in style.get_color() ] + + x = self.left_margin + cm2u(x1) + y = self.top_margin - cm2u(y1) + bh = cm2u(y2-y1) + bw = cm2u(x2-x1) + + self.gpc.setrgbcolor(color[0],color[1],color[2]) + self.gpc.rect_stroked(x,y,bw,-bh) + self.gpc.setrgbcolor(fill_color[0],fill_color[1],fill_color[2]) + self.gpc.rect_filled(x,y,bw,-bh) + self.gpc.setrgbcolor(0,0,0) def draw_text(self,style,text,x,y): self.brand_new_page = 0 diff --git a/src/docgen/OpenOfficeDoc.py b/src/docgen/OpenOfficeDoc.py index 9bc4d31a0..bcbdd91bd 100644 --- a/src/docgen/OpenOfficeDoc.py +++ b/src/docgen/OpenOfficeDoc.py @@ -143,11 +143,11 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.cntnt.write('') self.cntnt.write('\n') - for style_name in self.draw_styles.keys(): + for style_name in self.draw_styles.keys(): style = self.draw_styles[style_name] self.cntnt.write('\n') - self.cntnt.write('\n') + self.cntnt.write('\n') - self.cntnt.write('\n') + self.cntnt.write('/>\n') + self.cntnt.write('\n') self.cntnt.write('\n') - self.cntnt.write('\n') + self.cntnt.write('\n') - self.cntnt.write('\n') + self.cntnt.write('/>\n') + self.cntnt.write('\n') for style_name in self.style_list.keys(): - style = self.style_list[style_name] + style = self.style_list[style_name] self.cntnt.write('\n' % style_name) @@ -190,13 +190,13 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.cntnt.write(' 0: self.cntnt.write('fo:keep-with-next="true" ') align = style.get_alignment() - if align == BaseDoc.PARA_ALIGN_LEFT: - self.cntnt.write('fo:text-align="start" ') + if align == BaseDoc.PARA_ALIGN_LEFT: + self.cntnt.write('fo:text-align="start" ') elif align == BaseDoc.PARA_ALIGN_RIGHT: self.cntnt.write('fo:text-align="end" ') elif align == BaseDoc.PARA_ALIGN_CENTER: @@ -213,13 +213,13 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.cntnt.write('fo:font-size="%dpt" ' % font.get_size()) self.cntnt.write('style:font-size-asian="%dpt" ' % font.get_size()) color = font.get_color() - self.cntnt.write('fo:color="#%02x%02x%02x" ' % color) + self.cntnt.write('fo:color="#%02x%02x%02x" ' % color) if font.get_bold(): self.cntnt.write('fo:font-weight="bold" ') if font.get_italic(): self.cntnt.write('fo:font-style="italic" ') - if font.get_underline(): - self.cntnt.write('style:text-underline="single" ') + if font.get_underline(): + self.cntnt.write('style:text-underline="single" ') self.cntnt.write('style:text-underline-color="font-color" ') self.cntnt.write('fo:text-indent="%.2fcm" ' % style.get_first_indent()) self.cntnt.write('fo:margin-right="%.2fcm" ' % style.get_right_margin()) @@ -233,8 +233,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.cntnt.write('style:family="text">\n') self.cntnt.write(' ' % font.get_size()) self.cntnt.write('\n') - for style_name in self.table_styles.keys(): - style = self.table_styles[style_name] + for style_name in self.table_styles.keys(): + style = self.table_styles[style_name] self.cntnt.write('\n') + self.cntnt.write('style:family="table">\n') table_width = float(self.get_usable_width()) table_width_str = "%.4f" % table_width - self.cntnt.write('\n') self.cntnt.write('\n') - for col in range(0,style.get_columns()): - self.cntnt.write('') + for col in range(0,style.get_columns()): + self.cntnt.write('') width = table_width * float(style.get_column_width(col)/100.0) width_str = "%.4f" % width - self.cntnt.write('' % width_str) - self.cntnt.write('\n') + self.cntnt.write('\n') for cell in self.cell_styles.keys(): cell_style = self.cell_styles[cell] @@ -425,11 +425,11 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): def start_table(self,name,style_name): self.cntnt.write('\n' % style_name) - table = self.table_styles[style_name] - for col in range(0,table.get_columns()): - self.cntnt.write('\n') + self.cntnt.write('table:style-name="%s">\n' % style_name) + table = self.table_styles[style_name] + for col in range(0,table.get_columns()): + self.cntnt.write('\n') def end_table(self): self.cntnt.write('\n') @@ -441,13 +441,13 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.cntnt.write('\n') def start_cell(self,style_name,span=1): - self.span = span - self.cntnt.write(' 1: self.cntnt.write(' table:number-columns-spanned="%s">\n' % span) - else: - self.cntnt.write('>\n') + else: + self.cntnt.write('>\n') self.new_cell = 1 def end_cell(self): @@ -550,13 +550,13 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.sfile.write(' 0: self.sfile.write('fo:keep-with-next="true" ') align = style.get_alignment() - if align == BaseDoc.PARA_ALIGN_LEFT: - self.sfile.write('fo:text-align="start" ') + if align == BaseDoc.PARA_ALIGN_LEFT: + self.sfile.write('fo:text-align="start" ') elif align == BaseDoc.PARA_ALIGN_RIGHT: self.sfile.write('fo:text-align="end" ') elif align == BaseDoc.PARA_ALIGN_CENTER: @@ -572,13 +572,13 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.sfile.write('style:font-name="Times New Roman" ') self.sfile.write('fo:font-size="' + str(font.get_size()) + 'pt" ') color = font.get_color() - self.sfile.write('fo:color="#%02x%02x%02x" ' % color) + self.sfile.write('fo:color="#%02x%02x%02x" ' % color) if font.get_bold(): self.sfile.write('fo:font-weight="bold" ') if font.get_italic(): self.sfile.write('fo:font-style="italic" ') - if font.get_underline(): - self.sfile.write('style:text-underline="single" ') + if font.get_underline(): + self.sfile.write('style:text-underline="single" ') self.sfile.write('style:text-underline-color="font-color" ') self.sfile.write('fo:text-indent="%.2fcm" ' % style.get_first_indent()) self.sfile.write('fo:margin-right="%.2fcm" ' % style.get_right_margin()) @@ -588,20 +588,20 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.sfile.write('/>\n') self.sfile.write('\n') - # Current no leading number format for headers + # Current no leading number format for headers - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') self.sfile.write('\n') self.sfile.write('\n') @@ -631,20 +631,20 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.sfile.write('\n') self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') - self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') self.sfile.write('\n') self.sfile.write('\n') @@ -658,19 +658,19 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.cntnt.write('\n') def start_paragraph(self,style_name,leader=None): - style = self.style_list[style_name] - self.level = style.get_header_level() + style = self.style_list[style_name] + self.level = style.get_header_level() if self.new_page == 1: self.new_page = 0 name = "NL%s" % style_name else: name = style_name - if self.level == 0: - self.cntnt.write('' % name) - else: - self.cntnt.write('' % name) + else: + self.cntnt.write('\n') + self.cntnt.write('" text:level="' + str(self.level) + '">\n') if leader != None: self.cntnt.write(leader) self.cntnt.write('\n') @@ -718,17 +718,17 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): text = text.replace('<super>', '') text = text.replace('</super>','') - self.cntnt.write(text) + self.cntnt.write(text) def _write_manifest(self): self.mfile = StringIO() - self.mfile.write('\n') - self.mfile.write('\n') + self.mfile.write('') - self.mfile.write('') + self.mfile.write('manifest:full-path="/"/>') for image in self.media_list: i = image[0] base = os.path.basename(i) @@ -737,58 +737,58 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.mfile.write(base) self.mfile.write('"/>') self.mfile.write('') - self.mfile.write('') - self.mfile.write('') - self.mfile.write('') - self.mfile.write('\n') + self.mfile.write('manifest:full-path="Pictures/"/>') + self.mfile.write('') + self.mfile.write('') + self.mfile.write('') + self.mfile.write('\n') def _write_meta_file(self): self.meta = StringIO() - self.meta.write('\n') - self.meta.write('\n'); - self.meta.write('\n') - self.meta.write('') + self.meta.write('\n') + self.meta.write('\n'); + self.meta.write('\n') + self.meta.write('') self.meta.write(const.progName + ' ' + const.version) self.meta.write('\n') - self.meta.write('') - self.meta.write(self.name) - self.meta.write('\n') - self.meta.write('') - self.meta.write(self.time) - self.meta.write('\n') - self.meta.write('') - self.meta.write(self.name) - self.meta.write('\n') - self.meta.write('') - self.meta.write(self.time) - self.meta.write('\n') - self.meta.write('0-00-00T00:00:00\n') - self.meta.write('%s\n' % self.lang) - self.meta.write('1\n') - self.meta.write('PT0S\n') - self.meta.write('\n') - self.meta.write('\n') - self.meta.write('\n') - self.meta.write('\n') - self.meta.write('\n') - self.meta.write('\n') + self.meta.write('') + self.meta.write(self.name) + self.meta.write('\n') + self.meta.write('') + self.meta.write(self.time) + self.meta.write('\n') + self.meta.write('') + self.meta.write(self.name) + self.meta.write('\n') + self.meta.write('') + self.meta.write(self.time) + self.meta.write('\n') + self.meta.write('0-00-00T00:00:00\n') + self.meta.write('%s\n' % self.lang) + self.meta.write('1\n') + self.meta.write('PT0S\n') + self.meta.write('\n') + self.meta.write('\n') + self.meta.write('\n') + self.meta.write('\n') + self.meta.write('\n') + self.meta.write('\n') def rotate_text(self,style,text,x,y,angle): stype = self.draw_styles[style] pname = stype.get_paragraph_style() p = self.style_list[pname] - font = p.get_font() + font = p.get_font() size = font.get_size() height = size*(len(text)) @@ -829,7 +829,7 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): maxy = max(point[1],maxy) self.cntnt.write('\n') def draw_text(self,style,text,x,y): - box_style = self.draw_styles[style] - para_name = box_style.get_paragraph_style() + box_style = self.draw_styles[style] + para_name = box_style.get_paragraph_style() pstyle = self.style_list[para_name] font = pstyle.get_font() @@ -869,14 +869,14 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): sw = pt2cm(FontScale.string_width(font,text))*1.3 - self.cntnt.write('' % float(y)) self.cntnt.write('' % para_name) self.cntnt.write('' % para_name) @@ -885,20 +885,20 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.cntnt.write('\n') def draw_bar(self,style,x,y,x2,y2): - box_style = self.draw_styles[style] + box_style = self.draw_styles[style] - self.cntnt.write('' % float(y)) self.cntnt.write('\n') def draw_box(self,style,text,x,y): - box_style = self.draw_styles[style] - para_name = box_style.get_paragraph_style() + box_style = self.draw_styles[style] + para_name = box_style.get_paragraph_style() shadow_width = box_style.get_shadow_space() if box_style.get_shadow(): @@ -912,66 +912,64 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.cntnt.write('svg:y="%.3fcm">\n' % (float(y)+shadow_width)) self.cntnt.write('\n') - self.cntnt.write('\n' % float(y)) - if text != "": - self.cntnt.write('' % para_name) + if text != "": + self.cntnt.write('' % para_name) self.cntnt.write('' % para_name) text = text.replace('\t','') text = text.replace('\n','') - self.cntnt.write(text) + self.cntnt.write(text) self.cntnt.write('') self.cntnt.write('\n') self.cntnt.write('\n') def center_text(self,style,text,x,y): - box_style = self.draw_styles[style] - para_name = box_style.get_paragraph_style() + box_style = self.draw_styles[style] + para_name = box_style.get_paragraph_style() pstyle = self.style_list[para_name] font = pstyle.get_font() size = 1.1*(FontScale.string_width(font,text)/72.0) * 2.54 - self.cntnt.write('\n' % float(y)) - if text != "": - self.cntnt.write('' % para_name) - self.cntnt.write(text) + if text != "": + self.cntnt.write('' % para_name) + self.cntnt.write(text) self.cntnt.write('\n') self.cntnt.write('\n') def write_at(self,style,text,x,y): - box_style = self.draw_styles[style] - para_name = box_style.get_paragraph_style() - pstyle = self.style_list[para_name] + pstyle = self.style_list[style] font = pstyle.get_font() size = 1.1*(FontScale.string_width(font,text)/72.0) * 2.54 - self.cntnt.write('\n' % float(y)) - if text != "": - self.cntnt.write('' % para_name) - self.cntnt.write(text) + if text != "": + self.cntnt.write('' % style) + self.cntnt.write(text) self.cntnt.write('\n') self.cntnt.write('\n') diff --git a/src/plugins/StatisticsChart.py b/src/plugins/StatisticsChart.py index ec6694db4..7cf87d2bb 100755 --- a/src/plugins/StatisticsChart.py +++ b/src/plugins/StatisticsChart.py @@ -91,49 +91,49 @@ class Extract: def __init__(self): """Methods for extracting statistical data from the database""" - # key, non-localized name, localized name, type method, data method + # key, non-localized name, localized name, type method, data method self.extractors = { 'data_title': ("Titles", _("Titles"), - self.get_person, self.get_title), + self.get_person, self.get_title), 'data_fname': ("Forenames", _("Forenames"), - self.get_person, self.get_forename), + self.get_person, self.get_forename), 'data_gender': ("Genders", _("Genders"), - self.get_person, self.get_gender), + self.get_person, self.get_gender), 'data_byear': ("Birth years", _("Birth years"), - self.get_birth, self.get_year), + self.get_birth, self.get_year), 'data_dyear': ("Death years", _("Death years"), - self.get_death, self.get_year), + self.get_death, self.get_year), 'data_bmonth': ("Birth months", _("Birth months"), - self.get_birth, self.get_month), + self.get_birth, self.get_month), 'data_dmonth': ("Death months", _("Death months"), - self.get_death, self.get_month), + self.get_death, self.get_month), 'data_dcause': ("Causes of death", _("Causes of death"), - self.get_death, self.get_cause), + self.get_death, self.get_cause), 'data_bplace': ("Birth places", _("Birth places"), - self.get_birth, self.get_place), + self.get_birth, self.get_place), 'data_dplace': ("Death places", _("Death places"), - self.get_death, self.get_place), + self.get_death, self.get_place), 'data_mplace': ("Marriage places", _("Marriage places"), - self.get_marriage_handles, self.get_places), + self.get_marriage_handles, self.get_places), 'data_fchild': ("Ages when first child born", _("Ages when first child born"), - self.get_child_handles, self.get_first_child_age), + self.get_child_handles, self.get_first_child_age), 'data_lchild': ("Ages when last child born", _("Ages when last child born"), - self.get_child_handles, self.get_last_child_age), + self.get_child_handles, self.get_last_child_age), 'data_ccount': ("Number of children", _("Number of children"), - self.get_child_handles, self.get_child_count), + self.get_child_handles, self.get_child_count), 'data_mage': ("Marriage ages", _("Marriage ages"), - self.get_marriage_handles, self.get_event_ages), + self.get_marriage_handles, self.get_event_ages), 'data_dage': ("Ages at death", _("Ages at death"), - self.get_person, self.get_death_age), + self.get_person, self.get_death_age), 'data_age': ("Ages", _("Ages"), - self.get_person, self.get_person_age) + self.get_person, self.get_person_age) } # ----------------- data extraction methods -------------------- # take an object and return a list of strings def get_title(self, person): - "return title for given person" + "return title for given person" # TODO: return all titles, not just primary ones... title = person.get_primary_name().get_title() if title: @@ -142,7 +142,7 @@ class Extract: return [_("(Preferred) title missing")] def get_forename(self, person): - "return forenames for given person" + "return forenames for given person" # TODO: return all forenames, not just primary ones... firstnames = person.get_primary_name().get_first_name().strip() if firstnames: @@ -151,7 +151,7 @@ class Extract: return [_("(Preferred) forename missing")] def get_gender(self, person): - "return gender for given person" + "return gender for given person" # TODO: why there's no Person.getGenderName? # It could be used by getDisplayInfo & this... if person.gender == Person.male: @@ -161,37 +161,37 @@ class Extract: return [_("Gender unknown")] def get_year(self, event): - "return year for given event" - date = event.get_date_object() - if date: + "return year for given event" + date = event.get_date_object() + if date: year = date.get_year() if year: return [str(year)] return [_("Date(s) missing")] def get_month(self, event): - "return month for given event" - date = event.get_date_object() - if date: + "return month for given event" + date = event.get_date_object() + if date: month = date.get_month() if month: return [_dd._months[month]] return [_("Date(s) missing")] def get_cause(self, event): - "return cause for given event" - cause = event.get_cause() - if cause: - return [cause] + "return cause for given event" + cause = event.get_cause() + if cause: + return [cause] return [_("Cause missing")] def get_place(self, event): - "return place for given event" - place_handle = event.get_place_handle() - if place_handle: + "return place for given event" + place_handle = event.get_place_handle() + if place_handle: place = self.db.get_place_from_handle(place_handle).get_title() - if place: - return [place] + if place: + return [place] return [_("Place missing")] def get_places(self, data): @@ -210,16 +210,16 @@ class Extract: return places def get_person_age(self, person): - "return age for given person, if alive" - death = person.get_death_handle() - if not death: + "return age for given person, if alive" + death = person.get_death_handle() + if not death: return [self.estimate_age(person)] return [_("Already dead")] def get_death_age(self, person): - "return age at death for given person, if dead" - death_handle = person.get_death_handle() - if death_handle: + "return age at death for given person, if dead" + death_handle = person.get_death_handle() + if death_handle: return [self.estimate_age(person, death_handle)] return [_("Still alive")] @@ -231,7 +231,7 @@ class Extract: ages.append(self.estimate_age(person, event_handle)) if ages: return ages - return [_("Events missing")] + return [_("Events missing")] def get_first_child_age(self, data): "return age when first child in given (person,child_handles) was born" @@ -264,8 +264,8 @@ class Extract: child = self.db.get_person_from_handle(child_handle) birth_handle = child.get_birth_handle() if birth_handle: - ages.append(self.estimate_age(person, birth_handle)) - else: + ages.append(self.estimate_age(person, birth_handle)) + else: errors.append(_("Birth missing")) continue ages.sort() @@ -289,8 +289,8 @@ class Extract: # take db and person and return suitable gramps object(s) def get_person(self, person): - "return person" - return person + "return person" + return person def get_birth(self, person): "return birth event for given person or None" @@ -345,12 +345,12 @@ class Extract: for chart in collect: # get the information type_func = chart[2] - data_func = chart[3] - obj = type_func(person) # e.g. get_date() - if obj: - value = data_func(obj) # e.g. get_year() - else: - value = [_("Personal information missing")] + data_func = chart[3] + obj = type_func(person) # e.g. get_date() + if obj: + value = data_func(obj) # e.g. get_year() + else: + value = [_("Personal information missing")] # list of information found for key in value: if key in chart[1].keys(): @@ -371,13 +371,13 @@ class Extract: year_from - use only persons who've born this year of after year_to - use only persons who've born this year or before no_years - use also people without any birth year - - Returns an array of tuple of: - - Extraction method title - - Dict of values with their counts - (- Method) + + Returns an array of tuple of: + - Extraction method title + - Dict of values with their counts + (- Method) """ - self.db = db # store for use by methods + self.db = db # store for use by methods data = [] ext = self.extractors @@ -396,16 +396,16 @@ class Extract: continue # check whether birth year is within required range - birth = self.get_birth(person).get_date_object() - if birth: + birth = self.get_birth(person).get_date_object() + if birth: if birth.get_year_valid(): year = birth.get_year() if not (year >= year_from and year <= year_to): continue else: # if death before range, person's out of range too... - death = self.get_death(person).get_date_object() - if death: + death = self.get_death(person).get_date_object() + if death: if death.get_year_valid() and death.get_year() < year_from: continue if not no_years: @@ -465,7 +465,7 @@ class StatisticsChart(Report.Report): 'genders': genders, 'year_from': year_from, 'year_to': year_to - } + } # extract requested items from the database and count them tables = _Extract.collect_data(database, filterfun, options, @@ -484,9 +484,9 @@ class StatisticsChart(Report.Report): else: heading = "Persons born %(year_from)04d-%(year_to)04d: %(chart_title)s" % mapping self.data.append((heading, table[1], lookup)) - #DEBUG - #print heading - #print table[1] + #DEBUG + #print heading + #print table[1] def lookup_compare(self, a, b): @@ -541,7 +541,7 @@ class StatisticsChart(Report.Report): g.set_line_width(0) self.doc.add_draw_style("SC-text",g) - width = 0.8 + width = 0.8 self.colors = 7 # red g = BaseDoc.GraphicsStyle() @@ -635,7 +635,7 @@ class StatisticsChart(Report.Report): yoffset = yoffset + 1 + radius ReportUtils.draw_pie_chart(self.doc, middle, yoffset, radius, chart_data, -90) yoffset = yoffset + radius + 1 - ReportUtils.draw_legend(self.doc, 2, yoffset, chart_data) + ReportUtils.draw_legend(self.doc, 2, yoffset, chart_data) def output_barchart(self, title, data, lookup): @@ -710,7 +710,7 @@ class StatisticsChartOptions(ReportOptions.ReportOptions): 'year_from' : 1700, 'year_to' : time.localtime()[0], 'no_years' : 0, - 'bar_items' : 8 + 'bar_items' : 8 } for key in _Extract.extractors: self.options_dict[key] = 0 @@ -732,7 +732,7 @@ class StatisticsChartOptions(ReportOptions.ReportOptions): "Smaller than %d" % self.options_dict['year_to']), 'no_years' : ("=0/1", "Whether to include people without birth years", ["Do not include", "Include"], True), - 'bar_items' : ("=num", "Use barchart instead of piechart with this many or more items", + 'bar_items' : ("=num", "Use barchart instead of piechart with this many or more items", "Number of items with which piecharts still look good...") } for key in _Extract.extractors: @@ -740,14 +740,14 @@ class StatisticsChartOptions(ReportOptions.ReportOptions): ["Leave char with this data out", "Include chart with this data"], True) - + def enable_options(self): # Semi-common options that should be enabled for this report self.enable_dict = { 'filter' : 0, } - + def make_default_style(self, default_style): """Make the default output style for the Statistics report.""" f = BaseDoc.FontStyle() @@ -768,7 +768,7 @@ class StatisticsChartOptions(ReportOptions.ReportOptions): p.set_description(_("The style used for the title of the page.")) default_style.add_style("SC-Title",p) - + def get_report_filters(self, person): """Set up the list of possible content filters.""" @@ -855,12 +855,12 @@ class StatisticsChartOptions(ReportOptions.ReportOptions): tip = _("With fewer items pie chart and legend will be used instead of a bar chart.") self.bar_items = gtk.Entry(2) self.bar_items.set_text(str(self.options_dict['bar_items'])) - dialog.add_option("Min. bar char items", self.bar_items, tip) + dialog.add_option("Min. bar char items", self.bar_items, tip) # ------------------------------------------------- # List of available charts on a separate option tab - idx = 0 - half = (len(_Extract.extractors)+1)/2 + idx = 0 + half = (len(_Extract.extractors)+1)/2 hbox = gtk.HBox() vbox = gtk.VBox() self.charts = {} @@ -868,21 +868,21 @@ class StatisticsChartOptions(ReportOptions.ReportOptions): check = gtk.CheckButton(_Extract.extractors[key][1]) check.set_active(self.options_dict[key]) self.charts[key] = check - vbox.add(check) - idx += 1 - if idx == half: - hbox.add(vbox) - vbox = gtk.VBox() + vbox.add(check) + idx += 1 + if idx == half: + hbox.add(vbox) + vbox = gtk.VBox() hbox.add(vbox) - tip = _("Mark checkboxes to add charts with indicated data") - dialog.add_frame_option("Chart Selection", "", hbox, tip) + tip = _("Mark checkboxes to add charts with indicated data") + dialog.add_frame_option("Chart Selection", "", hbox, tip) hbox.show_all() # Note about children label = gtk.Label(_("Note that both biological and adopted children are taken into account.")) - dialog.add_frame_option("Chart Selection", "", label) + dialog.add_frame_option("Chart Selection", "", label) - + def parse_user_options(self, dialog): """ Parses the custom options that we have added.