more pylint changes: some reformats, some new ones, some 9535 bug fixes

This commit is contained in:
Paul Franklin 2016-06-20 13:31:35 -07:00
parent 8e7d5f5f14
commit 597c48b66b
16 changed files with 207 additions and 192 deletions

View File

@ -385,8 +385,8 @@ class OptionHandler:
and option_data[0] in docgen_names):
print(_("Option '%(opt_name)s' is present in %(file)s\n"
" but is not known to the module. Ignoring..."
% {'opt_name' : option_name,
'file' : self.option_list_collection.filename}),
) % {'opt_name' : option_name,
'file' : self.option_list_collection.filename},
file=sys.stderr)
options.pop(option_name)

View File

@ -75,8 +75,8 @@ class LastNameDialog(ManagedWindow):
ManagedWindow.__init__(self, uistate, track, self)
flags = Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT
buttons = (_('_Cancel'), Gtk.ResponseType.REJECT, _('_OK'),
Gtk.ResponseType.ACCEPT)
buttons = (_('_Cancel'), Gtk.ResponseType.REJECT,
_('_OK'), Gtk.ResponseType.ACCEPT)
self.__dlg = Gtk.Dialog(None, uistate.window, flags, buttons)
self.__dlg.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
self.set_window(self.__dlg, None, _('Select surname'))
@ -890,11 +890,10 @@ class GuiFamilyOption(Gtk.Box):
else:
mother_name = _("unknown mother")
name = _(
"%(father_name)s and %(mother_name)s (%(family_id)s)") % {
'father_name': father_name,
'mother_name': mother_name,
'family_id': family_id}
name = _("%(father_name)s and %(mother_name)s (%(family_id)s)"
) % {'father_name' : father_name,
'mother_name' : mother_name,
'family_id' : family_id}
self.__family_label.set_text(name)
self.__option.set_value(family_id)

View File

