本文整理汇总了Python中gramps.gen.lib.Event.get_handle方法的典型用法代码示例。如果您正苦于以下问题:Python Event.get_handle方法的具体用法?Python Event.get_handle怎么用?Python Event.get_handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Event
的用法示例。
在下文中一共展示了Event.get_handle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_occupation
# 需要导入模块: from gramps.gen.lib import Event [as 别名]
# 或者: from gramps.gen.lib.Event import get_handle [as 别名]
def add_occupation(self, fields, data):
"""Read the ROLE property of a VCard."""
occupation = data.strip()
if occupation:
event = Event()
event.set_type(EventType(EventType.OCCUPATION))
event.set_description(self.unesc(occupation))
self.database.add_event(event, self.trans)
event_ref = EventRef()
event_ref.set_reference_handle(event.get_handle())
self.person.add_event_ref(event_ref)
示例2: add_birthday
# 需要导入模块: from gramps.gen.lib import Event [as 别名]
# 或者: from gramps.gen.lib.Event import get_handle [as 别名]
def add_birthday(self, fields, data):
"""Read the BDAY property of a VCard."""
date_str = data.strip()
date_match = VCardParser.DATE_RE.match(date_str)
date = Date()
if date_match:
if date_match.group(2):
date_str = "%s-%s-%s" % (date_match.group(2),
date_match.group(3), date_match.group(4))
else:
date_str = date_match.group(1)
y, m, d = [int(x, 10) for x in date_str.split('-')]
try:
date.set(value=(d, m, y, False))
except DateError:
# TRANSLATORS: leave the {vcard_snippet} untranslated
# in the format string, but you may re-order it if needed.
self.__add_msg(_(
"Invalid date in BDAY {vcard_snippet}, "
"preserving date as text."
).format(vcard_snippet=data), self.line_num - 1)
date.set(modifier=Date.MOD_TEXTONLY, text=data)
else:
if date_str:
# TRANSLATORS: leave the {vcard_snippet} untranslated.
self.__add_msg(_(
"Date {vcard_snippet} not in appropriate format "
"yyyy-mm-dd, preserving date as text."
).format(vcard_snippet=date_str), self.line_num - 1)
date.set(modifier=Date.MOD_TEXTONLY, text=date_str)
else: # silently ignore an empty BDAY record
return
event = Event()
event.set_type(EventType(EventType.BIRTH))
event.set_date_object(date)
self.database.add_event(event, self.trans)
event_ref = EventRef()
event_ref.set_reference_handle(event.get_handle())
self.person.set_birth_ref(event_ref)