本文整理汇总了Python中gramps.gen.lib.Person.set_primary_name方法的典型用法代码示例。如果您正苦于以下问题:Python Person.set_primary_name方法的具体用法?Python Person.set_primary_name怎么用?Python Person.set_primary_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Person
的用法示例。
在下文中一共展示了Person.set_primary_name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
# 需要导入模块: from gramps.gen.lib import Person [as 别名]
# 或者: from gramps.gen.lib.Person import set_primary_name [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
示例2: add_mother_clicked
# 需要导入模块: from gramps.gen.lib import Person [as 别名]
# 或者: from gramps.gen.lib.Person import set_primary_name [as 别名]
def add_mother_clicked(self, obj):
person = Person()
person.set_gender(Person.FEMALE)
autoname = config.get("behavior.surname-guessing")
# _("Father's surname"),
# _("None"),
# _("Combination of mother's and father's surname"),
# _("Icelandic style"),
if autoname == 2:
name = self.latin_american_child("mother")
else:
name = self.no_name()
person.set_primary_name(name)
EditPerson(self.dbstate, self.uistate, self.track, person, self.new_mother_added)
示例3: add_button_clicked
# 需要导入模块: from gramps.gen.lib import Person [as 别名]
# 或者: from gramps.gen.lib.Person import set_primary_name [as 别名]
def add_button_clicked(self, obj=None):
person = Person()
autoname = config.get("behavior.surname-guessing")
# _("Father's surname"),
# _("None"),
# _("Combination of mother's and father's surname"),
# _("Icelandic style"),
if autoname == 0:
name = self.north_american()
elif autoname == 2:
name = self.latin_american()
else:
name = self.no_name()
person.set_primary_name(name)
EditPerson(self.dbstate, self.uistate, self.track, person, self.new_child_added)
示例4: run_tool
# 需要导入模块: from gramps.gen.lib import Person [as 别名]
# 或者: from gramps.gen.lib.Person import set_primary_name [as 别名]
#.........这里部分代码省略.........
# dates.append( d)
# except:
# d = Date()
# d.set_as_text("Date.set Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
# dates.append( d)
#self.progress.step()
#d = Date()
#d.set(Date.QUAL_NONE,Date.MOD_NONE,
# Date.CAL_GREGORIAN,(44,7,1789,False),"Text comment")
#dates.append( d)
#d = Date()
#d.set(Date.QUAL_NONE,Date.MOD_NONE,
# Date.CAL_GREGORIAN,(4,77,1789,False),"Text comment")
#dates.append( d)
#d = Date()
#d.set(Date.QUAL_NONE,Date.MOD_SPAN,
# Date.CAL_GREGORIAN,
# (4,7,1789,False,55,8,1876,False),"Text comment")
#dates.append( d)
#d = Date()
#d.set(Date.QUAL_NONE,Date.MOD_SPAN,
# Date.CAL_GREGORIAN,
# (4,7,1789,False,5,88,1876,False),"Text comment")
#dates.append( d)
with DbTxn(_("Date Test Plugin"), self.db, batch=True) as self.trans:
self.db.disable_signals()
self.progress.set_pass(_('Generating dates'),
len(dates))
# create pass and fail tags
pass_handle = self.create_tag(_('Pass'), '#0000FFFF0000')
fail_handle = self.create_tag(_('Fail'), '#FFFF00000000')
# now add them as birth to new persons
i = 1
for dateval in dates:
person = Person()
surname = Surname()
surname.set_surname("DateTest")
name = Name()
name.add_surname(surname)
name.set_first_name("Test %d" % i)
person.set_primary_name(name)
self.db.add_person(person, self.trans)
bevent = Event()
bevent.set_type(EventType.BIRTH)
bevent.set_date_object(dateval)
bevent.set_description("Date Test %d (source)" % i)
bevent_h = self.db.add_event(bevent, self.trans)
bevent_ref = EventRef()
bevent_ref.set_reference_handle(bevent_h)
# for the death event display the date as text and parse it back to a new date
ndate = None
try:
datestr = _dd.display( dateval)
try:
ndate = _dp.parse( datestr)
if not ndate:
ndate = Date()
ndate.set_as_text("DateParser None")
person.add_tag(fail_handle)
else:
person.add_tag(pass_handle)
except:
ndate = Date()
ndate.set_as_text("DateParser Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
person.add_tag(fail_handle)
else:
person.add_tag(pass_handle)
except:
ndate = Date()
ndate.set_as_text("DateDisplay Exception: %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
person.add_tag(fail_handle)
if dateval.get_modifier() != Date.MOD_TEXTONLY \
and ndate.get_modifier() == Date.MOD_TEXTONLY:
# parser was unable to correctly parse the string
ndate.set_as_text( "TEXTONLY: "+ndate.get_text())
person.add_tag(fail_handle)
if dateval.get_modifier() == Date.MOD_TEXTONLY \
and dateval.get_text().count("Traceback") \
and pass_handle in person.get_tag_list():
person.add_tag(fail_handle)
devent = Event()
devent.set_type(EventType.DEATH)
devent.set_date_object(ndate)
devent.set_description("Date Test %d (result)" % i)
devent_h = self.db.add_event(devent, self.trans)
devent_ref = EventRef()
devent_ref.set_reference_handle(devent_h)
person.set_birth_ref(bevent_ref)
person.set_death_ref(devent_ref)
self.db.commit_person(person, self.trans)
i = i + 1
self.progress.step()
self.db.enable_signals()
self.db.request_rebuild()
self.progress.close()
示例5: name_value_split
# 需要导入模块: from gramps.gen.lib import Person [as 别名]
# 或者: from gramps.gen.lib.Person import set_primary_name [as 别名]
#.........这里部分代码省略.........
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
def add_firstname(self, given_name, additional_names, name):
"""
Combine given_name and additional_names and add as firstname to name.
If possible try to add given_name as call name.
"""
default = "%s %s" % (given_name, additional_names)
if self.formatted_name:
if given_name:
if additional_names:
given_name_pos = self.formatted_name.find(given_name)
if given_name_pos != -1:
add_names_pos = self.formatted_name.find(additional_names)
if add_names_pos != -1:
if given_name_pos <= add_names_pos:
firstname = default
# Uncertain if given name is used as callname
else:
firstname = "%s %s" % (additional_names,
given_name)
name.set_call_name(given_name)
else:
idx = fitin(self.formatted_name, additional_names,
given_name)
if idx == -1:
# Additional names is not in formatted name
firstname = default
else: # Given name in middle of additional names
firstname = "%s%s %s" % (additional_names[:idx],
given_name, additional_names[idx:])