本文整理汇总了Python中family.Family.husband方法的典型用法代码示例。如果您正苦于以下问题:Python Family.husband方法的具体用法?Python Family.husband怎么用?Python Family.husband使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类family.Family
的用法示例。
在下文中一共展示了Family.husband方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_lists_from_file
# 需要导入模块: from family import Family [as 别名]
# 或者: from family.Family import husband [as 别名]
def build_lists_from_file(filename):
"""Parses the Ged file and builds the Family and Individual objects.
Returns a touple of dictionaries, in the for ({},{}), where the first is
the list of families (indexed by family ID) and the second is the list of
individuals (indexed by the individual ID).
"""
load_valid_tags()
lines = open(filename, "r").readlines()
individuals = {}
families = {}
def generateUntilLevelZero(seq):
"""Creates a list of GedLine objects until the given sequence has a
GedLine with level zero. This is useful for retrieving a sequence of
lines of a single object (family of individual)
"""
for e in seq:
line = GedLine(e)
if line.level() != 0:
yield line
else:
break
index = 0 # line index
while index < len(lines)-1:
line = GedLine(lines[index])
if line.level() == 0 and line.content() == "INDI":
# Create Individual
ind = Individual(line.tag()) # Tag is the ID
individual_lines = generateUntilLevelZero(lines[index+1:])
for l in individual_lines:
if l.tag() == "NAME":
ind.name = l.content()
elif l.tag() == "GIVN":
ind.givenname = l.content()
elif l.tag() == "SURN":
ind.surname = l.content()
elif l.tag() == "SEX":
ind.sex = l.content()
elif l.tag() == "NOTE":
ind.note = l.content()
elif l.tag() == "BIRT":
ind.setbirthday(individual_lines.next().content())
elif l.tag() == "DEAT":
ind.setdeathday(individual_lines.next().content())
individuals[ind.id] = ind
elif line.level() == 0 and line.content() == "FAM":
# Create Family
fam = Family(line.tag()) # Tag is the ID
family_lines = generateUntilLevelZero(lines[index+1:])
for l in family_lines:
if l.tag() == "HUSB":
fam.husband = l.content()
elif l.tag() == "WIFE":
fam.wife = l.content()
elif l.tag() == "CHIL":
fam.children.append(l.content())
elif l.tag() == "MARR":
fam.setmarrydate(family_lines.next().content())
families[fam.id] = fam
index += 1
return families, individuals