@ -21,14 +21,14 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" The ReportDialog base class """
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
import os
import threading
import time
import logging
LOG = logging.getLogger(".")
@ -45,17 +45,18 @@ from gi.repository import Gtk
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale, URL_MANUAL_PAGE
from gramps.gen.const import GRAMPS_LOCALE as glocale, URL_MANUAL_PAGE
_ = glocale.translation.gettext
from gramps.gen.config import config
from gramps.gen.errors import DatabaseError, FilterError, ReportError, WindowActiveError
from gramps.gen.errors import (DatabaseError, FilterError, ReportError,
WindowActiveError)
from ...utils import open_file_with_default_application
from .. import add_gui_options, make_gui_option
from ...user import User
from ...dialog import ErrorDialog, OptionDialog
from gramps.gen.plug.report import (CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK,
CATEGORY_CODE, CATEGORY_WEB, CATEGORY_GRAPHVIZ,
standalone_categories)
CATEGORY_CODE, CATEGORY_WEB,
CATEGORY_GRAPHVIZ, standalone_categories)
from gramps.gen.plug.docgen import StyleSheet, StyleSheetList
from ...managedwindow import ManagedWindow
from ._stylecombobox import StyleComboBox
@ -192,7 +193,8 @@ class ReportDialog(ManagedWindow):
self.notebook.set_border_width(6)
try:
#assume a vbox or hbox
self.window.vbox.pack_start(self.notebook, expand=True, fill=True, padding=0)
self.window.vbox.pack_start(self.notebook,
expand=True, fill=True, padding=0)
except:
#general container instead:
self.window.vbox.add(self.notebook)
@ -203,7 +205,8 @@ class ReportDialog(ManagedWindow):
try:
#assume a vbox or hbox
self.window.vbox.pack_start(self.grid, expand=True, fill=True, padding=0)
self.window.vbox.pack_start(self.grid,
expand=True, fill=True, padding=0)
except:
#general container instead:
self.window.vbox.add(self.grid)
@ -333,8 +336,7 @@ class ReportDialog(ManagedWindow):
# includes the default style set and any style sets saved from
# previous invocations of gramps.
self.style_sheet_list = StyleSheetList(
self.options.handler.get_stylesheet_savefile(),
self.default_style)
self.options.handler.get_stylesheet_savefile(), self.default_style)
# Now build the actual menu.
style = self.options.handler.get_default_stylesheet_name()
@ -504,14 +506,14 @@ class ReportDialog(ManagedWindow):
# selected path is an existing file and we need a file
if os.path.isfile(self.target_path):
a = OptionDialog(_('File already exists'),
_('You can choose to either overwrite the '
'file, or change the selected filename.'),
_('_Overwrite'), None,
_('_Change filename'), None,
parent=self.window)
aaa = OptionDialog(_('File already exists'),
_('You can choose to either overwrite the '
'file, or change the selected filename.'),
_('_Overwrite'), None,
_('_Change filename'), None,
parent=self.window)
if a.get_response() == Gtk.ResponseType.YES:
if aaa.get_response() == Gtk.ResponseType.YES:
return None
# selected path does not exist yet
@ -621,8 +623,7 @@ class ReportDialog(ManagedWindow):
def init_doc_options(self, option_class):
try:
if (issubclass(option_class, object) or # New-style class
isinstance(option_class, ClassType)): # Old-style class
if issubclass(option_class, object):
self.doc_options = option_class(self.raw_name, self.db)
except TypeError:
self.doc_options = option_class
@ -692,29 +693,29 @@ def report(dbstate, uistate, person, report_class, options_class,
dialog.close()
try:
user = User(uistate=uistate)
MyReport = report_class(dialog.db, dialog.options, user)
MyReport.doc.init()
MyReport.begin_report()
MyReport.write_report()
MyReport.end_report()
my_report = report_class(dialog.db, dialog.options, user)
my_report.doc.init()
my_report.begin_report()
my_report.write_report()
my_report.end_report()
# Web reports do not have a target frame
# The GtkPrint generator can not be "opened"
if hasattr(dialog, "open_with_app") and \
dialog.open_with_app.get_property('sensitive') == True and \
dialog.open_with_app.get_active():
if (hasattr(dialog, "open_with_app") and
dialog.open_with_app.get_property('sensitive') == True
and dialog.open_with_app.get_active()):
out_file = dialog.options.get_output()
open_file_with_default_application(out_file)
except FilterError as msg:
(m1, m2) = msg.messages()
ErrorDialog(m1, m2, parent=uistate.window)
(msg1, msg2) = msg.messages()
ErrorDialog(msg1, msg2, parent=uistate.window)
except IOError as msg:
ErrorDialog(_("Report could not be created"), str(msg),
parent=uistate.window)
except ReportError as msg:
(m1, m2) = msg.messages()
ErrorDialog(m1, m2, parent=uistate.window)
(msg1, msg2) = msg.messages()
ErrorDialog(msg1, msg2, parent=uistate.window)
except DatabaseError as msg:
ErrorDialog(_("Report could not be created"), str(msg),
parent=uistate.window)
@ -740,6 +741,7 @@ def report(dbstate, uistate, person, report_class, options_class,
#just stop, in ManagedWindow, delete-event is already coupled to
#correct action.
break
#do needed cleanup
dialog.db = None
dialog.options = None

View File

@ -768,8 +768,8 @@ class StatisticsChart(Report):
if value == living_value:
living_desc = self._(description)
break
self.living_desc = self._(
"(Living people: %(option_name)s)") % {'option_name': living_desc}
self.living_desc = self._("(Living people: %(option_name)s)"
) % {'option_name' : living_desc}
# title needs both data extraction method name + gender name
if gender == Person.MALE:
@ -788,10 +788,12 @@ class StatisticsChart(Report):
if genders:
span_string = self._("%(genders)s born "
"%(year_from)04d-%(year_to)04d" % mapping)
"%(year_from)04d-%(year_to)04d"
) % mapping
else:
span_string = self._("Persons born "
"%(year_from)04d-%(year_to)04d") % mapping
"%(year_from)04d-%(year_to)04d"
) % mapping
# extract requested items from the database and count them
self._user.begin_progress(_('Statistics Charts'),

View File

@ -250,8 +250,8 @@ class Printinfo:
self.doc.start_paragraph("DR-Spouse%d" % min(level, 32))
name = self._name_display.display(person)
self.doc.write_text(self._("sp. see %(reference)s: %(spouse)s"
% {'reference' : display_num,
'spouse' : name}),
) % {'reference' : display_num,
'spouse' : name},
mark)
self.doc.end_paragraph()
@ -309,7 +309,7 @@ class RecurseDown:
self.obj_print.print_spouse(level, spouse_handle, family)
if spouse_handle:
spouse_num = self._("%s sp." % (ref_str))
spouse_num = self._("%s sp.") % ref_str
self.person_printed[spouse_handle] = spouse_num
if level >= self.max_generations:

