Exemplo n.º 1
0
def userStory24(file):

    indiDict, famDict = processGEDCOM(file)
    famList = []
    resultList = list()

    for index in famDict:
        famList += [index]

    count = 0
    while count <= len(famList)-2:
        tempFam1 = famDict[famList[count]]
        tempFam1_Husb = tempFam1.Get_husbandName()
        tempFam1_Wife = tempFam1.Get_wifeName()
        temp = count + 1
        while temp <= len(famList)-1:
            tempFam2 = famDict[famList[temp]]
            tempFam2_Husb = tempFam2.Get_husbandName()
            tempFam2_Wife = tempFam2.Get_wifeName()
            if tempFam1_Husb == tempFam2_Husb and tempFam1_Wife == tempFam2_Wife:
                fam_1 = tempFam1.Get_ID()
                fam_2 = tempFam2.Get_ID()
                resultList.append(f"ERROR: FAMILY: US24: Two families [{fam_1}, {fam_2}] have duplicate spouses [{tempFam1_Husb}, {tempFam2_Wife}].")
            temp += 1
        count += 1

    resultList.sort()
    return resultList
Exemplo n.º 2
0
def userStory23(file):

    indiDict, famDict = processGEDCOM(file)
    indiList = []
    resultList = list()

    for index in indiDict:
        indiList += [index]

    count = 0
    while count <= len(indiList)-2:
        tempIndi1 = indiDict[indiList[count]]

        temp = count + 1
        while temp <= len(indiList)-1:
            tempIndi2 = indiDict[indiList[temp]]
            if tempIndi1.Get_name() == tempIndi2.Get_name() and tempIndi1.Get_birthday() == tempIndi2.Get_birthday():
                indi_1 = tempIndi1.Get_ID()
                indi_2 = tempIndi2.Get_ID()
                indiBirth_2 = tempIndi2.Get_birthday()
                indiName_2 = tempIndi1.Get_name()
                resultList.append(f"ERROR: INDIVIDUAL: US23: Two individuals have duplicate names and birthdays [{tempIndi1.Get_name()}, {tempIndi2.Get_birthday()}].")
            temp += 1
        count += 1

    resultList.sort()
    
    return resultList
Exemplo n.º 3
0
def userStory10(file):

    individuals, families = processGEDCOM(file)
    resultsList = list()

    for family_id, family in families.items():

        if family.Get_married() != "NA":

            husband = family.Get_husbandID()
            wife = family.Get_wifeID()

            husband_date = individuals[husband].Get_birthday()
            wife_date = individuals[wife].Get_birthday()

            family_marriage_date = family.Get_married()
            if float(relativedelta(family_marriage_date,
                                   husband_date).years) < float(14):
                resultsList.append(
                    f"ERROR: FAMILY: US10: {family_id}: Husband ({husband}) birth date {husband_date} not at least 14 years prior to marriage date {family_marriage_date}"
                )
            if float(relativedelta(family_marriage_date,
                                   wife_date).years) < float(14):
                resultsList.append(
                    f"ERROR: FAMILY: US10: {family_id}: Wife ({wife}) birth date {wife_date} not at least 14 years prior to marriage date {family_marriage_date}"
                )

    return resultsList
Exemplo n.º 4
0
def userStory02(file):

    indiDict, famDict = processGEDCOM(file)

    resultList = list()

    for index in famDict:
        husbandID = famDict[index].Get_husbandID()
        wifeID = famDict[index].Get_wifeID()

        if wifeID != "NA":
            husBirthDate = indiDict[husbandID].Get_birthday()
        else:
            husBirthDate = "NA"

        if wifeID != "NA":
            wifeBirthDate = indiDict[wifeID].Get_birthday()
        else:
            wifeBirthDate = "NA"

        marriageDate = famDict[index].Get_married()

        if marriageDate != 'NA':
            if husBirthDate != 'NA':
                if husBirthDate > marriageDate:
                    result_1_str = f"ERROR: FAMILY: US02: : {husbandID}: Husband's birth date {husBirthDate} is after marriage date {marriageDate}"
                    resultList.append(result_1_str)

            if wifeBirthDate != 'NA':
                if wifeBirthDate > marriageDate:
                    result_2_str = f"ERROR: FAMILY: US02: : {wifeID}: Wife's birth date {wifeBirthDate} is after marriage date {marriageDate}"
                    resultList.append(result_2_str)

    return resultList
