本文整理汇总了Python中gramps.gen.lib.EventRef.ref方法的典型用法代码示例。如果您正苦于以下问题:Python EventRef.ref方法的具体用法?Python EventRef.ref怎么用?Python EventRef.ref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.EventRef
的用法示例。
在下文中一共展示了EventRef.ref方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import ref [as 别名]
def save(self, trans):
"""
Save the census details to the database.
"""
# Update people on the census
all_people = []
for order, row in enumerate(self.model):
all_people.append(row[0])
person = self.db.get_person_from_handle(row[0])
event_ref = self.get_census_event_ref(person)
if event_ref is None:
# Add new link to census
event_ref = EventRef()
event_ref.ref = self.event.get_handle()
event_ref.set_role(EventRoleType.PRIMARY)
person.add_event_ref(event_ref)
# Write attributes
attrs = event_ref.get_attribute_list()
set_attribute(event_ref, attrs, ORDER_ATTR, str(order + 1))
for offset, name in enumerate(self.columns):
value = row[offset + 1]
if name == _('Name'):
if value != name_displayer.display(person):
set_attribute(event_ref, attrs, name, value)
else:
set_attribute(event_ref, attrs, name, value)
self.db.commit_person(person, trans)
# Remove links to people no longer on census
for handle in (set(self.initial_people) - set(all_people)):
person = self.db.get_person_from_handle(handle)
ref_list = [event_ref for event_ref in person.get_event_ref_list()
if event_ref.ref != self.event.handle]
person.set_event_ref_list(ref_list)
self.db.commit_person(person, trans)
示例2: get_event_ref
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import ref [as 别名]
def get_event_ref(event, obj, role):
"""
Return the event reference for a given person or family that points
to the event being edited.
"""
for event_ref in obj.get_event_ref_list():
if (event_ref.ref == event.get_handle() and
event_ref.get_role() == role):
return event_ref
# Add new event reference
event_ref = EventRef()
event_ref.ref = event.get_handle()
event_ref.set_role(role)
obj.add_event_ref(event_ref)
return event_ref