View File

@ -74,6 +74,7 @@ EMPTY_ENTRY = "_____________"
#
#------------------------------------------------------------------------
class DetAncestorReport(Report):
""" the Detailed Ancestor Report """
def __init__(self, database, options, user):
"""
@ -264,8 +265,8 @@ class DetAncestorReport(Report):
""" convenience function """
if first:
self.doc.start_paragraph('DAR-MoreHeader')
self.doc.write_text(self._('More about %(person_name)s:')
% {'person_name' : name})
self.doc.write_text(self._('More about %(person_name)s:'
) % {'person_name' : name})
self.doc.end_paragraph()
return False
@ -300,8 +301,8 @@ class DetAncestorReport(Report):
break
if self.map[key] == self.map[dkey]:
self.doc.write_text(
self._("%(name)s is the same person as [%(id_str)s].")
% {'name' : '', 'id_str' : str(dkey)})
self._("%(name)s is the same person as [%(id_str)s]."
) % {'name' : '', 'id_str' : str(dkey)})
self.doc.end_paragraph()
return 1 # Duplicate person
@ -360,10 +361,10 @@ class DetAncestorReport(Report):
self.doc.start_paragraph('DAR-MoreDetails')
atype = self._get_type(alt_name.get_type())
self.doc.write_text_citation(
self._('%(name_kind)s: %(name)s%(endnotes)s') % {
'name_kind' : self._(atype),
'name' : alt_name.get_regular_name(),
'endnotes' : self.endnotes(alt_name)})
self._('%(name_kind)s: %(name)s%(endnotes)s'
) % {'name_kind' : self._(atype),
'name' : alt_name.get_regular_name(),
'endnotes' : self.endnotes(alt_name)})
self.doc.end_paragraph()
if self.inc_events:
@ -411,10 +412,10 @@ class DetAncestorReport(Report):
self.doc.start_paragraph('DAR-MoreDetails')
attr_name = attr.get_type().type2base()
# translators: needed for French, ignore otherwise
text = self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : self._(attr_name),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr)}
text = self._("%(type)s: %(value)s%(endnotes)s"
) % {'type' : self._(attr_name),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr)}
self.doc.write_text_citation(text)
self.doc.end_paragraph()
@ -434,12 +435,13 @@ class DetAncestorReport(Report):
self.doc.start_paragraph('DAR-MoreDetails')
if date and place:
text += self._('%(date)s, %(place)s') % {
'date' : date, 'place' : place}
# translators: needed for Arabic, ignore otherwise
text += self._('%(str1)s, %(str2)s'
) % {'str1' : date, 'str2' : place}
elif date:
text += self._('%(date)s') % {'date' : date}
text += '%s' % date
elif place:
text += self._('%(place)s') % {'place' : place}
text += '%s' % self._(place)
if event.get_description():
if text:
@ -454,14 +456,14 @@ class DetAncestorReport(Report):
event_name = self._(self._get_type(event.get_type()))
role = event_ref.get_role()
if role in (EventRoleType.PRIMARY, EventRoleType.FAMILY):
text = self._('%(event_name)s: %(event_text)s') % {
'event_name' : event_name,
'event_text' : text}
# translators: needed for French, ignore otherwise
text = self._('%(str1)s: %(str2)s'
) % {'str1' : event_name, 'str2' : text}
else:
primaries = get_participant_from_event(self._db, event_ref.ref)
text = self._('%(event_role)s at %(event_name)s '
'of %(primary_person)s: %(event_text)s') % {
'event_role' : self._(role.xml_str()),
'of %(primary_person)s: %(event_text)s'
) % {'event_role' : self._(role.xml_str()),
'event_name' : event_name,
'primary_person' : primaries,
'event_text' : text}
@ -478,10 +480,10 @@ class DetAncestorReport(Report):
text += self._("; ")
attr_name = attr.get_type().type2base()
# translators: needed for French, ignore otherwise
text += self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : self._(attr_name),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr)}
text += self._("%(type)s: %(value)s%(endnotes)s"
) % {'type' : self._(attr_name),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr)}
text = " " + text
self.doc.write_text_citation(text)
@ -579,8 +581,9 @@ class DetAncestorReport(Report):
self.doc.start_paragraph("DAR-ChildTitle")
self.doc.write_text(
self._("Children of %(mother_name)s and %(father_name)s")
% {'father_name': father_name, 'mother_name': mother_name})
self._("Children of %(mother_name)s and %(father_name)s"
) % {'father_name' : father_name,
'mother_name' : mother_name})
self.doc.end_paragraph()
cnt = 1
@ -641,9 +644,9 @@ class DetAncestorReport(Report):
if first:
self.doc.start_paragraph('DAR-MoreHeader')
self.doc.write_text(
self._('More about %(mother_name)s and %(father_name)s:')
% {'mother_name' : mother_name,
'father_name' : father_name})
self._('More about %(mother_name)s and %(father_name)s:'
) % {'mother_name' : mother_name,
'father_name' : father_name})
self.doc.end_paragraph()
first = False
self.write_event(event_ref)
@ -696,10 +699,13 @@ class DetAncestorReport(Report):
mark = ReportUtils.get_person_mark(self._db, ind)
if family.get_relationship() == FamilyRelType.MARRIED:
self.doc.write_text(self._("Spouse: %s") % name, mark)
self.doc.write_text(self._("Spouse: %s"
) % name,
mark)
else:
self.doc.write_text(self._("Relationship with: %s")
% name, mark)
self.doc.write_text(self._("Relationship with: %s"
) % name,
mark)
if name[-1:] != '.':
self.doc.write_text(".")
self.doc.write_text_citation(self.endnotes(ind))

View File

@ -296,8 +296,8 @@ class DetDescendantReport(Report):
self.doc.start_paragraph("DDR-Title")
# feature request 2356: avoid genitive form
title = self._(
"Descendant Report for %(person_name)s") % {'person_name' : name}
title = self._("Descendant Report for %(person_name)s"
) % {'person_name' : name}
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.write_text(title, mark)
self.doc.end_paragraph()
@ -406,8 +406,8 @@ class DetDescendantReport(Report):
if self.map[key] == self.map[dkey]:
self.doc.write_text(
self._("%(name)s is the same person as [%(id_str)s]."
% {'name' : '',
'id_str' : self.dnumber[self.map[dkey]]}))
) % {'name' : '',
'id_str' : self.dnumber[self.map[dkey]]})
self.doc.end_paragraph()
return
@ -446,12 +446,12 @@ class DetDescendantReport(Report):
event_name = self._get_type(event.get_type())
if date and place:
# translators: needed for Arabic, ignore otherwise
text += self._(
'%(date)s, %(place)s') % {'date' : date, 'place' : place}
text += self._('%(str1)s, %(str2)s'
) % {'str1' : date, 'str2' : place}
elif date:
text += '%s' % date
elif place:
text += '%s' % place
text += '%s' % self._(place)
if event.get_description():
if text:
@ -465,8 +465,8 @@ class DetDescendantReport(Report):
# translators: needed for French, ignore otherwise
text = self._('%(str1)s: %(str2)s'
% {'str1' : self._(event_name),
'str2' : text})
) % {'str1' : self._(event_name),
'str2' : text}
self.doc.write_text_citation(text)
@ -481,9 +481,9 @@ class DetDescendantReport(Report):
attr_name = attr.get_type().type2base()
# translators: needed for French, ignore otherwise
text += self._("%(type)s: %(value)s%(endnotes)s"
% {'type' : self._(attr_name),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr)})
) % {'type' : self._(attr_name),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr)}
text = " " + text
self.doc.write_text_citation(text)
@ -570,10 +570,13 @@ class DetDescendantReport(Report):
name = self._("Unknown")
mark = ReportUtils.get_person_mark(self._db, mate)
if family.get_relationship() == FamilyRelType.MARRIED:
self.doc.write_text(self._("Spouse: %s") % name, mark)
self.doc.write_text(self._("Spouse: %s"
) % name,
mark)
else:
self.doc.write_text(
self._("Relationship with: %s") % name, mark)
self.doc.write_text(self._("Relationship with: %s"
) % name,
mark)
if name[-1:] != '.':
self.doc.write_text(".")
self.doc.write_text_citation(self.endnotes(mate))
@ -588,8 +591,8 @@ class DetDescendantReport(Report):
self.doc.start_paragraph('DDR-MoreDetails')
self.doc.write_text_citation(
self._("Ref: %(number)s. %(name)s"
% {'number' : self.dnumber[mate_handle],
'name' : name}))
) % {'number' : self.dnumber[mate_handle],
'name' : name})
self.doc.end_paragraph()
else:
self.dmates[mate_handle] = person.get_handle()
@ -628,8 +631,8 @@ class DetDescendantReport(Report):
self.doc.start_paragraph("DDR-ChildTitle")
self.doc.write_text(
self._("Children of %(mother_name)s and %(father_name)s"
% {'father_name' : father_name,
'mother_name' : mother_name}))
) % {'father_name' : father_name,
'mother_name' : mother_name})
self.doc.end_paragraph()
cnt = 1
@ -691,8 +694,8 @@ class DetDescendantReport(Report):
self.doc.start_paragraph("DDR-NoteHeader")
self.doc.write_text(
self._('Notes for %(mother_name)s and %(father_name)s:'
% {'mother_name' : mother_name,
'father_name' : father_name}))
) % {'mother_name' : mother_name,
'father_name' : father_name})
self.doc.end_paragraph()
for notehandle in notelist:
note = self._db.get_note_from_handle(notehandle)
@ -714,8 +717,8 @@ class DetDescendantReport(Report):
self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text(
self._('More about %(mother_name)s and %(father_name)s:'
% {'mother_name' : mother_name,
'father_name' : father_name}))
) % {'mother_name' : mother_name,
'father_name' : father_name})
self.doc.end_paragraph()
first = False
self.write_event(event_ref)
@ -733,17 +736,17 @@ class DetDescendantReport(Report):
self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text(
self._('More about %(mother_name)s and %(father_name)s:'
% {'mother_name' : mother_name,
'father_name' : father_name}))
) % {'mother_name' : mother_name,
'father_name' : father_name})
self.doc.end_paragraph()
for attr in attrs:
self.doc.start_paragraph('DDR-MoreDetails')
attr_name = self._get_type(attr.get_type())
text = self._("%(type)s: %(value)s%(endnotes)s"
% {'type' : self._(attr_name),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr)})
) % {'type' : self._(attr_name),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr)}
self.doc.write_text_citation(text)
self.doc.end_paragraph()
@ -817,7 +820,7 @@ class DetDescendantReport(Report):
if first:
self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text(self._('More about %(person_name)s:'
% {'person_name' : name}))
) % {'person_name' : name})
self.doc.end_paragraph()
first = False
self.doc.start_paragraph('DDR-MoreDetails')
@ -825,9 +828,9 @@ class DetDescendantReport(Report):
aname = alt_name.get_regular_name()
self.doc.write_text_citation(
self._('%(name_kind)s: %(name)s%(endnotes)s'
% {'name_kind' : self._(atype),
'name' : aname,
'endnotes' : self.endnotes(alt_name)}))
) % {'name_kind' : self._(atype),
'name' : aname,
'endnotes' : self.endnotes(alt_name)})
self.doc.end_paragraph()
if self.inc_events:
@ -835,7 +838,7 @@ class DetDescendantReport(Report):
if first:
self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text(self._('More about %(person_name)s:'
% {'person_name' : name}))
) % {'person_name' : name})
self.doc.end_paragraph()
first = 0
@ -846,7 +849,7 @@ class DetDescendantReport(Report):
if first:
self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text(self._('More about %(person_name)s:'
% {'person_name' : name}))
) % {'person_name' : name})
self.doc.end_paragraph()
first = False
self.doc.start_paragraph('DDR-MoreDetails')
@ -872,7 +875,7 @@ class DetDescendantReport(Report):
self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text(
self._('More about %(person_name)s:'
% {'person_name' : name}))
) % {'person_name' : name})
self.doc.end_paragraph()
first = False
@ -881,9 +884,9 @@ class DetDescendantReport(Report):
attr_name = attr.get_type().type2base()
# translators: needed for French, ignore otherwise
text = self._("%(type)s: %(value)s%(endnotes)s"
% {'type' : self._(attr_name),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr)})
) % {'type' : self._(attr_name),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr)}
self.doc.write_text_citation(text)
self.doc.end_paragraph()
@ -933,8 +936,8 @@ class DetDescendantOptions(MenuReportOptions):
numbering.set_items([
("Henry", _("Henry numbering")),
("d'Aboville", _("d'Aboville numbering")),
("Record (Modified Register)", _(
"Record (Modified Register) numbering"))])
("Record (Modified Register)",
_("Record (Modified Register) numbering"))])
numbering.set_help(_("The numbering system to be used"))
add_option("numbering", numbering)

View File

@ -161,8 +161,8 @@ class EndOfLineReport(Report):
self.doc.start_paragraph("EOL-Subtitle")
# feature request 2356: avoid genitive form
title = self._("All the ancestors of %s "
"who are missing a parent") % pname
title = self._("All the ancestors of %s who are missing a parent"
) % pname
self.doc.write_text(title)
self.doc.end_paragraph()
@ -207,8 +207,8 @@ class EndOfLineReport(Report):
dates = ''
if birth_date or death_date:
dates = self._(" (%(birth_date)s - %(death_date)s)"
% {'birth_date' : birth_date,
'death_date' : death_date})
) % {'birth_date' : birth_date,
'death_date' : death_date}
self.doc.start_row()
self.doc.start_cell('EOL-TableCell', 2)

View File

@ -133,8 +133,8 @@ class FamilyGroup(Report):
attr_type = self._get_type(attr.get_type())
# translators: needed for French, ignore otherwise
descr += self._("%(str1)s: %(str2)s"
% {'str1' : self._(attr_type),
'str2' : attr.get_value()})
) % {'str1' : self._(attr_type),
'str2' : attr.get_value()}
self.doc.start_row()
self.doc.start_cell("FGR-TextContents")
@ -299,8 +299,9 @@ class FamilyGroup(Report):
mark = ReportUtils.get_person_mark(self.db, person)
# translators: needed for French, ignore otherwise
self.doc.write_text(self._("%(str1)s: %(str2)s"
% {'str1' : title,
'str2' : name}), mark)
) % {'str1' : title,
'str2' : name},
mark)
if self.gramps_ids:
gid = person.get_gramps_id()
if gid:

View File

@ -89,6 +89,7 @@ TYPE2GROUP[EventType.UNKNOWN] = _T_("Unknown")
#
#------------------------------------------------------------------------
class IndivCompleteReport(Report):
""" the Complete Individual Report """
def __init__(self, database, options, user):
"""
@ -230,10 +231,9 @@ class IndivCompleteReport(Report):
self.write_cell(label)
if parent_name:
# for example (a stepfather): John Smith, relationship: Step
text = self._(
'%(parent-name)s, relationship: %(rel-type)s') % {
'parent-name' : parent_name,
'rel-type' : self._(rel_type)}
text = self._('%(parent-name)s, relationship: %(rel-type)s'
) % {'parent-name' : parent_name,
'rel-type' : self._(rel_type)}
self.write_cell(text, mark=pmark)
else:
self.write_cell('')
@ -847,9 +847,9 @@ class IndivCompleteReport(Report):
else:
self._user.warn(_("Could not add photo to page"),
# translators: for French, else ignore
_("%(str1)s: %(str2)s") % {
'str1' : image_filename,
'str2' : _('File does not exist')})
_("%(str1)s: %(str2)s"
) % {'str1' : image_filename,
'str2' : _('File does not exist')})
self.doc.start_table('person', p_style)
self.doc.start_row()
@ -887,10 +887,9 @@ class IndivCompleteReport(Report):
for attr in attr_list:
attr_type = attr.get_type().type2base()
# translators: needed for French, ignore otherwise
text = self._(
"%(str1)s: %(str2)s") % {
'str1' : self._(attr_type),
'str2' : attr.get_value()}
text = self._("%(str1)s: %(str2)s"
) % {'str1' : self._(attr_type),
'str2' : attr.get_value()}
endnotes = self._cite_endnote(attr, prior=endnotes)
self.write_paragraph("(%s)" % text,
endnotes=endnotes,
@ -929,7 +928,7 @@ class IndivCompleteReport(Report):
""" Combine two strings with a given format. """
text = ""
if str1 and str2:
text = self._(format_both) % {'str1':str1, 'str2':str2}
text = self._(format_both) % {'str1' : str1, 'str2' : str2}
elif str1 and not str2:
text = format_single % str1
elif str2 and not str1:
@ -958,10 +957,9 @@ class IndivCompleteReport(Report):
for attr in attr_list:
attr_type = attr.get_type().type2base()
# translators: needed for French, ignore otherwise
text = self._(
"%(type)s: %(value)s") % {
'type' : self._(attr_type),
'value' : attr.get_value()}
text = self._("%(str1)s: %(str2)s"
) % {'str1' : self._(attr_type),
'str2' : attr.get_value()}
endnotes = self._cite_endnote(attr)
self.write_paragraph(text, endnotes)

View File

@ -317,8 +317,8 @@ class KinshipReport(Report):
dates = ''
if birth_date or death_date:
dates = self._(" (%(birth_date)s - %(death_date)s)"
% {'birth_date' : birth_date,
'death_date' : death_date})
) % {'birth_date' : birth_date,
'death_date' : death_date}
self.doc.start_paragraph('KIN-Normal')
self.doc.write_text(name, mark)

