本文整理汇总了Python中gramps.gen.lib.Name.get_surname_list方法的典型用法代码示例。如果您正苦于以下问题:Python Name.get_surname_list方法的具体用法?Python Name.get_surname_list怎么用?Python Name.get_surname_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Name
的用法示例。
在下文中一共展示了Name.get_surname_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: latin_american
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import get_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
示例2: latin_american_child
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import get_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