本文整理汇总了Python中gramps.gen.lib.Family.set_mother_handle方法的典型用法代码示例。如果您正苦于以下问题:Python Family.set_mother_handle方法的具体用法?Python Family.set_mother_handle怎么用?Python Family.set_mother_handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Family
的用法示例。
在下文中一共展示了Family.set_mother_handle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __add_family
# 需要导入模块: from gramps.gen.lib import Family [as 别名]
# 或者: from gramps.gen.lib.Family import set_mother_handle [as 别名]
def __add_family(self, father, mother, trans):
family = Family()
family.set_father_handle(father.handle)
family.set_mother_handle(mother.handle)
fam_handle = self.db.add_family(family, trans)
father.add_family_handle(fam_handle)
mother.add_family_handle(fam_handle)
self.db.commit_person(father, trans)
self.db.commit_person(mother, trans)
return family
示例2: get_or_create_family
# 需要导入模块: from gramps.gen.lib import Family [as 别名]
# 或者: from gramps.gen.lib.Family import set_mother_handle [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
示例3: __init__
# 需要导入模块: from gramps.gen.lib import Family [as 别名]
# 或者: from gramps.gen.lib.Family import set_mother_handle [as 别名]
#.........这里部分代码省略.........
).format(number_of=t)
self.db.enable_signals()
self.db.request_rebuild()
LOG.debug(msg)
LOG.debug("Families: %d" % len(self.fkeys))
LOG.debug("Individuals: %d" % len(self.ikeys))
return None
def read_family_line(self,line,fields):
self.current_husband_handle = None
self.current_child_birthplace_handle = None
self.current_child_source_handle = None
self.current_family = Family()
self.db.add_family(self.current_family,self.trans)
#self.db.commit_family(self.current_family,self.trans)
self.fkeys.append(self.current_family.get_handle())
idx = 1;
LOG.debug("\nHusband:")
(idx, husband) = self.parse_person(fields,idx,Person.MALE,None)
if husband:
self.current_husband_handle = husband.get_handle()
self.current_family.set_father_handle(husband.get_handle())
self.db.commit_family(self.current_family,self.trans)
husband.add_family_handle(self.current_family.get_handle())
self.db.commit_person(husband,self.trans)
LOG.debug("Marriage:")
idx = self.parse_marriage(fields,idx)
LOG.debug("Wife:")
(idx,wife) = self.parse_person(fields,idx,Person.FEMALE,None)
if wife:
self.current_family.set_mother_handle(wife.get_handle())
self.db.commit_family(self.current_family,self.trans)
wife.add_family_handle(self.current_family.get_handle())
self.db.commit_person(wife,self.trans)
return None
def read_relationship_person(self,line,fields):
LOG.debug("\Relationships:")
(idx,person) = self.parse_person(fields,1,Person.UNKNOWN,None)
if person:
self.current_relationship_person_handle = person.get_handle()
def read_relation_lines(self):
if not self.current_relationship_person_handle:
LOG.warning("Unknown person for relationship in line %d!" % self.lineno)
return None
rel_person = self.db.get_person_from_handle(self.current_relationship_person_handle)
while 1:
line = self.get_next_line()
if line is None or line == "end":
break
if line == "":
continue
# match relationship type and related person
line_re = re.compile("^- ([^:]+): (.*)$")
matches = line_re.match(line)
if matches:
#split related person into fields
fields = matches.groups()[1].split(" ")
if fields:
(idx,asso_p) = self.parse_person(fields,0,Person.UNKNOWN,None)
pref = PersonRef()