View File

@ -165,8 +165,8 @@ class NumberOfAncestorsReport(Report):
# TC # English return something like:
# Total ancestors in generations 2 to 3 is 4. (66.67%)
text = self._("Total ancestors in generations %(second_generation)d "
"to %(last_generation)d is %(count)d. %(percent)s") % {
'second_generation': 2,
"to %(last_generation)d is %(count)d. %(percent)s"
) % {'second_generation': 2,
'last_generation' : gen,
'count' : len(all_people),
'percent' : percent}

View File

@ -94,8 +94,8 @@ class PlaceReport(Report):
if value == self._lv:
living_desc = self._(description)
break
self.living_desc = self._(
"(Living people: %(option_name)s)") % {'option_name': living_desc}
self.living_desc = self._("(Living people: %(option_name)s)"
) % {'option_name': living_desc}
places = menu.get_option_by_name('places').get_value()
self.center = menu.get_option_by_name('center').get_value()
@ -177,9 +177,9 @@ class PlaceReport(Report):
place_details = [self._("Gramps ID: %s ") % place.get_gramps_id()]
for level in get_location_list(self._db, place):
# translators: needed for French, ignore otherwise
place_details.append(self._(
"%(str1)s: %(str2)s") % {'str1': self._(level[1].xml_str()),
'str2': level[0]})
place_details.append(self._("%(str1)s: %(str2)s"
) % {'str1': self._(level[1].xml_str()),
'str2': level[0]})
place_names = ''
all_names = place.get_all_names()
@ -257,16 +257,16 @@ class PlaceReport(Report):
for p_handle in person_list:
person = self._db.get_person_from_handle(p_handle)
if person:
person_name = self._nd.display(person)
if people == "":
people = "%(name)s (%(id)s)" \
% {'name': self._nd.display(person),
'id': person.get_gramps_id()}
people = "%(name)s (%(id)s)" % {
'name' : person_name,
'id' : person.get_gramps_id()}
else:
people = self._("%(persons)s and %(name)s "
"(%(id)s)") \
% {'persons': people,
'name': self._nd.display(person),
'id': person.get_gramps_id()}
people = self._("%(persons)s and %(name)s (%(id)s)"
) % {'persons' : people,
'name' : person_name,
'id' : person.get_gramps_id()}
event_details = [date, event_type, people, descr]
self.doc.start_row()
@ -321,13 +321,16 @@ class PlaceReport(Report):
if f_handle and m_handle:
father = self._db.get_person_from_handle(f_handle)
mother = self._db.get_person_from_handle(m_handle)
name_entry = self._(
"%(father)s (%(father_id)s) and "
"%(mother)s (%(mother_id)s)") % {
'father' : self._nd.display(father),
'father_id' : father.get_gramps_id(),
'mother' : self._nd.display(mother),
'mother_id' : mother.get_gramps_id()}
father_name = self._nd.display(father)
mother_name = self._nd.display(mother)
father_id = father.get_gramps_id()
mother_id = mother.get_gramps_id()
name_entry = self._("%(father)s (%(father_id)s) and "
"%(mother)s (%(mother_id)s)"
) % {'father' : father_name,
'father_id' : father_id,
'mother' : mother_name,
'mother_id' : mother_id}
elif f_handle or m_handle:
if f_handle:
p_handle = f_handle

