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): and option_data[0] in docgen_names):
print(_("Option '%(opt_name)s' is present in %(file)s\n" print(_("Option '%(opt_name)s' is present in %(file)s\n"
" but is not known to the module. Ignoring..." " but is not known to the module. Ignoring..."
% {'opt_name' : option_name, ) % {'opt_name' : option_name,
'file' : self.option_list_collection.filename}), 'file' : self.option_list_collection.filename},
file=sys.stderr) file=sys.stderr)
options.pop(option_name) options.pop(option_name)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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