2008-01-18 Douglas S. Blank <dblank@cs.brynmawr.edu>

* 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
This commit is contained in:
Doug Blank 2008-01-18 18:28:28 +00:00
parent 0fc89437fa
commit 409a730fa0
5 changed files with 30 additions and 7 deletions

View File

@ -1,3 +1,11 @@
2008-01-18 Douglas S. Blank <dblank@cs.brynmawr.edu>
* 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 <raphael.ackermann@gmail.com> 2008-01-18 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/FilterEditor/_EditRule.py * src/FilterEditor/_EditRule.py
* src/FilterEditor/_ShowResults.py * src/FilterEditor/_ShowResults.py

View File

@ -31,6 +31,7 @@ import Utils
from BasicUtils import name_displayer from BasicUtils import name_displayer
from ReportBase import ReportUtils from ReportBase import ReportUtils
from gen.lib import EventType from gen.lib import EventType
import const
class SimpleAccess: class SimpleAccess:
""" """
@ -128,7 +129,8 @@ class SimpleAccess:
""" """
assert(isinstance(person, (gen.lib.Person, NoneType))) assert(isinstance(person, (gen.lib.Person, NoneType)))
if person: if person:
return person.get_primary_name().get_surname() surname = person.get_primary_name().get_surname()
return surname or const.NO_SURNAME
else: else:
return u'' return u''

View File

@ -176,6 +176,8 @@ TRANSLATORS = _('TRANSLATORS: Translate this to your '
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
THUMBSCALE = 96.0 THUMBSCALE = 96.0
XMLFILE = "data.gramps" XMLFILE = "data.gramps"
NO_SURNAME = "(%s)" % _("none")
NO_GIVEN = "(%s)" % _("none")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -31,6 +31,7 @@ from BasicUtils import name_displayer
from QuickReports import run_quick_report_by_name from QuickReports import run_quick_report_by_name
import DateHandler import DateHandler
from gettext import gettext as _ from gettext import gettext as _
import const
# #
# Hello World, in Gramps Gramplets # Hello World, in Gramps Gramplets
@ -243,7 +244,7 @@ class TopSurnamesGramplet(Gramplet):
self.set_text("") self.set_text("")
for (count, surname) in surname_sort: for (count, surname) in surname_sort:
if len(surname) == 0: 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) int((float(count)/total) * 100), count)
else: else:
text = "%s, %d%% (%d)\n" % (surname, int((float(count)/total) * 100), count) text = "%s, %d%% (%d)\n" % (surname, int((float(count)/total) * 100), count)
@ -329,11 +330,9 @@ class SurnameCloudGramplet(Gramplet):
self.set_text("") self.set_text("")
for (count, surname) in cloud_names: # surname_sort: for (count, surname) in cloud_names: # surname_sort:
if len(surname) == 0: if len(surname) == 0:
text = "(%s)" % _("blank") text = const.NO_SURNAME
# int((float(count)/total) * 100), count)
else: else:
text = surname text = surname
#
size = make_tag_size(count, counts) size = make_tag_size(count, counts)
self.link(text, 'Surname', representative_handle[surname], size, self.link(text, 'Surname', representative_handle[surname], size,
"%s, %d%% (%d)" % (text, "%s, %d%% (%d)" % (text,

View File

@ -28,7 +28,6 @@ from gettext import gettext as _
from PluginUtils import register_quick_report from PluginUtils import register_quick_report
from ReportBase import CATEGORY_QR_PERSON from ReportBase import CATEGORY_QR_PERSON
from Filters.Rules import Rule from Filters.Rules import Rule
from Filters.Rules.Person import SearchName
from Filters import GenericFilterFactory, Rules from Filters import GenericFilterFactory, Rules
class IncompleteSurname(Rule): class IncompleteSurname(Rule):
@ -42,6 +41,19 @@ class IncompleteSurname(Rule):
return True return True
return False return False
class SameSurname(Rule):
"""People with same surname"""
labels = [_('Substring:')]
name = _('People matching the <name>')
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): def run(database, document, person):
""" """
Loops through the families that the person is a child in, and display 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) gid = sdb.gid(person)
filter = GenericFilterFactory('Person')() filter = GenericFilterFactory('Person')()
if person.get_primary_name().get_surname() != '': if person.get_primary_name().get_surname() != '':
rule = SearchName([person.get_primary_name().get_surname()]) rule = SameSurname([person.get_primary_name().get_surname()])
else: else:
rule = IncompleteSurname([]) rule = IncompleteSurname([])
filter.add_rule(rule) filter.add_rule(rule)