本文整理汇总了Python中gramps.gen.lib.Name.set_suffix方法的典型用法代码示例。如果您正苦于以下问题:Python Name.set_suffix方法的具体用法?Python Name.set_suffix怎么用?Python Name.set_suffix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Name
的用法示例。
在下文中一共展示了Name.set_suffix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_name
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_suffix [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
示例2: _parse_person
# 需要导入模块: from gramps.gen.lib import Name [as 别名]
# 或者: from gramps.gen.lib.Name import set_suffix [as 别名]
def _parse_person(self, line_number, row, col):
"Parse the content of a Person line."
surname = rd(line_number, row, col, "surname")
firstname = rd(line_number, row, col, "firstname", "")
callname = rd(line_number, row, col, "callname")
title = rd(line_number, row, col, "title")
prefix = rd(line_number, row, col, "prefix")
suffix = rd(line_number, row, col, "suffix")
gender = rd(line_number, row, col, "gender")
source = rd(line_number, row, col, "source")
note = rd(line_number, row, col, "note")
birthplace = rd(line_number, row, col, "birthplace")
birthplace_id = rd(line_number, row, col, "birthplace_id")
birthdate = rd(line_number, row, col, "birthdate")
birthsource = rd(line_number, row, col, "birthsource")
baptismplace = rd(line_number, row, col, "baptismplace")
baptismplace_id = rd(line_number, row, col, "baptismplace_id")
baptismdate = rd(line_number, row, col, "baptismdate")
baptismsource = rd(line_number, row, col, "baptismsource")
burialplace = rd(line_number, row, col, "burialplace")
burialplace_id = rd(line_number, row, col, "burialplace_id")
burialdate = rd(line_number, row, col, "burialdate")
burialsource = rd(line_number, row, col, "burialsource")
deathplace = rd(line_number, row, col, "deathplace")
deathplace_id = rd(line_number, row, col, "deathplace_id")
deathdate = rd(line_number, row, col, "deathdate")
deathsource = rd(line_number, row, col, "deathsource")
deathcause = rd(line_number, row, col, "deathcause")
grampsid = rd(line_number, row, col, "grampsid")
person_ref = rd(line_number, row, col, "person")
#########################################################
# if this person already exists, don't create them
person = self.lookup("person", person_ref)
if person is None:
if surname is None:
LOG.warn("empty surname for new person on line %d" %
line_number)
surname = ""
# new person
person = self.create_person()
name = Name()
name.set_type(NameType(NameType.BIRTH))
name.set_first_name(firstname)
surname_obj = Surname()
surname_obj.set_surname(surname)
name.add_surname(surname_obj)
person.set_primary_name(name)
else:
name = person.get_primary_name()
#########################################################
if person_ref is not None:
self.storeup("person", person_ref, person)
# replace
if surname is not None:
name.get_primary_surname().set_surname(surname)
if firstname is not None:
name.set_first_name(firstname)
if callname is not None:
name.set_call_name(callname)
if title is not None:
name.set_title(title)
if prefix is not None:
name.get_primary_surname().set_prefix(prefix)
name.group_as = '' # HELP? what should I do here?
if suffix is not None:
name.set_suffix(suffix)
if note is not None:
# append notes, if previous notes
previous_notes_list = person.get_note_list()
updated_note = False
for note_handle in previous_notes_list:
previous_note = self.db.get_note_from_handle(note_handle)
if previous_note.type == NoteType.PERSON:
previous_text = previous_note.get()
if note not in previous_text:
note = previous_text + "\n" + note
previous_note.set(note)
self.db.commit_note(previous_note, self.trans)
updated_note = True
break
if not updated_note:
# add new note here
new_note = Note()
new_note.handle = create_id()
new_note.type.set(NoteType.PERSON)
new_note.set(note)
if self.default_tag:
new_note.add_tag(self.default_tag.handle)
self.db.add_note(new_note, self.trans)
person.add_note(new_note.handle)
if grampsid is not None:
person.gramps_id = grampsid
elif person_ref is not None:
if person_ref.startswith("[") and person_ref.endswith("]"):
person.gramps_id = self.db.id2user_format(person_ref[1:-1])
if (person.get_gender() == Person.UNKNOWN and
gender is not None):
gender = gender.lower()
if gender == gender_map[Person.MALE].lower():
gender = Person.MALE
#.........这里部分代码省略.........