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


Python Individual.setbirthday方法代码示例

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


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

示例1: build_lists_from_file

# 需要导入模块: from individual import Individual [as 别名]
# 或者: from individual.Individual import setbirthday [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
开发者ID:hongyix,项目名称:GradSSW555,代码行数:69,代码来源:ged_parser.py


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