本文整理汇总了Python中gramps.gen.lib.PlaceRef.date方法的典型用法代码示例。如果您正苦于以下问题:Python PlaceRef.date方法的具体用法?Python PlaceRef.date怎么用?Python PlaceRef.date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.PlaceRef
的用法示例。
在下文中一共展示了PlaceRef.date方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _parse_place
# 需要导入模块: from gramps.gen.lib import PlaceRef [as 别名]
# 或者: from gramps.gen.lib.PlaceRef import date [as 别名]
def _parse_place(self, line_number, row, col):
"Parse the content of a Place line."
place_id = rd(line_number, row, col, "place")
place_title = rd(line_number, row, col, "title")
place_name = rd(line_number, row, col, "name")
place_type_str = rd(line_number, row, col, "type")
place_latitude = rd(line_number, row, col, "latitude")
place_longitude = rd(line_number, row, col, "longitude")
place_code = rd(line_number, row, col, "code")
place_enclosed_by_id = rd(line_number, row, col, "enclosed_by")
place_date = rd(line_number, row, col, "date")
#########################################################
# if this place already exists, don't create it
place = self.lookup("place", place_id)
if place is None:
# new place
place = self.create_place()
if place_id is not None:
if place_id.startswith("[") and place_id.endswith("]"):
place.gramps_id = self.db.pid2user_format(place_id[1:-1])
self.storeup("place", place_id, place)
if place_title is not None:
place.title = place_title
if place_name is not None:
place.name = PlaceName(value=place_name)
if place_type_str is not None:
place.place_type = self.get_place_type(place_type_str)
if place_latitude is not None:
place.lat = place_latitude
if place_longitude is not None:
place.long = place_longitude
if place_code is not None:
place.code = place_code
if place_enclosed_by_id is not None:
place_enclosed_by = self.lookup("place", place_enclosed_by_id)
if place_enclosed_by is None:
raise Exception("cannot enclose %s in %s as it doesn't exist" % (place.gramps_id, place_enclosed_by_id))
if not place_enclosed_by.handle in place.placeref_list:
placeref = PlaceRef()
placeref.ref = place_enclosed_by.handle
if place_date:
placeref.date = _dp.parse(place_date)
place.placeref_list.append(placeref)
#########################################################
self.db.commit_place(place, self.trans)