當前位置: 首頁>>代碼示例>>Python>>正文


Python Family.setdivorceday方法代碼示例

本文整理匯總了Python中family.Family.setdivorceday方法的典型用法代碼示例。如果您正苦於以下問題:Python Family.setdivorceday方法的具體用法?Python Family.setdivorceday怎麽用?Python Family.setdivorceday使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在family.Family的用法示例。


在下文中一共展示了Family.setdivorceday方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: build_lists_from_file

# 需要導入模塊: from family import Family [as 別名]
# 或者: from family.Family import setdivorceday [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(next(individual_lines).content())
                elif l.tag() == "DEAT":
                    ind.setdeathday(next(individual_lines).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())
                elif l.tag() == "DIV":
                    fam.setdivorceday(family_lines.next().content())
            families[fam.id] = fam

        index += 1

    return families, individuals
開發者ID:hoffmannmatheus,項目名稱:GradSSW555,代碼行數:71,代碼來源:ged_parser.py


注:本文中的family.Family.setdivorceday方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。