本文整理汇总了Python中gramps.gen.lib.Name.set_surname_list方法的典型用法代码示例。如果您正苦于以下问题:Python Name.set_surname_list方法的具体用法?Python Name.set_surname_list怎么用?Python Name.set_surname_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Name
的用法示例。
在下文中一共展示了Name.set_surname_list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: latin_american_child
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_surname_list [as 别名]
def latin_american_child(self, parent):
"""
If SURNAME_GUESSING is latin american, then find a child
and return their name for the father or mother.
parent = "mother" | "father"
"""
name = Name()
#the editor requires a surname
name.add_surname(Surname())
name.set_primary_surname(0)
# for each child, find one with a last name
for ref in self.obj.get_child_ref_list():
child = self.db.get_person_from_handle(ref.ref)
if child:
pname = child.get_primary_name()
preset_name(child, name)
if len(name.get_surname_list()) < 2:
return name
else:
#return first for the father, and last for the mother
if parent == 'father':
name.set_surname_list(name.get_surname_list()[0])
return name
else:
name.set_surname_list(name.get_surname_list()[-1])
return name
return name
示例2: latin_american
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_surname_list [as 别名]
def latin_american(self):
"""
Child inherits name from father and mother
"""
name = Name()
#the editor requires a surname
name.add_surname(Surname())
name.set_primary_surname(0)
if self.family:
father_handle = self.family.get_father_handle()
mother_handle = self.family.get_mother_handle()
father = self.dbstate.db.get_person_from_handle(father_handle)
mother = self.dbstate.db.get_person_from_handle(mother_handle)
if not father and not mother:
return name
if not father:
preset_name(mother, name)
return name
if not mother:
preset_name(father, name)
return name
#we take first surname, and keep that
mothername = Name()
preset_name(mother, mothername)
preset_name(father, name)
mothersurname = mothername.get_surname_list()[0]
mothersurname.set_primary(False)
name.set_surname_list([name.get_surname_list()[0], mothersurname])
return name
else:
return name
示例3: get_name
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_surname_list [as 别名]
def get_name(self, person, maiden_name = None):
""" Return person's name, unless maiden_name given,
unless married_name listed.
"""
# Get all of a person's names:
primary_name = person.get_primary_name()
married_name = None
names = [primary_name] + person.get_alternate_names()
for name in names:
if int(name.get_type()) == NameType.MARRIED:
married_name = name
break # use first
# Now, decide which to use:
if maiden_name is not None:
if married_name is not None:
name = Name(married_name)
else:
name = Name(primary_name)
surname = Surname()
surname.set_surname(maiden_name)
name.set_surname_list([surname])
else:
name = Name(primary_name)
name.set_display_as(self.name_format)
return _nd.display_name(name)