2005-01-01 20:46:44 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-06-15 01:50:39 +05:30
|
|
|
# Copyright (C) 2004-2006 Donald N. Allingham
|
2005-01-01 20:46:44 +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$
|
|
|
|
|
|
|
|
"""
|
|
|
|
Class handling language-specific displaying of names.
|
|
|
|
"""
|
|
|
|
|
2005-02-25 22:36:04 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-21 03:13:40 +05:30
|
|
|
from RelLib import Name
|
2006-07-06 23:16:46 +05:30
|
|
|
import Config
|
2005-01-01 20:46:44 +05:30
|
|
|
|
2006-04-13 10:56:19 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
_FIRSTNAME = 4
|
|
|
|
_SURNAME = 5
|
|
|
|
_SUFFIX = 6
|
|
|
|
_TITLE = 7
|
|
|
|
_TYPE = 8
|
|
|
|
_PREFIX = 9
|
|
|
|
_PATRONYM = 10
|
|
|
|
_SNAME = 11
|
|
|
|
_GROUP = 12
|
|
|
|
_SORT = 13
|
|
|
|
_DISPLAY = 14
|
2006-06-25 11:09:32 +05:30
|
|
|
_CALL = 15
|
2006-04-13 10:56:19 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##-------------------------------------------------------------------------
|
|
|
|
##
|
|
|
|
## formats registration
|
|
|
|
##
|
|
|
|
##-------------------------------------------------------------------------
|
|
|
|
##CUSTOM_FORMATS = []
|
2006-07-06 23:16:46 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##def register_custom_formats(formats):
|
|
|
|
##CUSTOM_FORMATS = formats[:]
|
2006-06-15 01:50:39 +05:30
|
|
|
|
2005-02-25 22:36:04 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# NameDisplay class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-01-01 20:46:44 +05:30
|
|
|
class NameDisplay:
|
|
|
|
"""
|
|
|
|
Base class for displaying of Name instances.
|
|
|
|
"""
|
2006-06-15 01:50:39 +05:30
|
|
|
|
|
|
|
# FIXME: Is this used anywhere? I cannot see that it is.
|
|
|
|
sort_field = (Name.get_surname, Name.get_surname,
|
|
|
|
Name.get_first_name, Name.get_patronymic,
|
|
|
|
Name.get_first_name)
|
|
|
|
|
2005-01-01 20:46:44 +05:30
|
|
|
def __init__(self,use_upper=False):
|
|
|
|
"""
|
|
|
|
Creates a new NameDisplay class.
|
|
|
|
|
|
|
|
@param use_upper: True indicates that the surname should be
|
|
|
|
displayed in upper case.
|
|
|
|
@type use_upper: bool
|
|
|
|
"""
|
2006-07-06 23:16:46 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##self.force_upper = use_upper
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
self.CUSTOM_FORMATS = []
|
|
|
|
|
2006-07-06 23:16:46 +05:30
|
|
|
self.fn_array = {
|
2006-07-16 20:14:13 +05:30
|
|
|
##Name.LNFN: self._lnfn,
|
|
|
|
##Name.FNLN: self._fnln,
|
|
|
|
##Name.PTFN: self._ptfn,
|
|
|
|
##Name.FN: self._fn,
|
2006-07-06 23:16:46 +05:30
|
|
|
}
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-06 23:16:46 +05:30
|
|
|
self.raw_fn_array = {
|
2006-07-16 20:14:13 +05:30
|
|
|
##Name.LNFN: self._lnfn_raw,
|
|
|
|
##Name.FNLN: self._fnln_raw,
|
|
|
|
##Name.PTFN: self._ptfn_raw,
|
|
|
|
##Name.FN: self._fn_raw,
|
2006-07-06 23:16:46 +05:30
|
|
|
}
|
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
self.set_format_fn()
|
|
|
|
|
|
|
|
default_idx = Config.get(Config.NAME_FORMAT)
|
|
|
|
if default_idx == 0:
|
|
|
|
default_idx = Name.LNFN
|
|
|
|
self.set_format_default(default_idx)
|
2006-07-06 23:16:46 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
def _format_fn(self,fmt_str):
|
|
|
|
return lambda x: self.format_str(x,fmt_str)
|
|
|
|
|
|
|
|
def _format_raw_fn(self,fmt_str):
|
|
|
|
return lambda x: self.format_str_raw(x,fmt_str)
|
|
|
|
|
|
|
|
def set_format_fn(self):
|
|
|
|
# Add standard formats to mappings
|
|
|
|
for number,name,fmt_str in Name.STANDARD_FORMATS:
|
|
|
|
self.fn_array[number] = self._format_fn(fmt_str)
|
|
|
|
self.raw_fn_array[number] = self._format_raw_fn(fmt_str)
|
2006-07-06 23:16:46 +05:30
|
|
|
# Add custom formats to the mappings
|
2006-07-16 20:14:13 +05:30
|
|
|
for number,name,fmt_str in self.CUSTOM_FORMATS:
|
|
|
|
self.fn_array[number] = self._format_fn(fmt_str)
|
|
|
|
self.raw_fn_array[number] = self._format_raw_fn(fmt_str)
|
|
|
|
|
|
|
|
def set_format_default(self,idx):
|
2006-07-06 23:16:46 +05:30
|
|
|
# Add mappings for the gramps-prefs format
|
2006-07-16 20:14:13 +05:30
|
|
|
if not self.fn_array.has_key(idx):
|
|
|
|
idx = Name.LNFN
|
|
|
|
# this should not happen if the default is kept in the db
|
|
|
|
|
|
|
|
self.gramps_format = idx
|
|
|
|
self.fn_array[0] = self.fn_array[idx]
|
|
|
|
self.raw_fn_array[0] = self.raw_fn_array[idx]
|
|
|
|
|
|
|
|
def register_custom_formats(self,formats):
|
|
|
|
self.CUSTOM_FORMATS = formats[:]
|
|
|
|
self.set_format_fn()
|
|
|
|
|
|
|
|
##def use_upper(self,upper):
|
|
|
|
##"""
|
|
|
|
##Changes the NameDisplay class to enable or display the displaying
|
|
|
|
##of surnames in upper case.
|
2005-01-01 20:46:44 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##@param upper: True indicates that the surname should be
|
|
|
|
##displayed in upper case.
|
|
|
|
##@type upper: bool
|
|
|
|
##"""
|
|
|
|
##self.force_upper = upper
|
2005-01-01 20:46:44 +05:30
|
|
|
|
2006-03-21 11:53:45 +05:30
|
|
|
def sort_string(self,name):
|
|
|
|
return u"%-25s%-30s%s" % (name.surname,name.first_name,name.suffix)
|
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##def _fn(self,name):
|
|
|
|
##return self._fn_base(name.first_name)
|
2005-01-01 20:46:44 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##def _fn_raw(self,raw_data):
|
|
|
|
##first = raw_data[_FIRSTNAME]
|
|
|
|
##return self._fn_base(first)
|
2005-01-01 20:46:44 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##def _fn_base(self,first):
|
|
|
|
##return first
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##def _ptfn(self,name):
|
|
|
|
##"""
|
|
|
|
##Prints the Western style first name, last name style.
|
|
|
|
##Typically this is::
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##SurnamePrefix Patronymic SurnameSuffix, FirstName
|
|
|
|
##"""
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##return self._ptfn_base(name.first_name,name.suffix,
|
|
|
|
##name.prefix,name.patronymic)
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##def _ptfn_raw(self,raw_data):
|
|
|
|
##"""
|
|
|
|
##Prints the Western style first name, last name style.
|
|
|
|
##Typically this is::
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##SurnamePrefix Patronymic SurnameSuffix, FirstName
|
|
|
|
##"""
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##first = raw_data[_FIRSTNAME]
|
|
|
|
##suffix = raw_data[_SUFFIX]
|
|
|
|
##prefix = raw_data[_PREFIX]
|
|
|
|
##patronymic = raw_data[_PATRONYM]
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##return self._ptfn_base(first,suffix,prefix,patronymic)
|
2006-06-15 01:50:39 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##def _ptfn_base(self,first,suffix,prefix,patronymic):
|
|
|
|
##if self.force_upper:
|
|
|
|
##last = patronymic.upper()
|
|
|
|
##else:
|
|
|
|
##last = patronymic
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##if suffix:
|
|
|
|
##if prefix:
|
|
|
|
##return "%s %s %s, %s" % (prefix, last, suffix, first)
|
|
|
|
##else:
|
|
|
|
##return "%s %s, %s" % (last, suffix, first)
|
|
|
|
##else:
|
|
|
|
##if prefix:
|
|
|
|
##return "%s %s, %s" % (prefix, last, first)
|
|
|
|
##else:
|
|
|
|
##return "%s, %s" % (last, first)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##def _fnln(self,name):
|
|
|
|
##"""
|
|
|
|
##Prints the Western style first name, last name style.
|
|
|
|
##Typically this is::
|
|
|
|
|
|
|
|
##FirstName Patronymic SurnamePrefix Surname SurnameSuffix
|
|
|
|
##"""
|
|
|
|
##return self._fnln_base(name.first_name,name.surname,name.suffix,
|
|
|
|
##name.prefix,name.patronymic)
|
|
|
|
|
|
|
|
##def _fnln_raw(self,raw_data):
|
|
|
|
##"""
|
|
|
|
##Prints the Western style first name, last name style.
|
|
|
|
##Typically this is::
|
|
|
|
|
|
|
|
##FirstName Patronymic SurnamePrefix Surname SurnameSuffix
|
|
|
|
##"""
|
|
|
|
##first = raw_data[_FIRSTNAME]
|
|
|
|
##surname = raw_data[_SURNAME]
|
|
|
|
##suffix = raw_data[_SUFFIX]
|
|
|
|
##prefix = raw_data[_PREFIX]
|
|
|
|
##patronymic = raw_data[_PATRONYM]
|
|
|
|
##return self._fnln_base(first,surname,suffix,prefix,patronymic)
|
|
|
|
|
|
|
|
##def _fnln_base(self,first,surname,suffix,prefix,patronymic):
|
|
|
|
##if patronymic:
|
|
|
|
##first = "%s %s" % (first, patronymic)
|
|
|
|
|
|
|
|
##if self.force_upper:
|
|
|
|
##last = surname.upper()
|
|
|
|
##else:
|
|
|
|
##last = surname
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
##if suffix:
|
|
|
|
##if prefix:
|
|
|
|
##return "%s %s %s, %s" % (first, prefix, last, suffix)
|
|
|
|
##else:
|
|
|
|
##return "%s %s, %s" % (first, last, suffix)
|
|
|
|
##else:
|
|
|
|
##if prefix:
|
|
|
|
##return "%s %s %s" % (first, prefix, last)
|
|
|
|
##else:
|
|
|
|
##return "%s %s" % (first, last)
|
|
|
|
|
|
|
|
##def _lnfn(self,name):
|
|
|
|
##"""
|
|
|
|
##Prints the Western style last name, first name style.
|
|
|
|
##Typically this is::
|
|
|
|
|
|
|
|
##SurnamePrefix Surname, FirstName Patronymic SurnameSuffix
|
|
|
|
##"""
|
|
|
|
##return self._lnfn_base(name.first_name,name.surname,name.prefix,
|
|
|
|
##name.suffix,name.patronymic)
|
|
|
|
|
|
|
|
##def _lnfn_raw(self,raw_data):
|
|
|
|
##"""
|
|
|
|
##Prints the Western style last name, first name style.
|
|
|
|
##Typically this is::
|
|
|
|
|
|
|
|
##SurnamePrefix Surname, FirstName Patronymic SurnameSuffix
|
|
|
|
##"""
|
|
|
|
|
|
|
|
##surname = raw_data[_SURNAME]
|
|
|
|
##prefix = raw_data[_PREFIX]
|
|
|
|
##first = raw_data[_FIRSTNAME]
|
|
|
|
##patronymic = raw_data[_PATRONYM]
|
|
|
|
##suffix = raw_data[_SUFFIX]
|
|
|
|
|
|
|
|
##return self._lnfn_base(first,surname,prefix,suffix,patronymic)
|
|
|
|
|
|
|
|
##def _lnfn_base(self,first,surname,prefix,suffix,patronymic):
|
|
|
|
##if self.force_upper:
|
|
|
|
##last = surname.upper()
|
|
|
|
##else:
|
|
|
|
##last = surname
|
|
|
|
|
|
|
|
##if last:
|
|
|
|
##last += ","
|
|
|
|
|
|
|
|
##return " ".join([prefix, last, first, patronymic, suffix])
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
def format_str(self,name,format_str):
|
2006-07-06 23:16:46 +05:30
|
|
|
return self._format_str_base(name.first_name,name.surname,name.prefix,
|
|
|
|
name.suffix,name.patronymic,name.title,
|
|
|
|
name.call,format_str)
|
2006-06-25 11:09:32 +05:30
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
def format_str_raw(self,raw_data,format_str):
|
2006-06-25 11:09:32 +05:30
|
|
|
surname = raw_data[_SURNAME]
|
|
|
|
prefix = raw_data[_PREFIX]
|
|
|
|
first = raw_data[_FIRSTNAME]
|
|
|
|
patronymic = raw_data[_PATRONYM]
|
|
|
|
suffix = raw_data[_SUFFIX]
|
|
|
|
title = raw_data[_TITLE]
|
|
|
|
call = raw_data[_CALL]
|
2006-07-06 23:16:46 +05:30
|
|
|
return self._format_str_base(first,surname,prefix,suffix,patronymic,
|
|
|
|
title,call,format_str)
|
2006-06-25 11:09:32 +05:30
|
|
|
|
2006-07-06 23:16:46 +05:30
|
|
|
def _format_str_base(self,first,surname,prefix,suffix,patronymic,
|
|
|
|
title,call,format_str):
|
2006-06-25 11:09:32 +05:30
|
|
|
"""
|
2006-07-07 05:15:15 +05:30
|
|
|
Generates name from a format string.
|
|
|
|
|
|
|
|
The following substitutions are made:
|
|
|
|
%t -> title
|
|
|
|
%f -> given name (first name)
|
|
|
|
%p -> prefix
|
|
|
|
%s -> suffix
|
|
|
|
%l -> family name (last name, surname)
|
|
|
|
%y -> patronymic
|
|
|
|
%c -> call 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.
|
|
|
|
|
2006-06-25 11:09:32 +05:30
|
|
|
"""
|
|
|
|
|
2006-07-06 23:16:46 +05:30
|
|
|
output = format_str
|
2006-06-25 11:09:32 +05:30
|
|
|
|
|
|
|
output = output.replace("%t",title)
|
|
|
|
output = output.replace("%f",first)
|
|
|
|
output = output.replace("%p",prefix)
|
|
|
|
output = output.replace("%l",surname)
|
|
|
|
output = output.replace("%s",suffix)
|
|
|
|
output = output.replace("%y",patronymic)
|
|
|
|
output = output.replace("%c",call)
|
2006-07-07 05:15:15 +05:30
|
|
|
|
2006-06-25 11:09:32 +05:30
|
|
|
output = output.replace("%T",title.upper())
|
|
|
|
output = output.replace("%F",first.upper())
|
|
|
|
output = output.replace("%P",prefix.upper())
|
|
|
|
output = output.replace("%L",surname.upper())
|
|
|
|
output = output.replace("%S",suffix.upper())
|
|
|
|
output = output.replace("%Y",patronymic.upper())
|
|
|
|
output = output.replace("%C",call.upper())
|
|
|
|
output = output.replace("%%",'%')
|
|
|
|
|
2006-07-16 20:14:13 +05:30
|
|
|
# Suppress multiple spaces
|
|
|
|
prev_space = -1
|
|
|
|
namestr = ''
|
|
|
|
for i in range(len(output)):
|
|
|
|
if output[i] == ' ':
|
|
|
|
dist = i - prev_space
|
|
|
|
prev_space = i
|
|
|
|
if dist == 1:
|
|
|
|
continue
|
|
|
|
namestr += output[i]
|
|
|
|
|
|
|
|
return namestr.strip()
|
2006-06-25 11:09:32 +05:30
|
|
|
|
2006-07-06 23:16:46 +05:30
|
|
|
def sorted(self,person):
|
|
|
|
"""
|
|
|
|
Returns a text string representing the L{RelLib.Person} instance's
|
|
|
|
L{Name} in a manner that should be used for displaying a sorted
|
|
|
|
name.
|
|
|
|
|
|
|
|
@param person: L{RelLib.Person} instance that contains the
|
|
|
|
L{Name} that is to be displayed. The primary name is used for
|
|
|
|
the display.
|
|
|
|
@type person: L{RelLib.Person}
|
|
|
|
@returns: Returns the L{RelLib.Person} instance's name
|
|
|
|
@rtype: str
|
|
|
|
"""
|
|
|
|
name = person.get_primary_name()
|
|
|
|
return self.sorted_name(name)
|
|
|
|
|
2006-01-21 03:13:40 +05:30
|
|
|
def sorted_name(self,name):
|
|
|
|
"""
|
|
|
|
Returns a text string representing the L{Name} instance
|
|
|
|
in a manner that should be used for displaying a sorted
|
|
|
|
name.
|
|
|
|
|
|
|
|
@param name: L{Name} instance that is to be displayed.
|
|
|
|
@type name: L{Name}
|
|
|
|
@returns: Returns the L{Name} string representation
|
|
|
|
@rtype: str
|
|
|
|
"""
|
2006-03-20 05:04:23 +05:30
|
|
|
return self.fn_array[name.sort_as](name)
|
|
|
|
|
|
|
|
def raw_sorted_name(self,raw_data):
|
|
|
|
"""
|
|
|
|
Returns a text string representing the L{Name} instance
|
|
|
|
in a manner that should be used for displaying a sorted
|
|
|
|
name.
|
|
|
|
|
|
|
|
@param name: L{Name} instance that is to be displayed.
|
|
|
|
@type name: L{Name}
|
|
|
|
@returns: Returns the L{Name} string representation
|
|
|
|
@rtype: str
|
|
|
|
"""
|
2006-04-13 10:56:19 +05:30
|
|
|
return self.raw_fn_array[raw_data[_SORT]](raw_data)
|
2006-01-21 03:13:40 +05:30
|
|
|
|
|
|
|
def display(self,person):
|
|
|
|
"""
|
|
|
|
Returns a text string representing the L{RelLib.Person} instance's
|
|
|
|
L{Name} in a manner that should be used for normal displaying.
|
|
|
|
|
|
|
|
@param person: L{RelLib.Person} instance that contains the
|
|
|
|
L{Name} that is to be displayed. The primary name is used for
|
|
|
|
the display.
|
|
|
|
@type person: L{RelLib.Person}
|
|
|
|
@returns: Returns the L{RelLib.Person} instance's name
|
|
|
|
@rtype: str
|
|
|
|
"""
|
|
|
|
name = person.get_primary_name()
|
2006-07-06 23:16:46 +05:30
|
|
|
return self.display_name(name)
|
2006-01-21 03:13:40 +05:30
|
|
|
|
|
|
|
def display_formal(self,person):
|
|
|
|
"""
|
|
|
|
Returns a text string representing the L{RelLib.Person} instance's
|
|
|
|
L{Name} in a manner that should be used for normal displaying.
|
|
|
|
|
|
|
|
@param person: L{RelLib.Person} instance that contains the
|
|
|
|
L{Name} that is to be displayed. The primary name is used for
|
|
|
|
the display.
|
|
|
|
@type person: L{RelLib.Person}
|
|
|
|
@returns: Returns the L{RelLib.Person} instance's name
|
|
|
|
@rtype: str
|
|
|
|
"""
|
2006-07-06 23:16:46 +05:30
|
|
|
# FIXME: At this time, this is just duplicating display() method
|
2006-01-21 03:13:40 +05:30
|
|
|
name = person.get_primary_name()
|
2006-07-06 23:16:46 +05:30
|
|
|
return self.display_name(name)
|
2006-01-21 03:13:40 +05:30
|
|
|
|
|
|
|
def display_name(self,name):
|
|
|
|
"""
|
|
|
|
Returns a text string representing the L{Name} instance
|
|
|
|
in a manner that should be used for normal displaying.
|
|
|
|
|
|
|
|
@param name: L{Name} instance that is to be displayed.
|
|
|
|
@type name: L{Name}
|
|
|
|
@returns: Returns the L{Name} string representation
|
|
|
|
@rtype: str
|
|
|
|
"""
|
|
|
|
if name == None:
|
|
|
|
return ""
|
2006-07-06 23:16:46 +05:30
|
|
|
return self.fn_array[name.display_as](name)
|
|
|
|
|
|
|
|
def display_given(self,person):
|
|
|
|
name = person.get_primary_name()
|
|
|
|
if name.patronymic:
|
|
|
|
return "%s %s" % (name.first_name, name.patronymic)
|
2006-01-21 03:13:40 +05:30
|
|
|
else:
|
2006-07-06 23:16:46 +05:30
|
|
|
return name.first_name
|
2006-01-21 03:13:40 +05:30
|
|
|
|
|
|
|
def name_grouping(self,db,person):
|
|
|
|
return self.name_grouping_name(db,person.primary_name)
|
|
|
|
|
|
|
|
def name_grouping_name(self,db,pn):
|
|
|
|
if pn.group_as:
|
|
|
|
return pn.group_as
|
|
|
|
sv = pn.sort_as
|
2006-07-06 23:16:46 +05:30
|
|
|
if sv == Name.LNFN:
|
2006-01-21 03:13:40 +05:30
|
|
|
return db.get_name_group_mapping(pn.surname)
|
|
|
|
elif sv == Name.PTFN:
|
|
|
|
return db.get_name_group_mapping(pn.patronymic)
|
|
|
|
else:
|
|
|
|
return db.get_name_group_mapping(pn.first_name)
|
|
|
|
|
2005-01-01 20:46:44 +05:30
|
|
|
displayer = NameDisplay()
|