当前位置: 首页>>代码示例>>Python>>正文


Python Family.add_tag方法代码示例

本文整理汇总了Python中gramps.gen.lib.Family.add_tag方法的典型用法代码示例。如果您正苦于以下问题:Python Family.add_tag方法的具体用法?Python Family.add_tag怎么用?Python Family.add_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gramps.gen.lib.Family的用法示例。


在下文中一共展示了Family.add_tag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_or_create_family

# 需要导入模块: from gramps.gen.lib import Family [as 别名]
# 或者: from gramps.gen.lib.Family import add_tag [as 别名]
 def get_or_create_family(self, family_ref, husband, wife):
     "Return the family object for the give family ID."
     # if a gramps_id and exists:
     LOG.debug("get_or_create_family")
     if family_ref.startswith("[") and family_ref.endswith("]"):
         id_ = self.db.fid2user_format(family_ref[1:-1])
         family = self.db.get_family_from_gramps_id(id_)
         if family:
             # don't delete, only add
             fam_husband_handle = family.get_father_handle()
             fam_wife_handle = family.get_mother_handle()
             if husband:
                 if husband.get_handle() != fam_husband_handle:
                     # this husband is not the same old one! Add him!
                     family.set_father_handle(husband.get_handle())
             if wife:
                 if wife.get_handle() != fam_wife_handle:
                     # this wife is not the same old one! Add her!
                     family.set_mother_handle(wife.get_handle())
             LOG.debug("   returning existing family")
             return family
     # if not, create one:
     family = Family()
     # was marked with a gramps_id, but didn't exist, so we'll use it:
     if family_ref.startswith("[") and family_ref.endswith("]"):
         id_ = self.db.fid2user_format(family_ref[1:-1])
         family.set_gramps_id(id_)
     # add it:
     family.set_handle(create_id())
     if self.default_tag:
         family.add_tag(self.default_tag.handle)
     if husband:
         family.set_father_handle(husband.get_handle())
         husband.add_family_handle(family.get_handle())
     if wife:
         family.set_mother_handle(wife.get_handle())
         wife.add_family_handle(family.get_handle())
     if husband and wife:
         family.set_relationship(FamilyRelType.MARRIED)
     self.db.add_family(family, self.trans)
     if husband:
         self.db.commit_person(husband, self.trans)
     if wife:
         self.db.commit_person(wife, self.trans)
     self.fam_count += 1
     return family
开发者ID:tecknicaltom,项目名称:gramps,代码行数:48,代码来源:importcsv.py


注:本文中的gramps.gen.lib.Family.add_tag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。