本文整理汇总了Python中gramps.gen.lib.Name.set_primary_surname方法的典型用法代码示例。如果您正苦于以下问题:Python Name.set_primary_surname方法的具体用法?Python Name.set_primary_surname怎么用?Python Name.set_primary_surname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Name
的用法示例。
在下文中一共展示了Name.set_primary_surname方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: latin_american_child
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_primary_surname [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_primary_surname [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: add
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_primary_surname [as 别名]
def add(self, *obj):
person = Person()
# attempt to get the current surname
(model, pathlist) = self.selection.get_selected_rows()
name = Name()
#the editor requires a surname
name.add_surname(Surname())
name.set_primary_surname(0)
basepers = None
if len(pathlist) == 1:
path = pathlist[0]
pathids = path.get_indices()
if len(pathids) == 1:
path = Gtk.TreePath((pathids[0], 0))
iter_ = model.get_iter(path)
handle = model.get_handle_from_iter(iter_)
basepers = self.dbstate.db.get_person_from_handle(handle)
if basepers:
preset_name(basepers, name)
person.set_primary_name(name)
try:
EditPerson(self.dbstate, self.uistate, [], person)
except WindowActiveError:
pass
示例4: no_name
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_primary_surname [as 别名]
def no_name(self):
"""
Default surname guess.
"""
name = Name()
#the editor requires a surname
name.add_surname(Surname())
name.set_primary_surname(0)
return name
示例5: add_button_clicked
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_primary_surname [as 别名]
def add_button_clicked(self, obj):
name = Name()
#the editor requires a surname
name.add_surname(Surname())
name.set_primary_surname(0)
try:
from .. import EditName
EditName(self.dbstate, self.uistate, self.track,
name, self.add_callback)
except WindowActiveError:
pass
示例6: add_name
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_primary_surname [as 别名]
def add_name(self):
"""
Add the name to the person.
Returns True on success, False on failure.
"""
if not self.name_parts.strip():
self.__add_msg(_("VCard is malformed missing the compulsory N "
"property, so there is no name; skip it."),
self.line_num - 1)
return False
if not self.formatted_name:
self.__add_msg(_("VCard is malformed missing the compulsory FN "
"property, get name from N alone."), self.line_num - 1)
data_fields = self.split_unescaped(self.name_parts, ';')
if len(data_fields) != 5:
self.__add_msg(_("VCard is malformed wrong number of name "
"components."), self.line_num - 1)
name = Name()
name.set_type(NameType(NameType.BIRTH))
if data_fields[0].strip():
# assume first surname is primary
for surname_str in self.split_unescaped(data_fields[0], ','):
surname = Surname()
prefix, sname = splitof_nameprefix(self.unesc(surname_str))
surname.set_surname(sname.strip())
surname.set_prefix(prefix.strip())
name.add_surname(surname)
name.set_primary_surname()
if len(data_fields) > 1 and data_fields[1].strip():
given_name = ' '.join(self.unesc(
self.split_unescaped(data_fields[1], ',')))
else:
given_name = ''
if len(data_fields) > 2 and data_fields[2].strip():
additional_names = ' '.join(self.unesc(
self.split_unescaped(data_fields[2], ',')))
else:
additional_names = ''
self.add_firstname(given_name.strip(), additional_names.strip(), name)
if len(data_fields) > 3 and data_fields[3].strip():
name.set_title(' '.join(self.unesc(
self.split_unescaped(data_fields[3], ','))))
if len(data_fields) > 4 and data_fields[4].strip():
name.set_suffix(' '.join(self.unesc(
self.split_unescaped(data_fields[4], ','))))
self.person.set_primary_name(name)
return True
示例7: north_american
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_primary_surname [as 别名]
def north_american(self):
"""
Child inherits name from father
"""
name = Name()
#the editor requires a surname
name.add_surname(Surname())
name.set_primary_surname(0)
father_handle = self.family.get_father_handle()
if father_handle:
father = self.dbstate.db.get_person_from_handle(father_handle)
preset_name(father, name)
return name
示例8: north_american_child
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_primary_surname [as 别名]
def north_american_child(self):
"""
If SURNAME_GUESSING is north american, then find a child
and return their name for the father.
"""
# for each child, find one with a last name
name = Name()
#the editor requires a surname
name.add_surname(Surname())
name.set_primary_surname(0)
for ref in self.obj.get_child_ref_list():
child = self.db.get_person_from_handle(ref.ref)
if child:
preset_name(child, name)
return name
return name