示例#1
0
    def test_full_path(self):
        '''Integration test for parser->objects->validation'''
        buff = StringIO('''0 @I1@ INDI
1 NAME CrankyFrank /Coffin/
1 SEX M
1 BIRT
2 DATE 6 OCT 1986
1 FAMS @F1@
0 @I2@ INDI
1 NAME SomethingSally /Coffin/
1 SEX F
1 BIRT
2 DATE 30 DEC 1985
1 FAMS @F1@
0 @F1@ FAM
1 MARR
2 DATE 1 JAN 1986
1 DIV
2 DATE 2 JAN 1986
1 CHIL @I1@
1 CHIL @I2@
''')
        (ind, fam, unused_warns) = parse_file(buff)
        warnings = collect_validation_warnings(ind, fam)
        count_of_us08_errors = 0
        for warn in warnings:
            if warn.story == "US08": count_of_us08_errors += 1
        self.assertEqual(count_of_us08_errors, 2)
示例#2
0
    def test_full_path(self):
        """Integration test for full parser->objects->validation data path."""
        buff = StringIO("""0 @I1@ INDI
1 NAME CrankyFrank /Coffin/
1 SEX M
1 BIRT
2 DATE 2 JAN 2940
1 FAMS @F1@
0 @I2@ INDI
1 NAME MarvelousMay /Coffin/
1 SEX F
1 BIRT
2 DATE 15 MAY 2941
1 FAMS @F1@
0 @F1@ FAM
1 HUSB @I1@
1 WIFE @I2@
1 MARR
2 DATE 15 JUL 2972
1 DIV
2 DATE 15 JUL 2973""")
        (ind,  fam,  unused_warns) = parse_file(buff)
        warnings = collect_validation_warnings(ind,  fam)
        count_of_us01_errors = 0
        for warn in warnings:
            if warn.story == "US01": count_of_us01_errors += 1
        self.assertEqual(count_of_us01_errors,  4)
示例#3
0
    def test_full_path(self):
        '''Integration test for parser->objects->validation'''
        buff = StringIO('''0 @I1@ INDI
1 NAME CrankyFrank /Coffin/
1 DEAT
2 DATE 1 SEP 1995
0 @I2@ INDI
1 NAME SomethingSally /Coffin/
1 DEAT
2 DATE 1 JAN 1995
0 @I3@ INDI
1 NAME Maddye /Simmons/
1 BIRT
2 DATE 2 SEP 1995
0 @I4@ INDI
1 NAME Derek /Simmons/
1 BIRT
2 DATE 1 NOV 1995
0 @F1@ FAM
1 HUSB @I2@
1 WIFE @I1@
1 CHIL @I3@
1 CHIL @I4@''')
        (ind, fam, unused_warns) = parse_file(buff)
        warnings = collect_validation_warnings(ind, fam)
        count_of_us09_errors = 0
        for warn in warnings:
            if warn.story == "US09": count_of_us09_errors += 1
        self.assertEqual(count_of_us09_errors, 3)
示例#4
0
    def test_everything_fine(self):
        """Test that an okay GEDCOM file is reported with no warnings."""
        buff = StringIO("""0 @I1@ INDI
1 FAMC @F1@
0 @I2@ INDI
1 FAMC @F1@
0 @I3@ INDI
1 FAMS @F1@
0 @I4@ INDI
1 FAMS @F1@
0 @F1@ FAM
1 HUSB @I3@
1 WIFE @I4@
1 CHIL @I1@
1 CHIL @I2@""")
        (ind, fam, warns) = parse_file(buff)
        validation_warns = collect_validation_warnings(ind, fam)
        us26_warns = [x for x in warns + validation_warns if x.story == "US26"]
        self.assertTrue(len(us26_warns) == 0)

        self.assertTrue(fam['@F1@'] in ind['@I1@'].child_families)
        self.assertTrue(fam['@F1@'] in ind['@I2@'].child_families)
        self.assertTrue(fam['@F1@'] in ind['@I3@'].spouse_families)
        self.assertTrue(fam['@F1@'] in ind['@I4@'].spouse_families)

        self.assertTrue(ind['@I3@'] == fam['@F1@'].husband)
        self.assertTrue(ind['@I4@'] == fam['@F1@'].wife)
        self.assertTrue(ind['@I1@'] in fam['@F1@'].children_list)
        self.assertTrue(ind['@I2@'] in fam['@F1@'].children_list)
示例#5
0
    def test_full_path(self):
        '''Integration test for parser->objects->validation'''
        buff = StringIO('''0 @I1@ INDI
1 NAME CrankyFrank /Coffin/
1 SEX M
1 BIRT
2 DATE 3 MAR 1986
1 DEAT
2 DATE 3 MAR 1986
1 FAMS @F1@
0 @I2@ INDI
1 NAME SomethingSally /Coffin/
1 SEX F
1 BIRT
2 DATE 1 MAR 1986
1 DEAT
2 DATE 1 MAR 1986
1 FAMS @F1@
0 @F1@ FAM
1 HUSB @I1@
1 WIFE @I2@
1 MARR
2 DATE 2 MAR 1986''')
        (ind, fam, unused_warns) = parse_file(buff)
        warnings = collect_validation_warnings(ind, fam)
        count_of_us05_errors = 0
        for warn in warnings:
            if warn.story == "US05": count_of_us05_errors += 1
        self.assertEqual(count_of_us05_errors, 1)
示例#6
0
    def test_full_path(self):
        '''Integration test for parser->objects->validation'''
        buff = StringIO('''0 @F1@ FAM
1 MARR
2 DATE 3 MAR 1986
1 DIV
2 DATE 3 MAR 1986
0 @F2@ FAM
1 MARR
2 DATE 3 MAR 1986
1 DIV
2 DATE 2 MAR 1986''')
        (ind, fam, unused_warns) = parse_file(buff)
        warnings = collect_validation_warnings(ind, fam)
        count_of_us04_errors = 0
        for warn in warnings:
            if warn.story == "US04": count_of_us04_errors += 1
        self.assertEqual(count_of_us04_errors, 1)
示例#7
0
    if len(warnings) > 0:
        print('Warnings')
        pt = PrettyTable(field_names=['Code', 'Message'])
        for warn in warnings:
            pt.add_row([warn.story, warn.message])
        pt.sortby = "Code"
        print(pt)
    else:
        print()
        print("GEDCOM database is sane.")


if __name__ == "__main__":
    '''Begin by opening the file '''
    with open(sys.argv[1], 'r') as f:
        (indi, fam, parse_warns) = parse_file(f)
        warnings = parse_warns + gedcom_validation.collect_validation_warnings(
            indi, fam)

        printIndividuals(indi)
        printFamilies(indi, fam)
        US28_SiblingsByAge_pt(indi, fam)
        US29_ListOfDeceased(indi)
        US30_ListLivingMarried_pt(indi, fam)
        US31_Listofliving(indi)
        US32_Listofmultiplebirths(indi)
        US33_ListOrphans_pt(indi, fam)
        US35_Listrecentbirths(indi)
        US36_Listrecentdeaths(indi)
        printWarnings(warnings)