本文整理汇总了Python中gramps.gen.lib.Event.set_place_handle方法的典型用法代码示例。如果您正苦于以下问题:Python Event.set_place_handle方法的具体用法?Python Event.set_place_handle怎么用?Python Event.set_place_handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Event
的用法示例。
在下文中一共展示了Event.set_place_handle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_event
# 需要导入模块: from gramps.gen.lib import Event [as 别名]
# 或者: from gramps.gen.lib.Event import set_place_handle [as 别名]
def create_event(self,type,desc=None,date=None,place=None,source=None):
event = Event()
if type:
event.set_type(EventType(type))
if desc:
event.set_description(desc)
if date:
event.set_date_object(date)
if place:
event.set_place_handle(place.get_handle())
if source:
event.add_citation(source.get_handle())
self.db.add_event(event,self.trans)
self.db.commit_event(event,self.trans)
return event
示例2: get_or_create_event
# 需要导入模块: from gramps.gen.lib import Event [as 别名]
# 或者: from gramps.gen.lib.Event import set_place_handle [as 别名]
def get_or_create_event(self, object_, type_, date=None, place=None,
source=None):
""" Add or find a type event on object """
# first, see if it exists
LOG.debug("get_or_create_event")
ref_list = object_.get_event_ref_list()
LOG.debug("refs: %s", ref_list)
# look for a match, and possible correction
for ref in ref_list:
event = self.db.get_event_from_handle(ref.ref)
LOG.debug(" compare event type %s == %s", int(event.get_type()),
type_)
if int(event.get_type()) == type_:
# Match! Let's update
if date:
event.set_date_object(date)
if place:
event.set_place_handle(place.get_handle())
if source:
self.find_and_set_citation(event, source)
self.db.commit_event(event, self.trans)
LOG.debug(" returning existing event")
return (0, event)
# else create it:
LOG.debug(" creating event")
event = Event()
if type_:
event.set_type(EventType(type_))
if date:
event.set_date_object(date)
if place:
event.set_place_handle(place.get_handle())
if source:
self.find_and_set_citation(event, source)
self.db.add_event(event, self.trans)
return (1, event)