From 409a730fa05b2ab6685213ffa0ecef63e6dde569 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Fri, 18 Jan 2008 18:28:28 +0000 Subject: [PATCH] 2008-01-18 Douglas S. Blank * src/plugins/DefaultGramplets.py (SurnameCloudGramplet.main): use const.NO_SURNAME to display blank entries * src/plugins/SameSurnames.py (SameSurname): exact match surnames * src/Simple/_SimpleAccess.py (SimpleAccess.surname): surname() returns const.NO_SURNAME when left blank * src/const.py.in: new NO_SURNAME constant; RERUN ./autogen.sh ! svn: r9887 --- ChangeLog | 8 ++++++++ src/Simple/_SimpleAccess.py | 4 +++- src/const.py.in | 2 ++ src/plugins/DefaultGramplets.py | 7 +++---- src/plugins/SameSurnames.py | 16 ++++++++++++++-- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5daab326..83ae20126 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-01-18 Douglas S. Blank + * src/plugins/DefaultGramplets.py (SurnameCloudGramplet.main): + use const.NO_SURNAME to display blank entries + * src/plugins/SameSurnames.py (SameSurname): exact match surnames + * src/Simple/_SimpleAccess.py (SimpleAccess.surname): + surname() returns const.NO_SURNAME when left blank + * src/const.py.in: new NO_SURNAME constant; RERUN ./autogen.sh ! + 2008-01-18 Raphael Ackermann * src/FilterEditor/_EditRule.py * src/FilterEditor/_ShowResults.py diff --git a/src/Simple/_SimpleAccess.py b/src/Simple/_SimpleAccess.py index b6bcc6d1f..921090b23 100644 --- a/src/Simple/_SimpleAccess.py +++ b/src/Simple/_SimpleAccess.py @@ -31,6 +31,7 @@ import Utils from BasicUtils import name_displayer from ReportBase import ReportUtils from gen.lib import EventType +import const class SimpleAccess: """ @@ -128,7 +129,8 @@ class SimpleAccess: """ assert(isinstance(person, (gen.lib.Person, NoneType))) if person: - return person.get_primary_name().get_surname() + surname = person.get_primary_name().get_surname() + return surname or const.NO_SURNAME else: return u'' diff --git a/src/const.py.in b/src/const.py.in index 54299d227..571f54ee5 100644 --- a/src/const.py.in +++ b/src/const.py.in @@ -176,6 +176,8 @@ TRANSLATORS = _('TRANSLATORS: Translate this to your ' #------------------------------------------------------------------------- THUMBSCALE = 96.0 XMLFILE = "data.gramps" +NO_SURNAME = "(%s)" % _("none") +NO_GIVEN = "(%s)" % _("none") #------------------------------------------------------------------------- # diff --git a/src/plugins/DefaultGramplets.py b/src/plugins/DefaultGramplets.py index c1eb21410..9be36b8d1 100644 --- a/src/plugins/DefaultGramplets.py +++ b/src/plugins/DefaultGramplets.py @@ -31,6 +31,7 @@ from BasicUtils import name_displayer from QuickReports import run_quick_report_by_name import DateHandler from gettext import gettext as _ +import const # # Hello World, in Gramps Gramplets @@ -243,7 +244,7 @@ class TopSurnamesGramplet(Gramplet): self.set_text("") for (count, surname) in surname_sort: if len(surname) == 0: - text = "(%s), %d%% (%d)\n" % (_("blank"), # as in empty, left blank + text = "%s, %d%% (%d)\n" % (const.NO_SURNAME, int((float(count)/total) * 100), count) else: text = "%s, %d%% (%d)\n" % (surname, int((float(count)/total) * 100), count) @@ -329,11 +330,9 @@ class SurnameCloudGramplet(Gramplet): self.set_text("") for (count, surname) in cloud_names: # surname_sort: if len(surname) == 0: - text = "(%s)" % _("blank") - # int((float(count)/total) * 100), count) + text = const.NO_SURNAME else: text = surname - # size = make_tag_size(count, counts) self.link(text, 'Surname', representative_handle[surname], size, "%s, %d%% (%d)" % (text, diff --git a/src/plugins/SameSurnames.py b/src/plugins/SameSurnames.py index 1f342f59c..dda26e1a3 100644 --- a/src/plugins/SameSurnames.py +++ b/src/plugins/SameSurnames.py @@ -28,7 +28,6 @@ from gettext import gettext as _ from PluginUtils import register_quick_report from ReportBase import CATEGORY_QR_PERSON from Filters.Rules import Rule -from Filters.Rules.Person import SearchName from Filters import GenericFilterFactory, Rules class IncompleteSurname(Rule): @@ -42,6 +41,19 @@ class IncompleteSurname(Rule): return True return False +class SameSurname(Rule): + """People with same surname""" + labels = [_('Substring:')] + name = _('People matching the ') + description = _("Matches people with same lastname") + category = _('General filters') + def apply(self,db,person): + src = self.list[0].upper() + for name in [person.get_primary_name()] + person.get_alternate_names(): + if name.surname and name.surname.upper() == src.upper(): + return True + return False + def run(database, document, person): """ Loops through the families that the person is a child in, and display @@ -59,7 +71,7 @@ def run(database, document, person): gid = sdb.gid(person) filter = GenericFilterFactory('Person')() if person.get_primary_name().get_surname() != '': - rule = SearchName([person.get_primary_name().get_surname()]) + rule = SameSurname([person.get_primary_name().get_surname()]) else: rule = IncompleteSurname([]) filter.add_rule(rule)