本文整理汇总了Python中gramps.gen.lib.Citation.get_gramps_id方法的典型用法代码示例。如果您正苦于以下问题:Python Citation.get_gramps_id方法的具体用法?Python Citation.get_gramps_id怎么用?Python Citation.get_gramps_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Citation
的用法示例。
在下文中一共展示了Citation.get_gramps_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_and_set_citation
# 需要导入模块: from gramps.gen.lib import Citation [as 别名]
# 或者: from gramps.gen.lib.Citation import get_gramps_id [as 别名]
def find_and_set_citation(self, obj, source):
# look for the source in the existing citations for the object
LOG.debug("find_and_set_citation: looking for source: %s",
source.get_gramps_id())
for citation_handle in obj.get_citation_list():
citation = self.db.get_citation_from_handle(citation_handle)
LOG.debug("find_and_set_citation: existing citation: %s",
citation.get_gramps_id())
poss_source = self.db.get_source_from_handle(
citation.get_reference_handle())
LOG.debug(" compare source %s == %s", source.get_gramps_id(),
poss_source.get_gramps_id())
if poss_source.get_handle() == source.get_handle():
# The source is already cited
LOG.debug(" source already cited")
return
# we couldn't find an appropriate citation, so we have to create one.
citation = Citation()
LOG.debug(" creating citation")
citation.set_reference_handle(source.get_handle())
self.db.add_citation(citation, self.trans)
LOG.debug(" created citation, citation %s %s" %
(citation, citation.get_gramps_id()))
obj.add_citation(citation.get_handle())