Exemplo n.º 5
0
def userStory09(file):

    individuals, families = processGEDCOM(file)
    resultsList = list()

    for family_id, family in families.items():

        if family.Get_married() != "NA":

            husband = family.Get_husbandID()
            wife = family.Get_wifeID()

            husband_date = individuals[husband].Get_death()
            wife_date = individuals[wife].Get_death()

            children = family.Get_children()

            if len(children) > 0 and (wife_date != "NA"
                                      and husband_date != "NA"):
                for child in children:
                    child_birthdate = individuals[child].Get_birthday()
                    if husband_date < child_birthdate:
                        resultsList.append(
                            f"ERROR: FAMILY: US09: {family_id}: Husband ({husband}) died {husband_date} before child's ({child}) birth {child_birthdate}"
                        )
                    if wife_date < child_birthdate:
                        resultsList.append(
                            f"ERROR: FAMILY: US09: {family_id}: Wife ({wife}) died {wife_date} before child's ({child}) birth {child_birthdate}"
                        )

    return resultsList
Exemplo n.º 6
0
def userStory08(file):
    i_dict, f_dict = processGEDCOM(file)
    errors = list()

    for key in f_dict:
        family = f_dict[key]

        if (family.Get_ID() != 'NA'):
            children = family.Get_children()

            if children != 'NA':
                child_list = [
                    i for i in i_dict.values() if i.Get_ID() in children
                ]

                for child in child_list:
                    child_birth = child.Get_birthday()

                    if (family.Get_divorced() != 'NA'):
                        divorce = family.Get_divorced()
                        divorce_birth_limit = datetime.timedelta(
                            seconds=(9 * 4 * 7 * 24 * 60 * 60))

                        if ((child_birth - divorce) > divorce_birth_limit):
                            result_1_str = f"ERROR: FAMILY: US08: Child's birthday occurs more than 9 months after parents' divorce. ID: {family.Get_ID()} Child's birthday: {child_birth} Parents' divorce date: {divorce}"
                            errors.append(result_1_str)
                    elif (family.Get_married() != 'NA'):
                        marriage = family.Get_married()

                        if (child_birth < marriage):
                            result_2_str = f"ERROR: FAMILY: US08: Child's birthday occurs before parents' marriage. ID: {family.Get_ID()} Child's birthday: {child_birth} Parents' marriage date: {marriage}"
                            errors.append(result_2_str)

    return errors
Exemplo n.º 7
0
def userStory12(file):

    individuals, families = processGEDCOM(file)
    resultsList = list()

    for user_id in individuals.items():

        user_id = user_id[0]
        children_fam = individuals[user_id].Get_spouse()
        if children_fam == "NA":
            continue
        gender = individuals[user_id].Get_gender()
        parent_bday = individuals[user_id].Get_birthday()
        for each in children_fam:
            if families[each].Get_children() == 'NA':
                continue
            for child in families[each].Get_children():
                child_bday = individuals[child].Get_birthday()
                if gender == 'M':
                    datediff = rdelta.relativedelta(child_bday, parent_bday)
                    if datediff.years >= 80:
                        resultsList.append(
                            f"ERROR: INDIVIDUAL: US12: {user_id}: Father {user_id} is more than 80 years older than his child ({child}): {individuals[child].Get_name()}."
                        )
                else:
                    datediff = rdelta.relativedelta(child_bday, parent_bday)
                    if datediff.years >= 60:
                        resultsList.append(
                            f"ERROR: INDIVIDUAL: US12: {user_id}: Mother {user_id} is more than 60 years older than her child ({child}): {individuals[child].Get_name()}."
                        )
    resultsList.sort()

    return resultsList
Exemplo n.º 8
0
def userStory15(file):
    individuals, families = processGEDCOM(file)
    resultsList = list()

    for fam in families.values():
        children = fam.Get_children()
        num_sibs = len(children)

        if children == "NA":
            continue

        if num_sibs >= 15:
            resultsList.append(
                f"ERROR: FAMILY: US15: Family {fam.Get_ID()} has {num_sibs} siblings."
            )

    return resultsList
Exemplo n.º 9
0
def userStory16(file):
    individuals, families = processGEDCOM(file)
    resultsList = list()

    for fam in families.values():
        family_surname = fam.Get_husbandName().split(' ')[-1]
        children = fam.Get_children()

        for child_ID in children:
            if individuals[child_ID].Get_gender() == 'M':
                child_surname = individuals[child_ID].Get_name().split(' ')[-1]
                if child_surname != family_surname:
                    resultsList.append(
                        f"ERROR: FAMILY: US16: Child {child_ID}\'s last name ({child_surname}) does not match family name ({family_surname}) in family {fam.Get_ID()}."
                    )

    return resultsList
