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.
|
|
|
|
"""
|
|
|
|
|
2006-08-04 01:19:29 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
2007-01-17 03:55:29 +05:30
|
|
|
import re
|
2006-08-04 01:19:29 +05:30
|
|
|
|
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
|
2006-08-18 11:19:25 +05:30
|
|
|
_GROUP = 11
|
|
|
|
_SORT = 12
|
|
|
|
_DISPLAY = 13
|
|
|
|
_CALL = 14
|
2006-04-13 10:56:19 +05:30
|
|
|
|
2006-07-31 16:38:44 +05:30
|
|
|
_ACT = True
|
|
|
|
_INA = False
|
|
|
|
|
|
|
|
_F_NAME = 0 # name of the format
|
|
|
|
_F_FMT = 1 # the format string
|
|
|
|
_F_ACT = 2 # if the format is active
|
|
|
|
_F_FN = 3 # name format function
|
|
|
|
_F_RAWFN = 4 # name format raw function
|
|
|
|
|
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
|
|
|
|
2007-01-17 03:55:29 +05:30
|
|
|
format_funcs = {}
|
|
|
|
|
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)
|
|
|
|
|
2006-07-31 16:38:44 +05:30
|
|
|
STANDARD_FORMATS = [
|
|
|
|
(Name.DEF,_("Default format (defined by GRAMPS preferences)"),'',_ACT),
|
|
|
|
(Name.LNFN,_("Family name, Given name Patronymic"),'%p %l, %f %y %s',_ACT),
|
|
|
|
(Name.FNLN,_("Given name Family name"),'%f %y %p %l %s',_ACT),
|
|
|
|
(Name.PTFN,_("Patronymic, Given name"),'%p %y, %s %f',_ACT),
|
|
|
|
(Name.FN,_("Given name"),'%f',_ACT)
|
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.name_formats = {}
|
|
|
|
self.set_name_format(self.STANDARD_FORMATS)
|
2006-07-16 20:14:13 +05:30
|
|
|
|
2006-07-31 16:38:44 +05:30
|
|
|
self.default_format = Config.get(Config.NAME_FORMAT)
|
|
|
|
if self.default_format == 0:
|
|
|
|
self.default_format = Name.LNFN
|
|
|
|
Config.set(Config.NAME_FORMAT,self.default_format)
|
|
|
|
|
|
|
|
self.set_default_format(self.default_format)
|
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)
|
|
|
|
|
2006-07-31 16:38:44 +05:30
|
|
|
def set_name_format(self,formats):
|
|
|
|
for (num,name,fmt_str,act) in formats:
|
|
|
|
self.name_formats[num] = (name,fmt_str,act,
|
|
|
|
self._format_fn(fmt_str),
|
|
|
|
self._format_raw_fn(fmt_str))
|
|
|
|
|
|
|
|
def add_name_format(self,name,fmt_str):
|
|
|
|
num = -1
|
|
|
|
while num in self.name_formats:
|
|
|
|
num -= 1
|
|
|
|
self.set_name_format([(num,name,fmt_str,_ACT)])
|
|
|
|
return num
|
|
|
|
|
|
|
|
def edit_name_format(self,num,name,fmt_str):
|
|
|
|
self.set_name_format([(num,name,fmt_str,_ACT)])
|
|
|
|
if self.default_format == num:
|
|
|
|
self.set_default_format(num)
|
2006-07-27 16:18:16 +05:30
|
|
|
|
2006-07-31 16:38:44 +05:30
|
|
|
def del_name_format(self,num):
|
2006-07-27 16:18:16 +05:30
|
|
|
try:
|
2006-07-31 16:38:44 +05:30
|
|
|
del self.name_formats[num]
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def set_default_format(self,num):
|
|
|
|
if num not in self.name_formats:
|
|
|
|
num = Name.LNFN
|
2006-07-27 16:18:16 +05:30
|
|
|
|
2006-07-31 16:38:44 +05:30
|
|
|
self.default_format = num
|
2005-01-01 20:46:44 +05:30
|
|
|
|
2006-07-31 16:38:44 +05:30
|
|
|
self.name_formats[Name.DEF] = (self.name_formats[Name.DEF][_F_NAME],
|
|
|
|
self.name_formats[Name.DEF][_F_FMT],
|
|
|
|
self.name_formats[Name.DEF][_F_ACT],
|
|
|
|
self.name_formats[num][_F_FN],
|
|
|
|
self.name_formats[num][_F_RAWFN])
|
|
|
|
|
|
|
|
def get_default_format(self):
|
|
|
|
return self.default_format
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-31 16:38:44 +05:30
|
|
|
def set_format_inactive(self,num):
|
|
|
|
try:
|
|
|
|
self.name_formats[num] = (self.name_formats[num][_F_NAME],
|
|
|
|
self.name_formats[num][_F_FMT],
|
|
|
|
_INA,
|
|
|
|
self.name_formats[num][_F_FN],
|
|
|
|
self.name_formats[num][_F_RAWFN])
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def get_name_format(self,also_default=False,
|
|
|
|
only_custom=False,
|
|
|
|
only_active=True):
|
|
|
|
"""
|
|
|
|
Get a list of tuples (num,name,fmt_str,act)
|
|
|
|
"""
|
|
|
|
the_list = []
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-31 16:38:44 +05:30
|
|
|
keys = self.name_formats.keys()
|
|
|
|
keys.sort(self._sort_name_format)
|
|
|
|
|
|
|
|
for num in keys:
|
|
|
|
if ((also_default or num) and
|
|
|
|
(not only_custom or (num < 0)) and
|
|
|
|
(not only_active or self.name_formats[num][_F_ACT])):
|
|
|
|
the_list.append((num,) + self.name_formats[num][_F_NAME:_F_FN])
|
|
|
|
|
|
|
|
return the_list
|
|
|
|
|
|
|
|
def _sort_name_format(self,x,y):
|
|
|
|
if x<0:
|
|
|
|
if y<0: return x+y
|
|
|
|
else: return -x+y
|
|
|
|
else:
|
|
|
|
if y<0: return -x+y
|
|
|
|
else: return x-y
|
|
|
|
|
|
|
|
def _is_format_valid(self,num):
|
|
|
|
try:
|
|
|
|
if not self.name_formats[num][_F_ACT]:
|
|
|
|
num = 0
|
|
|
|
except:
|
|
|
|
num = 0
|
|
|
|
return num
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-07-31 16:38:44 +05:30
|
|
|
#-------------------------------------------------------------------------
|
2006-06-15 01:50:39 +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()
|
2007-01-17 03:55:29 +05:30
|
|
|
|
|
|
|
def _gen_func(self, format_str):
|
|
|
|
d = {"%t":"title",
|
|
|
|
"%f":"first",
|
|
|
|
"%p":"prefix",
|
|
|
|
"%l":"surname",
|
|
|
|
"%s":"suffix",
|
|
|
|
"%y":"patronymic",
|
|
|
|
"%c":"call",
|
|
|
|
"%T":"title.upper()",
|
|
|
|
"%F":"first.upper()",
|
|
|
|
"%P":"prefix.upper()",
|
|
|
|
"%L":"surname.upper()",
|
|
|
|
"%S":"suffix.upper()",
|
|
|
|
"%Y":"patronymic.upper()",
|
|
|
|
"%C":"call.upper()",
|
|
|
|
"%%":"'%'"}
|
|
|
|
|
|
|
|
|
|
|
|
new_fmt = format_str
|
|
|
|
|
|
|
|
new_fmt = new_fmt.replace("%t","%s")
|
|
|
|
new_fmt = new_fmt.replace("%f","%s")
|
|
|
|
new_fmt = new_fmt.replace("%p","%s")
|
|
|
|
new_fmt = new_fmt.replace("%l","%s")
|
|
|
|
new_fmt = new_fmt.replace("%s","%s")
|
|
|
|
new_fmt = new_fmt.replace("%y","%s")
|
|
|
|
new_fmt = new_fmt.replace("%c","%s")
|
|
|
|
|
|
|
|
new_fmt = new_fmt.replace("%T","%s")
|
|
|
|
new_fmt = new_fmt.replace("%F","%s")
|
|
|
|
new_fmt = new_fmt.replace("%P","%s")
|
|
|
|
new_fmt = new_fmt.replace("%L","%s")
|
|
|
|
new_fmt = new_fmt.replace("%S","%s")
|
|
|
|
new_fmt = new_fmt.replace("%Y","%s")
|
|
|
|
new_fmt = new_fmt.replace("%C","%s")
|
|
|
|
new_fmt = new_fmt.replace("%%",'%')
|
|
|
|
|
|
|
|
pat = re.compile("%.")
|
|
|
|
|
|
|
|
mat = pat.search(format_str)
|
|
|
|
|
|
|
|
param = ()
|
|
|
|
while mat:
|
|
|
|
param = param + (d[mat.group(0)],)
|
|
|
|
mat = pat.search(format_str,mat.end())
|
|
|
|
|
|
|
|
s = 'def fn(first,surname,prefix,suffix,patronymic,title,call,):\n'\
|
|
|
|
' return "%s" %% (%s)' % (new_fmt,",".join(param))
|
|
|
|
|
|
|
|
c = compile(s,'<string>','exec')
|
|
|
|
exec(c)
|
|
|
|
|
|
|
|
return fn
|
|
|
|
|
|
|
|
def _format_str_base1(self,first,surname,prefix,suffix,patronymic,
|
|
|
|
title,call,format_str):
|
|
|
|
"""
|
|
|
|
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.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
func = self.__class__.format_funcs.get(format_str)
|
|
|
|
if func == None:
|
|
|
|
func = self._gen_func(format_str)
|
|
|
|
self.__class__.format_funcs[format_str] = func
|
|
|
|
|
|
|
|
s = func(first,surname,prefix,suffix,patronymic,title,call)
|
|
|
|
return ' '.join([ x for x in s.split(" ") if x != ''])
|
2006-07-31 16:38:44 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def sort_string(self,name):
|
|
|
|
return u"%-25s%-30s%s" % (name.surname,name.first_name,name.suffix)
|
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-08-02 02:01:19 +05:30
|
|
|
num = self._is_format_valid(name.sort_as)
|
|
|
|
return self.name_formats[num][_F_FN](name)
|
2006-03-20 05:04:23 +05:30
|
|
|
|
|
|
|
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-08-02 02:01:19 +05:30
|
|
|
num = self._is_format_valid(raw_data[_SORT])
|
|
|
|
return self.name_formats[num][_F_RAWFN](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-27 16:18:16 +05:30
|
|
|
|
2006-08-02 02:01:19 +05:30
|
|
|
num = self._is_format_valid(name.display_as)
|
|
|
|
return self.name_formats[num][_F_FN](name)
|
2006-07-06 23:16:46 +05:30
|
|
|
|
|
|
|
def display_given(self,person):
|
|
|
|
name = person.get_primary_name()
|
2006-07-30 02:26:11 +05:30
|
|
|
return self.format_str(person.get_primary_name(),'%f %y')
|
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-08-02 05:20:47 +05:30
|
|
|
if sv == Name.LNFN or sv == Name.DEF:
|
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)
|
|
|
|
|
2006-08-02 05:20:47 +05:30
|
|
|
def name_grouping_data(self, db, pn):
|
2006-08-03 19:56:43 +05:30
|
|
|
if pn[_GROUP]:
|
|
|
|
return pn[_GROUP]
|
|
|
|
sv = pn[_SORT]
|
2006-08-02 05:20:47 +05:30
|
|
|
if sv == Name.LNFN or sv == Name.DEF:
|
2006-08-03 19:56:43 +05:30
|
|
|
return db.get_name_group_mapping(pn[_SURNAME])
|
2006-08-02 05:20:47 +05:30
|
|
|
elif sv == Name.PTFN:
|
2006-08-03 19:56:43 +05:30
|
|
|
return db.get_name_group_mapping(pn[_PATRONYM])
|
2006-08-02 05:20:47 +05:30
|
|
|
else:
|
2006-08-03 19:56:43 +05:30
|
|
|
return db.get_name_group_mapping(pn[_FIRSTNAME])
|
2006-08-02 05:20:47 +05:30
|
|
|
|
2005-01-01 20:46:44 +05:30
|
|
|
displayer = NameDisplay()
|