2005-12-21 02:18:18 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-02-20 06:09:10 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2010-07-22 07:46:32 +05:30
|
|
|
# Copyright (C) 2010 Michiel D. Nauta
|
2005-12-21 02:18:18 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Name class for GRAMPS.
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-02-24 19:25:55 +05:30
|
|
|
from gen.lib.secondaryobj import SecondaryObject
|
|
|
|
from gen.lib.privacybase import PrivacyBase
|
|
|
|
from gen.lib.srcbase import SourceBase
|
|
|
|
from gen.lib.notebase import NoteBase
|
|
|
|
from gen.lib.datebase import DateBase
|
2010-09-17 18:56:36 +05:30
|
|
|
from gen.lib.surnamebase import SurnameBase
|
2008-02-24 19:25:55 +05:30
|
|
|
from gen.lib.nametype import NameType
|
2010-07-22 07:46:32 +05:30
|
|
|
from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
2005-12-21 02:18:18 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Personal Name
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2010-09-17 18:56:36 +05:30
|
|
|
class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
|
|
|
|
DateBase):
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Provide name information about a person.
|
2005-12-21 02:18:18 +05:30
|
|
|
|
2010-09-17 18:56:36 +05:30
|
|
|
A person may have more that one name throughout his or her life. The Name
|
|
|
|
object stores one of them
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
|
|
|
|
2006-07-06 23:16:46 +05:30
|
|
|
DEF = 0 # Default format (determined by gramps-wide prefs)
|
2010-09-18 03:43:31 +05:30
|
|
|
LNFN = 1 # last name first name
|
2006-07-06 23:16:46 +05:30
|
|
|
FNLN = 2 # first name last name
|
|
|
|
FN = 4 # first name
|
2010-09-18 03:43:31 +05:30
|
|
|
|
|
|
|
NAMEFORMATS = (DEF, LNFN, FNLN, FN)
|
2010-09-17 18:56:36 +05:30
|
|
|
#deprecated :
|
|
|
|
PTFN = 3 # patronymic first name
|
2006-07-06 23:16:46 +05:30
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def __init__(self, source=None, data=None):
|
2010-03-07 21:03:38 +05:30
|
|
|
"""Create a new Name instance, copying from the source if provided.
|
|
|
|
We should connect here to 'person-groupname-rebuild' and do something
|
|
|
|
correct when first parameter is the name, and second parameter is
|
|
|
|
different from the group here. However, that would be complicated and
|
|
|
|
no real errors that cannot be ammended can be done if group is
|
|
|
|
saved differently.
|
|
|
|
"""
|
2007-01-08 07:19:33 +05:30
|
|
|
PrivacyBase.__init__(self, source)
|
2010-09-17 18:56:36 +05:30
|
|
|
SurnameBase.__init__(self, source)
|
2007-01-08 07:19:33 +05:30
|
|
|
SourceBase.__init__(self, source)
|
|
|
|
NoteBase.__init__(self, source)
|
|
|
|
DateBase.__init__(self, source)
|
2006-03-19 08:55:31 +05:30
|
|
|
if data:
|
2007-01-08 07:19:33 +05:30
|
|
|
(privacy, source_list, note, date,
|
2010-09-17 18:56:36 +05:30
|
|
|
self.first_name, surname_list, self.suffix, self.title, name_type,
|
2010-09-25 20:41:54 +05:30
|
|
|
self.group_as, self.sort_as, self.display_as, self.call,
|
|
|
|
self.nick, self.famnick) = data
|
2006-04-14 10:06:25 +05:30
|
|
|
self.type = NameType(name_type)
|
2010-09-17 18:56:36 +05:30
|
|
|
SurnameBase.unserialize(self, surname_list)
|
2007-01-08 07:19:33 +05:30
|
|
|
PrivacyBase.unserialize(self, privacy)
|
|
|
|
SourceBase.unserialize(self, source_list)
|
|
|
|
NoteBase.unserialize(self, note)
|
|
|
|
DateBase.unserialize(self, date)
|
2006-03-19 08:55:31 +05:30
|
|
|
elif source:
|
2005-12-21 02:18:18 +05:30
|
|
|
self.first_name = source.first_name
|
|
|
|
self.suffix = source.suffix
|
|
|
|
self.title = source.title
|
|
|
|
self.type = source.type
|
|
|
|
self.group_as = source.group_as
|
|
|
|
self.sort_as = source.sort_as
|
|
|
|
self.display_as = source.display_as
|
2006-05-06 02:46:24 +05:30
|
|
|
self.call = source.call
|
2010-09-25 20:41:54 +05:30
|
|
|
self.nick = source.nick
|
|
|
|
self.famnick = source.famnick
|
2005-12-21 02:18:18 +05:30
|
|
|
else:
|
|
|
|
self.first_name = ""
|
|
|
|
self.suffix = ""
|
|
|
|
self.title = ""
|
2006-04-14 10:06:25 +05:30
|
|
|
self.type = NameType()
|
2005-12-21 02:18:18 +05:30
|
|
|
self.group_as = ""
|
2006-07-06 23:16:46 +05:30
|
|
|
self.sort_as = self.DEF
|
|
|
|
self.display_as = self.DEF
|
2007-01-09 03:10:51 +05:30
|
|
|
self.call = u''
|
2010-09-25 20:41:54 +05:30
|
|
|
self.nick = u''
|
|
|
|
self.famnick = u''
|
2005-12-21 02:18:18 +05:30
|
|
|
|
2006-02-04 03:33:53 +05:30
|
|
|
def serialize(self):
|
2007-01-08 07:19:33 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Convert the object to a serialized tuple of data.
|
2007-01-08 07:19:33 +05:30
|
|
|
"""
|
2006-04-13 08:45:22 +05:30
|
|
|
return (PrivacyBase.serialize(self),
|
|
|
|
SourceBase.serialize(self),
|
|
|
|
NoteBase.serialize(self),
|
2006-02-04 03:33:53 +05:30
|
|
|
DateBase.serialize(self),
|
2010-09-17 18:56:36 +05:30
|
|
|
self.first_name,
|
|
|
|
SurnameBase.serialize(self),
|
|
|
|
self.suffix, self.title,
|
|
|
|
self.type.serialize(),
|
2010-09-25 20:41:54 +05:30
|
|
|
self.group_as, self.sort_as, self.display_as, self.call,
|
|
|
|
self.nick, self.famnick)
|
2006-02-04 03:33:53 +05:30
|
|
|
|
2006-10-10 04:16:06 +05:30
|
|
|
def is_empty(self):
|
2007-01-08 07:19:33 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Indicate if the name is empty.
|
2007-01-08 07:19:33 +05:30
|
|
|
"""
|
2010-09-17 18:56:36 +05:30
|
|
|
namefieldsempty = (self.first_name == u"" and
|
2010-09-25 20:41:54 +05:30
|
|
|
self.suffix == u"" and self.title == u"" and self.nick ==u""
|
|
|
|
and self.famnick == u"")
|
2010-09-17 18:56:36 +05:30
|
|
|
surnamefieldsempty = not (False in
|
|
|
|
[surn.is_empty() for surn in self.surname_list])
|
|
|
|
return namefieldsempty and surnamefieldsempty
|
2007-01-08 07:19:33 +05:30
|
|
|
|
|
|
|
def unserialize(self, data):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Convert a serialized tuple of data to an object.
|
2007-01-08 07:19:33 +05:30
|
|
|
"""
|
2007-02-20 06:09:10 +05:30
|
|
|
(privacy, source_list, note_list, date,
|
2010-09-17 18:56:36 +05:30
|
|
|
self.first_name, surname_list, self.suffix, self.title, name_type,
|
2010-09-25 20:41:54 +05:30
|
|
|
self.group_as, self.sort_as, self.display_as, self.call,
|
|
|
|
self.nick, self.famnick) = data
|
2007-08-30 04:31:16 +05:30
|
|
|
self.type = NameType(name_type)
|
2007-01-08 07:19:33 +05:30
|
|
|
PrivacyBase.unserialize(self, privacy)
|
2010-09-17 18:56:36 +05:30
|
|
|
SurnameBase.unserialize(self, surname_list)
|
2007-01-08 07:19:33 +05:30
|
|
|
SourceBase.unserialize(self, source_list)
|
2007-02-20 06:09:10 +05:30
|
|
|
NoteBase.unserialize(self, note_list)
|
2007-01-08 07:19:33 +05:30
|
|
|
DateBase.unserialize(self, date)
|
2006-02-04 03:33:53 +05:30
|
|
|
return self
|
|
|
|
|
2005-12-21 02:18:18 +05:30
|
|
|
def get_text_data_list(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the list of all textual attributes of the object.
|
2005-12-21 02:18:18 +05:30
|
|
|
|
2009-06-25 03:26:07 +05:30
|
|
|
:returns: Returns the list of all textual attributes of the object.
|
|
|
|
:rtype: list
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
2010-09-17 18:56:36 +05:30
|
|
|
return [self.first_name, self.suffix, self.title,
|
2010-09-25 20:41:54 +05:30
|
|
|
str(self.type), self.call, self.nick, self.famnick]
|
2005-12-21 02:18:18 +05:30
|
|
|
|
|
|
|
def get_text_data_child_list(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the list of child objects that may carry textual data.
|
2005-12-21 02:18:18 +05:30
|
|
|
|
2009-06-25 03:26:07 +05:30
|
|
|
:returns: Returns the list of child objects that may carry textual data.
|
|
|
|
:rtype: list
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
2010-09-17 18:56:36 +05:30
|
|
|
return self.source_list + self.surname_list
|
2005-12-21 02:18:18 +05:30
|
|
|
|
2007-12-15 03:48:19 +05:30
|
|
|
def get_note_child_list(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the list of child secondary objects that may refer notes.
|
2007-12-15 03:48:19 +05:30
|
|
|
|
2009-06-25 03:26:07 +05:30
|
|
|
:returns: Returns the list of child secondary child objects that may
|
2008-02-24 19:25:55 +05:30
|
|
|
refer notes.
|
2009-06-25 03:26:07 +05:30
|
|
|
:rtype: list
|
2007-12-15 03:48:19 +05:30
|
|
|
"""
|
|
|
|
return self.source_list
|
|
|
|
|
2005-12-21 02:18:18 +05:30
|
|
|
def get_handle_referents(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the list of child objects which may, directly or through
|
|
|
|
their children, reference primary objects.
|
2005-12-21 02:18:18 +05:30
|
|
|
|
2009-08-13 14:22:05 +05:30
|
|
|
:returns: Returns the list of objects referencing primary objects.
|
2009-06-25 03:26:07 +05:30
|
|
|
:rtype: list
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
|
|
|
return self.source_list
|
|
|
|
|
2007-02-20 06:09:10 +05:30
|
|
|
def get_referenced_handles(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the list of (classname, handle) tuples for all directly
|
2007-02-20 06:09:10 +05:30
|
|
|
referenced primary objects.
|
|
|
|
|
2009-06-25 03:26:07 +05:30
|
|
|
:returns: List of (classname, handle) tuples for referenced objects.
|
|
|
|
:rtype: list
|
2007-02-20 06:09:10 +05:30
|
|
|
"""
|
|
|
|
return self.get_referenced_note_handles()
|
|
|
|
|
2010-07-22 07:46:32 +05:30
|
|
|
def is_equivalent(self, other):
|
|
|
|
"""
|
2010-09-17 18:56:36 +05:30
|
|
|
Return if this name is equivalent, that is agrees in type, first,
|
|
|
|
call, surname_list, suffix, title and date, to other.
|
2010-07-22 07:46:32 +05:30
|
|
|
|
|
|
|
:param other: The name to compare this name to.
|
|
|
|
:rtype other: Name
|
|
|
|
:returns: Constant indicating degree of equivalence.
|
|
|
|
:rtype: int
|
|
|
|
"""
|
|
|
|
# TODO what to do with sort and display?
|
|
|
|
if self.get_text_data_list() != other.get_text_data_list() or \
|
2010-09-17 18:56:36 +05:30
|
|
|
self.get_date_object() != other.get_date_object() or \
|
|
|
|
SurnameBase.serialize(self) != SurnameBase.serialize(other):
|
2010-07-22 07:46:32 +05:30
|
|
|
return DIFFERENT
|
|
|
|
else:
|
|
|
|
if self.is_equal(other):
|
|
|
|
return IDENTICAL
|
|
|
|
else:
|
|
|
|
return EQUAL
|
|
|
|
|
|
|
|
def merge(self, acquisition):
|
|
|
|
"""
|
|
|
|
Merge the content of acquisition into this name.
|
2010-09-17 18:56:36 +05:30
|
|
|
Normally the person merge code should opt for adding an alternate
|
|
|
|
name if names are actually different (like not equal surname list)
|
2010-07-22 07:46:32 +05:30
|
|
|
|
2010-09-25 20:41:54 +05:30
|
|
|
Lost: type, first, call, suffix, title, nick, famnick and date of
|
2010-07-22 07:46:32 +05:30
|
|
|
acquisition.
|
|
|
|
|
|
|
|
:param acquisition: The name to merge with the present name.
|
|
|
|
:rtype acquisition: Name
|
|
|
|
"""
|
|
|
|
# TODO what to do with sort and display?
|
|
|
|
self._merge_privacy(acquisition)
|
2010-09-17 18:56:36 +05:30
|
|
|
self._merge_surname_list(acquisition)
|
2010-07-22 07:46:32 +05:30
|
|
|
self._merge_note_list(acquisition)
|
|
|
|
self._merge_source_reference_list(acquisition)
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def set_group_as(self, name):
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Set the grouping name for a person.
|
|
|
|
|
|
|
|
Normally, this is the person's surname. However, some locales group
|
|
|
|
equivalent names (e.g. Ivanova and Ivanov in Russian are usually
|
|
|
|
considered equivalent.
|
|
|
|
|
2007-10-09 18:35:56 +05:30
|
|
|
Note that there is also a database wide grouping set_name_group_mapping
|
|
|
|
So one might map a name Smith to SmithNew, and have one person still
|
|
|
|
grouped with name Smith. Hence, group_as can be equal to surname!
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
2007-10-09 18:35:56 +05:30
|
|
|
self.group_as = name
|
2005-12-21 02:18:18 +05:30
|
|
|
|
|
|
|
def get_group_as(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the grouping name, which is used to group equivalent surnames.
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
|
|
|
return self.group_as
|
|
|
|
|
|
|
|
def get_group_name(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the grouping name, which is used to group equivalent surnames.
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
|
|
|
if self.group_as:
|
|
|
|
return self.group_as
|
|
|
|
else:
|
|
|
|
return self.surname
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def set_sort_as(self, value):
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Specifies the sorting method for the specified name.
|
|
|
|
|
|
|
|
Typically the locale's default should be used. However, there may be
|
|
|
|
names where a specific sorting structure is desired for a name.
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
|
|
|
self.sort_as = value
|
|
|
|
|
|
|
|
def get_sort_as(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the selected sorting method for the name.
|
|
|
|
|
|
|
|
The options are LNFN (last name, first name), FNLN (first name, last
|
|
|
|
name), etc.
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
|
|
|
return self.sort_as
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def set_display_as(self, value):
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Specifies the display format for the specified name.
|
|
|
|
|
|
|
|
Typically the locale's default should be used. However, there may be
|
|
|
|
names where a specific display format is desired for a name.
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
|
|
|
self.display_as = value
|
|
|
|
|
|
|
|
def get_display_as(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the selected display format for the name.
|
|
|
|
|
|
|
|
The options are LNFN (last name, first name), FNLN (first name, last
|
|
|
|
name), etc.
|
2005-12-21 02:18:18 +05:30
|
|
|
"""
|
|
|
|
return self.display_as
|
|
|
|
|
2006-05-06 02:46:24 +05:30
|
|
|
def get_call_name(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the call name.
|
|
|
|
|
|
|
|
The call name's exact definition is not predetermined, and may be
|
|
|
|
locale specific.
|
2006-05-06 02:46:24 +05:30
|
|
|
"""
|
|
|
|
return self.call
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def set_call_name(self, val):
|
2006-05-06 02:46:24 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Set the call name.
|
|
|
|
|
|
|
|
The call name's exact definition is not predetermined, and may be
|
|
|
|
locale specific.
|
2006-05-06 02:46:24 +05:30
|
|
|
"""
|
|
|
|
self.call = val
|
|
|
|
|
2010-09-25 20:41:54 +05:30
|
|
|
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
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def set_type(self, the_type):
|
2008-02-24 19:25:55 +05:30
|
|
|
"""Set the type of the Name instance."""
|
2006-04-21 07:35:56 +05:30
|
|
|
self.type.set(the_type)
|
2005-12-21 02:18:18 +05:30
|
|
|
|
|
|
|
def get_type(self):
|
2008-02-24 19:25:55 +05:30
|
|
|
"""Return the type of the Name instance."""
|
2005-12-21 02:18:18 +05:30
|
|
|
return self.type
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def set_first_name(self, name):
|
2008-02-24 19:25:55 +05:30
|
|
|
"""Set the given name for the Name instance."""
|
2005-12-21 02:18:18 +05:30
|
|
|
self.first_name = name
|
|
|
|
|
|
|
|
def get_first_name(self):
|
2008-02-24 19:25:55 +05:30
|
|
|
"""Return the given name for the Name instance."""
|
2005-12-21 02:18:18 +05:30
|
|
|
return self.first_name
|
|
|
|
|
2010-09-17 18:56:36 +05:30
|
|
|
def set_suffix(self, name):
|
|
|
|
"""Set the suffix (such as Jr., III, etc.) for the Name instance."""
|
|
|
|
self.suffix = name
|
2005-12-21 02:18:18 +05:30
|
|
|
|
|
|
|
def get_suffix(self):
|
2008-02-24 19:25:55 +05:30
|
|
|
"""Return the suffix for the Name instance."""
|
2005-12-21 02:18:18 +05:30
|
|
|
return self.suffix
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def set_title(self, title):
|
2008-02-24 19:25:55 +05:30
|
|
|
"""Set the title (Dr., Reverand, Captain) for the Name instance."""
|
2005-12-21 02:18:18 +05:30
|
|
|
self.title = title
|
|
|
|
|
|
|
|
def get_title(self):
|
2008-02-24 19:25:55 +05:30
|
|
|
"""Return the title for the Name instance."""
|
2005-12-21 02:18:18 +05:30
|
|
|
return self.title
|
|
|
|
|
|
|
|
def get_name(self):
|
2008-02-24 19:25:55 +05:30
|
|
|
"""
|
|
|
|
Return a name string built from the components of the Name instance,
|
2010-09-17 18:56:36 +05:30
|
|
|
in the form of: surname, Firstname.
|
2008-02-24 19:25:55 +05:30
|
|
|
"""
|
2010-09-17 18:56:36 +05:30
|
|
|
first = self.first_name
|
|
|
|
surname = self.get_surname()
|
2005-12-21 02:18:18 +05:30
|
|
|
if self.suffix:
|
2010-09-17 18:56:36 +05:30
|
|
|
return "%s, %s %s" % (surname, first, self.suffix)
|
2005-12-21 02:18:18 +05:30
|
|
|
else:
|
2010-09-17 18:56:36 +05:30
|
|
|
return "%s, %s" % (surname, first)
|
2005-12-21 02:18:18 +05:30
|
|
|
|
|
|
|
def get_upper_name(self):
|
2008-02-24 19:25:55 +05:30
|
|
|
"""
|
|
|
|
Return a name string built from the components of the Name instance,
|
2010-09-17 18:56:36 +05:30
|
|
|
in the form of SURNAME, Firstname.
|
2008-02-24 19:25:55 +05:30
|
|
|
"""
|
2010-09-17 18:56:36 +05:30
|
|
|
first = self.first_name
|
|
|
|
surname = self.get_surname().upper()
|
2005-12-21 02:18:18 +05:30
|
|
|
if self.suffix:
|
2010-09-17 18:56:36 +05:30
|
|
|
return "%s, %s %s" % (surname, first, self.suffix)
|
2005-12-21 02:18:18 +05:30
|
|
|
else:
|
2010-09-17 18:56:36 +05:30
|
|
|
return "%s, %s" % (surname, first)
|
2005-12-21 02:18:18 +05:30
|
|
|
|
|
|
|
def get_regular_name(self):
|
2008-02-24 19:25:55 +05:30
|
|
|
"""
|
|
|
|
Return a name string built from the components of the Name instance,
|
|
|
|
in the form of Firstname surname.
|
|
|
|
"""
|
2010-09-17 18:56:36 +05:30
|
|
|
first = self.first_name
|
|
|
|
surname = self.get_surname()
|
2005-12-21 02:18:18 +05:30
|
|
|
if (self.suffix == ""):
|
2010-09-17 18:56:36 +05:30
|
|
|
return "%s %s" % (first, surname)
|
2005-12-21 02:18:18 +05:30
|
|
|
else:
|
2010-09-17 18:56:36 +05:30
|
|
|
return "%s %s, %s" % (first, surname, self.suffix)
|
2009-09-26 06:35:08 +05:30
|
|
|
|
|
|
|
def get_gedcom_parts(self):
|
|
|
|
"""
|
|
|
|
Returns a GEDCOM-formatted name dictionary.
|
2010-09-17 18:56:36 +05:30
|
|
|
Note, field patronymic and prefix are deprecated, prefix_list and
|
|
|
|
surname list, added.
|
2009-09-26 06:35:08 +05:30
|
|
|
"""
|
|
|
|
retval = {}
|
|
|
|
retval['given'] = self.first_name.strip()
|
2010-09-17 18:56:36 +05:30
|
|
|
retval['surname'] = self.get_surname().replace('/', '?')
|
2009-09-26 06:35:08 +05:30
|
|
|
retval['suffix'] = self.suffix
|
|
|
|
retval['title'] = self.title
|
2010-09-17 18:56:36 +05:30
|
|
|
retval['surnamelist'] = self.get_surnames()
|
|
|
|
retval['prefixes'] = self.get_prefixes()
|
|
|
|
retval['connectors'] = self.get_connectors()
|
2010-09-25 20:41:54 +05:30
|
|
|
retval['nick'] = self.nick
|
|
|
|
retval['famnick'] = self.famnick
|
2009-09-26 06:35:08 +05:30
|
|
|
return retval
|
|
|
|
|
|
|
|
def get_gedcom_name(self):
|
|
|
|
"""
|
|
|
|
Returns a GEDCOM-formatted name.
|
|
|
|
"""
|
|
|
|
firstname = self.first_name.strip()
|
2010-09-17 18:56:36 +05:30
|
|
|
surname = self.get_surname().replace('/', '?')
|
2009-09-26 06:35:08 +05:30
|
|
|
suffix = self.suffix
|
|
|
|
title = self.title
|
|
|
|
if suffix == "":
|
2010-09-17 18:56:36 +05:30
|
|
|
return '%s /%s/' % (firstname, surname)
|
2009-09-26 06:35:08 +05:30
|
|
|
else:
|
2010-09-17 18:56:36 +05:30
|
|
|
return '%s /%s/ %s' % (firstname, surname, suffix)
|
|
|
|
|
|
|
|
##
|
|
|
|
## #DEPRECATED METHODS
|
|
|
|
##
|
|
|
|
##
|
|
|
|
## def get_surname_prefix(self):
|
|
|
|
## """
|
|
|
|
## Return the prefix (or article) of a surname.
|
|
|
|
##
|
|
|
|
## The prefix is not used for sorting or grouping.
|
|
|
|
## """
|
|
|
|
## return self.prefix
|
|
|
|
##
|
|
|
|
## def set_surname_prefix(self, val):
|
|
|
|
## """
|
|
|
|
## Set the prefix (or article) of a surname.
|
|
|
|
##
|
|
|
|
## Examples of articles would be 'de' or 'van'.
|
|
|
|
## """
|
|
|
|
## self.prefix = val
|
|
|
|
##
|
|
|
|
## def get_patronymic(self):
|
|
|
|
## """Return the patronymic name for the Name instance."""
|
|
|
|
## return self.patronymic
|
|
|
|
##
|
|
|
|
## def set_patronymic(self, name):
|
|
|
|
## """Set the patronymic name for the Name instance."""
|
|
|
|
## self.patronymic = name
|
|
|
|
##
|
|
|
|
## def get_surname(self):
|
|
|
|
## """Return the surname (or last name) for the Name instance."""
|
|
|
|
## return self.surname
|
|
|
|
##
|
|
|
|
## def set_surname(self, name):
|
|
|
|
## """Set the surname (or last name) for the Name instance."""
|
|
|
|
## self.surname = name
|