add nick and famnick

svn: r15930
This commit is contained in:
Benny Malengier 2010-09-25 15:11:54 +00:00
parent bb248fadce
commit f111dcbad9
5 changed files with 83 additions and 18 deletions

View File

@ -122,9 +122,10 @@ def convert_name_15(name):
surname_list = [(patronymic, u"", False, patorigintype, u""),
(surname, prefix, True, origintype, connector)]
#return new value, add two empty strings for nick and family nick
return (privacy, source_list, note_list, date,
first_name, surname_list, suffix, title, name_type,
group_as, sort_as, display_as, call)
group_as, sort_as, display_as, call, u"", u"")
def gramps_upgrade_14(self):
"""Upgrade database from version 13 to 14."""

View File

@ -37,6 +37,8 @@ Specific symbols for parts of a name are defined:
'p' : list of all prefixes
'q' : surnames without prefixes and connectors
's' : suffix
'n' : nick name
'g' : family nick name
"""
#-------------------------------------------------------------------------
@ -71,12 +73,12 @@ _SURNAME_LIST = 5
_SUFFIX = 6
_TITLE = 7
_TYPE = 8
#_PREFIX = 9
#_PATRONYM = 10
_GROUP = 11
_SORT = 12
_DISPLAY = 13
_CALL = 14
_GROUP = 9
_SORT = 10
_DISPLAY = 11
_CALL = 12
_NICK = 13
_FAMNICK = 14
_SURNAME_IN_LIST = 0
_PREFIX_IN_LIST = 1
_PRIMARY_IN_LIST = 2
@ -363,6 +365,8 @@ class NameDisplay(object):
'p' : list of all prefixes
'q' : surnames without prefixes and connectors
's' : suffix
'n' : nick name
'g' : family nick name
"""
@ -399,6 +403,10 @@ class NameDisplay(object):
"q": ("_raw_single_surname(raw_data[_SURNAME_LIST])",
"rawsurnames",
_("String replacement keyword|rawsurnames")),
"n": ("raw_data[_NICK]", "nickname",
_("String replacement keyword|nickname")),
"g": ("raw_data[_FAMNICK]", "famnick",
_("String replacement keyword|famnick")),
}
args = "raw_data"
return self._make_fn(format_str, d, args)
@ -432,6 +440,8 @@ class NameDisplay(object):
'p' : list of all prefixes
'q' : surnames without prefixes and connectors
's' : suffix
'n' : nick name
'g' : family nick name
"""
# we need the names of each of the variables or methods that are
@ -462,8 +472,12 @@ class NameDisplay(object):
_("String replacement keyword|prefix")),
"q": ("_raw_single_surname(raw_surname_list)", "rawlastnames",
_("String replacement keyword|rawlastnames")),
"n": ("nick", "nickname",
_("String replacement keyword|nickname")),
"g": ("famnick", "famnick",
_("String replacement keyword|famnick")),
}
args = "first,raw_surname_list,suffix,title,call"
args = "first,raw_surname_list,suffix,title,call,nick,famnick"
return self._make_fn(format_str, d, args)
def _make_fn(self, format_str, d, args):
@ -567,7 +581,8 @@ def fn(%s):
def format_str(self, name, format_str):
return self._format_str_base(name.first_name, name.surname_list,
name.suffix, name.title,
name.call, format_str)
name.call, name.nick, name.famnick,
format_str)
def format_str_raw(self, raw_data, format_str):
"""
@ -587,7 +602,7 @@ def fn(%s):
def _format_str_base(self, first, surname_list, suffix, title, call,
format_str):
nick, famnick, format_str):
"""
Generates name from a format string.
@ -604,6 +619,8 @@ def fn(%s):
'%p' : list of all prefixes
'%q' : surnames without prefixes and connectors
'%s' : suffix
'%n' : nick name
'%g' : family nick name
The capital letters are substituted for capitalized name components.
The %% is substituted with the single % character.
All the other characters in the fmt_str are unaffected.
@ -614,7 +631,7 @@ def fn(%s):
self.__class__.format_funcs[format_str] = func
try:
s = func(first, [surn.serialize() for surn in surname_list],
suffix, title, call)
suffix, title, call, nick, famnick)
except (ValueError, TypeError,):
raise NameDisplayError, "Incomplete format string"

View File

@ -78,7 +78,8 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
if data:
(privacy, source_list, note, date,
self.first_name, surname_list, self.suffix, self.title, name_type,
self.group_as, self.sort_as, self.display_as, self.call) = data
self.group_as, self.sort_as, self.display_as, self.call,
self.nick, self.famnick) = data
self.type = NameType(name_type)
SurnameBase.unserialize(self, surname_list)
PrivacyBase.unserialize(self, privacy)
@ -94,6 +95,8 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
self.sort_as = source.sort_as
self.display_as = source.display_as
self.call = source.call
self.nick = source.nick
self.famnick = source.famnick
else:
self.first_name = ""
self.suffix = ""
@ -103,6 +106,8 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
self.sort_as = self.DEF
self.display_as = self.DEF
self.call = u''
self.nick = u''
self.famnick = u''
def serialize(self):
"""
@ -116,14 +121,16 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
SurnameBase.serialize(self),
self.suffix, self.title,
self.type.serialize(),
self.group_as, self.sort_as, self.display_as, self.call)
self.group_as, self.sort_as, self.display_as, self.call,
self.nick, self.famnick)
def is_empty(self):
"""
Indicate if the name is empty.
"""
namefieldsempty = (self.first_name == u"" and
self.suffix == u"" and self.title == u"")
self.suffix == u"" and self.title == u"" and self.nick ==u""
and self.famnick == u"")
surnamefieldsempty = not (False in
[surn.is_empty() for surn in self.surname_list])
return namefieldsempty and surnamefieldsempty
@ -134,7 +141,8 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
"""
(privacy, source_list, note_list, date,
self.first_name, surname_list, self.suffix, self.title, name_type,
self.group_as, self.sort_as, self.display_as, self.call) = data
self.group_as, self.sort_as, self.display_as, self.call,
self.nick, self.famnick) = data
self.type = NameType(name_type)
PrivacyBase.unserialize(self, privacy)
SurnameBase.unserialize(self, surname_list)
@ -151,7 +159,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
:rtype: list
"""
return [self.first_name, self.suffix, self.title,
str(self.type), self.call]
str(self.type), self.call, self.nick, self.famnick]
def get_text_data_child_list(self):
"""
@ -219,7 +227,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
Normally the person merge code should opt for adding an alternate
name if names are actually different (like not equal surname list)
Lost: type, first, call, suffix, title and date of
Lost: type, first, call, suffix, title, nick, famnick and date of
acquisition.
:param acquisition: The name to merge with the present name.
@ -314,6 +322,42 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
"""
self.call = val
def get_nick_name(self):
"""
Return the nick name.
The nick name of the person, a not official name the person is known
with.
"""
return self.nick
def set_nick_name(self, val):
"""
Set the nick name.
The nick name of the person, a not official name the person is known
with.
"""
self.nick = val
def get_family_nick_name(self):
"""
Return the family nick name.
The family nick name of the family of the person, a not official name
use to denote the entire family.
"""
return self.famnick
def set_family_nick_name(self, val):
"""
Set the family nick name.
The family nick name of the family of the person, a not official name
use to denote the entire family.
"""
self.famnick = val
def set_type(self, the_type):
"""Set the type of the Name instance."""
self.type.set(the_type)
@ -396,6 +440,8 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
retval['surnamelist'] = self.get_surnames()
retval['prefixes'] = self.get_prefixes()
retval['connectors'] = self.get_connectors()
retval['nick'] = self.nick
retval['famnick'] = self.famnick
return retval
def get_gedcom_name(self):

View File

@ -416,6 +416,7 @@ class GrampsParser(UpdateCallback):
self.childref = None
self.personref = None
self.name = None
self.surname = None
self.home = None
self.owner = gen.lib.Researcher()
self.func_list = [None]*50

View File

@ -35,5 +35,5 @@
# Public Constants
#
#------------------------------------------------------------------------
GRAMPS_XML_VERSION = "1.3.0"
GRAMPS_XML_VERSION = "1.4.0"