當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。