Exemplo n.º 10
0
def userStory03(file):
    indiDict, famDict = processGEDCOM(file)
    resultList = list()

    for index in indiDict:
        personID = indiDict[index].Get_ID()

        if personID != "NA":
            personBirthDate = indiDict[personID].Get_birthday()
            personDeathDate = indiDict[personID].Get_death()

            if personBirthDate != 'NA' and personDeathDate != 'NA':
                if personBirthDate > personDeathDate:
                    result_str = f"ERROR: INDIVIDUAL: US03: : {personID}: Person's birth date {personBirthDate} is after death date {personDeathDate}"
                    resultList.append(result_str)

    return resultList
Exemplo n.º 11
0
def userStory04(file):
    indiDict, famDict = processGEDCOM(file)
    resultList = list()

    for index in famDict:
        family = famDict[index]
        if (family.Get_divorced() == "NA"):
            continue
        divDate = family.Get_divorced()
        marrDate = family.Get_married()

        if (divDate < marrDate):
            error = f"ERROR: FAMILY: US04:{family.Get_ID()} Divorce date occurs before marriage date - Marriage {family.Get_married()}: Divorce {family.Get_divorced()}"
            resultList.append(error)
            continue

    resultList.sort()
    return resultList
Exemplo n.º 12
0
def userStory01(file):
    info, famtbl = processGEDCOM(file)
    resultList = list()

    dt = datetime.datetime.now()
    current = datetime.date(dt.year, dt.month, dt.day)
    resultList = list()
    good = True

    for key in info:
        user = info[key]
        fam = user.Get_spouse()
        individualID = user.Get_ID()

        if fam != 'NA':
            for i in range(len(fam)):
                marr = famtbl[fam[i]].Get_married()
                if (marr != 'NA'):
                    marriage = current > marr
                    if (marriage == False):
                        result_1_str = f"ERROR: INDIVIDUAL: US01: {individualID}: Marriage {marr} occurs in the future"
                        resultList.append(result_1_str)
            for i in range(len(fam)):
                div = famtbl[fam[i]].Get_divorced()
                if (div != 'NA'):
                    divorced = current > div
                    if (divorced == False):
                        result_1_str = f"ERROR: INDIVIDUAL: US01: {individualID}: Divorce {div} occurs in the future"
                        resultList.append(result_1_str)
            bday = current > user.Get_birthday()
            if (bday == False):
                result_1_str = f"ERROR: INDIVIDUAL: US01: {individualID}: Birthday {user.Get_birthday()} occurs in the future"
                resultList.append(result_1_str)
            if (user.Get_death() != 'NA'):
                death = current > user.Get_death()
                if (death == False):
                    result_1_str = f"ERROR: INDIVIDUAL: US01: {individualID}: Death {user.Get_death()} occurs in the future"
                    resultList.append(result_1_str)
    for i in resultList:
        print(i)
    return resultList
Exemplo n.º 13
0
def userStory05(file):
    i_dict, fam_dict = processGEDCOM(file)
    wife_status = False
    men_status = False
    errors = list()

    for key in fam_dict:
        family = fam_dict[key]
        fam_id = family.Get_ID()

        if (fam_dict[key] != 'NA'):
            h_id = str(fam_dict[fam_id].Get_husbandID())
            w_id = str(fam_dict[fam_id].Get_wifeID())
            if (h_id != 'NA' and w_id != 'NA'):
                if (i_dict[h_id].Get_death() != 'NA'):
                    husbandDeath = i_dict[h_id].Get_death()
                    men_status = True

                if (i_dict[w_id].Get_death() != 'NA'):
                    wifeDeath = i_dict[w_id].Get_death()
                    wife_status = True

                if (fam_dict[fam_id].Get_married() != "NA"):
                    marriedDate = fam_dict[fam_id].Get_married()

                if (wife_status and marriedDate > wifeDeath):
                    result_1_str = f"ERROR: FAMILY: US05: Wedding " + str(
                        fam_dict[fam_id].Get_married(
                        )) + " occurs after Wife death " + str(wifeDeath) + "."
                    errors.append(result_1_str)

                if (men_status and marriedDate > husbandDeath):

                    result_1_str = f"ERROR: FAMILY: US05: Wedding " + str(
                        fam_dict[fam_id].Get_married(
                        )) + " occurs after Husband death " + str(
                            husbandDeath) + "."
                    errors.append(result_1_str)

    return errors
Exemplo n.º 14
0
def sprint2_results():
    fileName = "sprint2_Reddy.ged"
    idict, famdict = processGEDCOM(fileName)
    indiTable, familyTable = printTable(idict, famdict)
    errors = []
    errors.extend(userStory05("sprint2_Reddy.ged"))
    errors.extend(userStory06("sprint2_Reddy.ged"))
    errors.extend(userStory07("sprint2_Reddy.ged"))
    errors.extend(userStory08("sprint2_Reddy.ged"))

    for e in errors:
        print(e)

    with open('acceptance_results.txt', 'w') as file:
        file.write('Individuals Information--------------->\n')
        file.write(indiTable.get_string())
        file.write("\n\n\n")
        file.write('Family Information------------>\n')
        file.write(familyTable.get_string())
        file.write("\n\n")
        for e in errors:
            file.write(e + "\n")
Exemplo n.º 15
0
def userStory21(file):

    individuals, families = processGEDCOM(file)
    resultsList = list()

    for fam in families:
        
        fclass = families[fam]

        husb_id = fclass.Get_husbandID()
        wife_id = fclass.Get_wifeID()
        if husb_id != 'NA':
            male = individuals[husb_id].Get_gender()
            if male != 'M':
                resultsList.append(f"ERROR: FAMILY: US21: {fam}: Husband ({husb_id}) is labelled incorrectly as ({male}).")
        if wife_id != 'NA':
            female = individuals[wife_id].Get_gender()
            if female != 'F':
                resultsList.append(f"ERROR: FAMILY: US21: {fam}: Wife ({wife_id}) is labelled incorrectly as ({female}).")


    return resultsList
Exemplo n.º 16
0
def sprint1_results():
    fileName = "sprint1_Reddy.ged"
    indiObj, familyObj = processGEDCOM(fileName)
    indiTable, familyTable = printTable(indiObj, familyObj)
    errors = []
    errors.extend(userStory01(fileName))
    errors.extend(userStory02(fileName))
    errors.extend(userStory03(fileName))
    errors.extend(userStory04(fileName))

    for e in errors:
        print(e)

    with open('acceptance_results.txt', 'w') as file:
        file.write('Individuals Information--------------->\n')
        file.write(indiTable.get_string())
        file.write("\n\n\n")
        file.write('Family Information------------>\n')
        file.write(familyTable.get_string())
        file.write("\n\n")
        for e in errors:
            file.write(e + "\n")
Exemplo n.º 17
0
def userStory06(file):
    indiDict,famDict = processGEDCOM(file)
    wife_status = False
    men_status = False
    errors = list()


    for key in famDict:
        family = famDict[key]
        familyID = family.Get_ID()

        if(famDict[key] != 'NA'):
            husbandID = str(famDict[familyID].Get_husbandID())
            wifeID = str(famDict[familyID].Get_wifeID())

            if(husbandID != 'NA' and wifeID != 'NA'):
                if(indiDict[husbandID].Get_death() != 'NA'):
                    husbandDeath = indiDict[husbandID].Get_death()
                    men_status = True

                if(indiDict[wifeID].Get_death() != 'NA'):
                    wifeDeath = indiDict[wifeID].Get_death()
                    wife_status = True

                if(famDict[familyID].Get_divorced() != "NA"):
                    divorcedDate = famDict[familyID].Get_divorced()

                    if(wife_status and divorcedDate > wifeDeath):

                        result_1_str = f"ERROR: FAMILY: US06: Divorced " + str(famDict[familyID].Get_divorced()) + " after wife death " + str(wifeDeath) + "." 
                        errors.append(result_1_str)

                    if(men_status and divorcedDate>husbandDeath):
                        result_1_str = f"ERROR: FAMILY: US06: Divorced " + str(famDict[familyID].Get_divorced()) + " after husband death " + str(husbandDeath) + "." 
                        
                        errors.append(result_1_str)

    return errors
Exemplo n.º 18
0
def userStory07(file, current_time=datetime.datetime.now().date()):
    i_dict, _ = processGEDCOM(file)
    errors = list()

    for key in i_dict:
        individual = i_dict[key]

        if (individual.Get_ID() != 'NA'):
            diff_limit = datetime.timedelta(seconds=(150 * 365 * 24 * 60 * 60))
            birth = individual.Get_birthday()

            if (individual.Get_death() != 'NA'):
                death = individual.Get_death()

                if ((death - birth) > diff_limit):
                    result_1_str = f"ERROR: INDIVIDUAL: US07: Person's death occurs more than 150 years after birth. ID: {individual.Get_ID()} Birth date: {birth} Death date: {death}"
                    errors.append(result_1_str)
            else:
                if ((current_time - birth) > diff_limit):
                    result_2_str = f"ERROR: INDIVIDUAL: US07: Current date is more than 150 years after person's birth. ID: {individual.Get_ID()} Birthdate: {birth} Current date: {current_time}"
                    errors.append(result_2_str)

    return errors