View File

@ -139,8 +139,8 @@ class SimpleBookTitleOptions(MenuReportOptions):
dateinfo = time.localtime(time.time())
rname = self.__db.get_researcher().get_name()
footer_string = _('Copyright %(year)d %(name)s') % {
'year' : dateinfo[0], 'name' : rname}
footer_string = _('Copyright %(year)d %(name)s'
) % {'year' : dateinfo[0], 'name' : rname}
footer = StringOption(_('Footer'), footer_string)
footer.set_help(_("Footer string for the page."))
menu.add_option(category_name, "footer", footer)

View File

@ -117,6 +117,7 @@ class SummaryReport(Report):
num_people = 0
for person in self.__db.iter_people():
num_people += 1
primary_names = [person.get_primary_name()]
# Count people with media.
length = len(person.get_media_list())
@ -124,7 +125,7 @@ class SummaryReport(Report):
with_media += 1
# Count people with incomplete names.
for name in [person.get_primary_name()] + person.get_alternate_names():
for name in primary_names + person.get_alternate_names():
if name.get_first_name().strip() == "":
incomp_names += 1
else:
@ -137,7 +138,7 @@ class SummaryReport(Report):
# Count people without families.
if (not person.get_main_parents_family_handle() and
not len(person.get_family_handle_list())):
not len(person.get_family_handle_list())):
disconnected += 1
# Count missing birthdays.
@ -158,9 +159,9 @@ class SummaryReport(Report):
unknowns += 1
# Count unique surnames
for name in [person.get_primary_name()] + person.get_alternate_names():
if not name.get_surname().strip() in namelist \
and not name.get_surname().strip() == "":
for name in primary_names + person.get_alternate_names():
if (not name.get_surname().strip() in namelist
and not name.get_surname().strip() == ""):
namelist.append(name.get_surname().strip())
self.doc.start_paragraph("SR-Normal")
@ -176,8 +177,8 @@ class SummaryReport(Report):
self.doc.end_paragraph()
self.doc.start_paragraph("SR-Normal")
self.doc.write_text(self._("Individuals with unknown gender: %d") %
unknowns)
self.doc.write_text(self._("Individuals with unknown gender: %d"
) % unknowns)
self.doc.end_paragraph()
self.doc.start_paragraph("SR-Normal")
@ -185,13 +186,13 @@ class SummaryReport(Report):
self.doc.end_paragraph()
self.doc.start_paragraph("SR-Normal")
self.doc.write_text(self._("Individuals missing birth dates: %d") %
missing_bday)
self.doc.write_text(self._("Individuals missing birth dates: %d"
) % missing_bday)
self.doc.end_paragraph()
self.doc.start_paragraph("SR-Normal")
self.doc.write_text(self._("Disconnected individuals: %d") %
disconnected)
self.doc.write_text(self._("Disconnected individuals: %d"
) % disconnected)
self.doc.end_paragraph()
self.doc.start_paragraph("SR-Normal")
@ -199,8 +200,8 @@ class SummaryReport(Report):
self.doc.end_paragraph()
self.doc.start_paragraph("SR-Normal")
self.doc.write_text(self._("Individuals with media objects: %d") %
with_media)
self.doc.write_text(self._("Individuals with media objects: %d"
) % with_media)
self.doc.end_paragraph()
def summarize_families(self):
@ -212,8 +213,8 @@ class SummaryReport(Report):
self.doc.end_paragraph()
self.doc.start_paragraph("SR-Normal")
self.doc.write_text(self._("Number of families: %d") %
self.__db.get_number_of_families())
self.doc.write_text(self._("Number of families: %d"
) % self.__db.get_number_of_families())
self.doc.end_paragraph()
def summarize_media(self):
@ -234,7 +235,7 @@ class SummaryReport(Report):
media = self.__db.get_media_from_handle(media_id)
try:
size_in_bytes += posixpath.getsize(
media_path_full(self.__db, media.get_path()))
media_path_full(self.__db, media.get_path()))
length = len(str(size_in_bytes))
if size_in_bytes <= 999999:
mbytes = self._("less than 1")
@ -244,13 +245,13 @@ class SummaryReport(Report):
notfound.append(media.get_path())
self.doc.start_paragraph("SR-Normal")
self.doc.write_text(self._("Number of unique media objects: %d") %
total_media)
self.doc.write_text(self._("Number of unique media objects: %d"
) % total_media)
self.doc.end_paragraph()
self.doc.start_paragraph("SR-Normal")
self.doc.write_text(self._("Total size of media objects: %s MB") %
mbytes)
self.doc.write_text(self._("Total size of media objects: %s MB"
) % mbytes)
self.doc.end_paragraph()
if len(notfound) > 0:

View File

@ -95,8 +95,8 @@ class TagReport(Report):
if value == self._lv:
living_desc = self._(description)
break
self.living_desc = self._(
"(Living people: %(option_name)s)") % {'option_name': living_desc}
self.living_desc = self._("(Living people: %(option_name)s)"
) % {'option_name' : living_desc}
self.tag = menu.get_option_by_name('tag').get_value()
if not self.tag: