Exemplo n.º 1
0
def getFamInfoFromBlocks(blocks):
    for infoBlock in blocks:
        if len(famList) < famLength:
            tempFam = family(None)
            for index, infoLine in enumerate(infoBlock):
                if infoLine[4] == 'FAM':
                    tempFam.famid = infoLine[2]
                if infoLine[2] == 'HUSB':
                    tempFam.husband = infoLine[4]
                if infoLine[2] == 'WIFE':
                    tempFam.wife = infoLine[4]
                if infoLine[2] == 'CHIL':
                    tempFam.children.append(infoLine[4])
                if infoLine[2] == 'MARR\n':
                    tempFam.marDate = datetime.datetime.strftime(
                        gedUtil().getDate(infoBlock[index + 1][4]),
                        "'%d %b %Y'")
                if infoLine[2] == '_SEPR\n':
                    tempFam.divDate = datetime.datetime.strftime(
                        gedUtil().getDate(infoBlock[index + 1][4]),
                        "'%d %b %Y'")
            famList.append(tempFam)
        else:
            print("Maximum amount of families stored!\n")
    #Search the name for them and add
    for fam in famList:
        for person in indList:
            if person.indi == fam.husband:
                fam.husbandN = person.name
                person.marDate = fam.marDate
                person.divDate = fam.divDate
            if person.indi == fam.wife:
                fam.wifeN = person.name
                person.marDate = fam.marDate
                person.divDate = fam.divDate
Exemplo n.º 2
0
def getIndInfoFromBlocks(blocks):
    for infoBlock in blocks:
        if len(indList) < indLength:
            tempIndi = individual(None)
            for index, infoLine in enumerate(infoBlock):
                # deal with properties here
                if infoLine[4] == 'INDI':
                    tempIndi.indi = infoLine[2]  #Kt
                if infoLine[2] == 'NAME':
                    tempIndi.name = infoLine[4]  #Kt
                if infoLine[2] == 'BIRT\n':
                    tempIndi.birth = datetime.datetime.strftime(
                        gedUtil().getDate(infoBlock[index + 1][4]),
                        "'%d %b %Y'")  #Kt
                if infoLine[2] == 'DEAT':
                    tempIndi.death = datetime.datetime.strftime(
                        gedUtil().getDate(infoBlock[index + 1][4]),
                        "'%d %b %Y'")  #Kt
                if infoLine[2] == 'FAMC':
                    tempIndi.familyC = infoLine[4]  #Na
                #if infoLine[2] == 'FAMS':
                # tempIndi.familyS.append(infoLine[4])
            indList.append(tempIndi)
        else:
            print("Maximum amount of individuals stored!\n")
    def datebeforeCurrentdate(self, person):
        util = gedUtil()
        current = datetime.datetime.today().strftime('%d %b %Y')

        if (person.birth != "not mentioned"):
            return gedUtil().dateCompare(current, person.birth)
        elif (person.marDate != "not mentioned"):
            return gedUtil().dateCompare(person.marDate, current)
        elif (person.death != "not mentioned"):
            return gedUtil().dateCompare(person.death, current)
        elif (person.divDate != "not mentioned"):
            return gedUtil().dateCompare(person.divDate, current)
        else:
            return 0
 def livingsingle(self, indList):
     livingsingle = []
     for ind in indList:
         if ind.death != "not mentioned" and ind.marDate == "not mentioned" and gedUtil(
         ).getAge(ind) > 30:
             livingsingle.append(ind.name)
     return livingsingle
    def validParentsage(self, indList, famList):
        return_flag = True
        util = gedUtil()

        for family in famList:
            husband = None
            wife = None
            children = None
            for ind in indList:
                if ind.indi == family.husband:
                    husband = ind
                if ind.indi == family.wife:
                    wife = ind
                if ind.indi == family.children:
                    children == ind
                if husband != "not mentioned" and wife != "not mentioned" and children != "not mentioned":
                    break

        try:
            if (util.getAge(husband.birth) - util.getAge(children.birth)) > 80:
                print("Parent of father is too old")
                return_flag = False

            if (util.getAge(wife.birth) - util.getAge(children.birth)) > 60:
                print("Parent of mother is too old")
                return_flag = False
        except:
            print("Wrong data")
        return return_flag
    def validMarriage(self, indList, famList):
        return_flag = True
        util = gedUtil()
        current = datetime.datetime.today()
        min_birth = datetime.datetime(current.year - 14, current.month,
                                      current.day)

        for family in famList:
            husband = None
            wife = None
            for ind in indList:
                if ind.indi == family.husband:
                    husband = ind
                if ind.indi == family.wife:
                    wife = ind
                if husband is not None and wife is not None:
                    break

        try:
            if util.getDate(husband.birth) > min_birth:
                print(husband + " is married before 14 years old")
                return_flag = False

            if util.getDate(wife.birth) > min_birth:
                print(wife + " is married before 14 years old")
                return_flag = False
        except:
            print("incomplete data")
        return return_flag
 def FewerSiblings(self, indList, famList):
     util = gedUtil()
     outputindList = copy.deepcopy(famList)
     for fam in famList:
         if fam.children.count > 15:
             outputindList.remove(fam)
     return outputindList
 def upcomingBirthdays(self, indList):
     birthdays = []
     for ind in indList:
         if ind.death == "not mentioned" and gedUtil().dateWithin30Days(
                 ind):
             birthdays.append(ind)
     if len(birthdays) > 0:
         for ind in birthdays:
             print(ind.name)
     return
    def validBirth(self, indList, famList):
        return_flag = True
        util = gedUtil()
        for ind in indList:
            if ind.familyC != "not mentioned":
                father = None
                fatherID = None
                mother = None
                motherID = None
                fam = None
                marriage = None

                for family in famList:
                    if family.famid == ind.familyC:
                        fatherID = family.husband
                        motherID = family.wife
                        fam = family
                        break

                for inds in indList:
                    if inds.indi == fatherID:
                        father = inds
                        marriage = inds.marDate
                    if inds.indi == motherID:
                        mother = inds
                        marriage = inds.marDate

                try:
                    if util.getDate(father.death) is not None and util.getDate(
                            father.death) < util.getDate(
                                ind.birth) - datetime.timedelta(days=266):
                        print(
                            "Child is born more than 9 months after death of "
                            + father.name)
                        return_flag = False

                    if util.getDate(mother.death) is not None and util.getDate(
                            mother.death) < util.getDate(ind.birth):
                        print("Child is born after death of " + mother.name)
                        return_flag = False

                    if util.getDate(ind.birth) < util.getDate(marriage):
                        print("Child is born before marriage of " +
                              father.name + " and " + mother.name)
                        return_flag = False
                except:
                    print("incomplete info")
        return return_flag
    def UniqueChildName(self, famList, indList):
        util = gedUtil()
        outputindList = copy.deepcopy(famList)
        for family in famList:
            childName = []

            for child in family.children:
                for ind in indList:
                    if ind.indi == family.children:
                        child == ind
                        childName.append(child.name.split()[0])

            if (len(childName) != (len(set(childName)))):
                outputindList.remove(family)
                break
        return outputindList
 def SiblingsSpacing(self, indList, famList):
     util = gedUtil()
     outputindList = copy.deepcopy(famList)
     for fam in famList:
         childBirthList = []
         if fam.children.count >= 0:
             for child in fam.children:
                 birthStr = util.getBirthStrByIndi(child, indList)
                 if birthStr != "not mentioned":
                     childBirthList.append(util.getDate(birthStr))
         for Date in childBirthList:
             for Date2 in childBirthList:
                 if gedHelper().SiblingsSpacingUtil(Date, Date2):
                     outputindList.remove(fam)
                     break
     return outputindList
    def MultipleBirthsDelete(self, indList, famList):
        util = gedUtil()
        outputindList = copy.deepcopy(famList)
        for fam in famList:
            childBirthList = []

            if len(fam.children) >= 5:  # only consider this situation
                for child in fam.children:
                    birthStr = util.getBirthStrByIndi(child, indList)
                    if birthStr != "Not Mentioned":
                        childBirthList.append(birthStr)
            if len(childBirthList) > 5:  # valid record more than 4
                for item in childBirthList:
                    if childBirthList.count(item) > 5:
                        outputindList.remove(fam)
                        break
        return outputindList
    def AuntsAndUncles(self, indList, famList):

        return_flag = True
        util = gedUtil()

        for family in famList:

            # Get the couple's IDs
            husband = None
            wife = None
            for ind in indList:
                if ind.indi == family.husband:
                    husband = ind
                if ind.indi == family.wife:
                    wife = ind
                if husband is not None and wife is not None:
                    break

            # Get the parents' IDs
            husband_mother = None
            husband_father = None
            wife_mother = None
            wife_father = None
            for child_fam in famList:
                #tu fix
                if husband.indi in child_fam.children:
                    husband_mother = child_fam.wife
                    husband_father = child_fam.husband
                if wife.indi in child_fam.children:
                    wife_mother = child_fam.wife
                    wife_father = child_fam.husband
                if husband_mother is not None and wife_mother is not None:
                    break
            try:
                # Wife is a sister to one of the husband's parents
                if husband_mother.familyC == wife.familyC or husband_father == wife.familyC:
                    return_flag = False

                # Husband is a brother to one of the wife's parents
                if wife_mother.familyC == husband.familyC or wife_father == husband.familyC:
                    return_flag = False
            except:
                print("incomplete data")

        return return_flag
 def Anniversary(self, famList):
     anniversaries = []
     # Get the current day and month. Year does not matter
     #fixed by tu
     currentMonth = datetime.datetime.now().month
     currentDay = datetime.datetime.now().day
     for fam in famList:
         # Check if the family is married and not divorced
         if fam.marDate != "not mentioned" and fam.divDate == "not mentioned":
             marriage = gedUtil().getDate(fam.marDate)
             # If the month is later than the current, append it
             if marriage.month > currentMonth:
                 anniversaries.append(marriage)
             # If the month is the current and the day is later, append it
             if marriage.month == currentMonth and marriage.day > currentDay:
                 anniversaries.append(marriage)
     for ann in anniversaries:
         print(ann)
 def MaleLastNames(self, indList, famList):
     util = gedUtil()
     outputindList = copy.deepcopy(famList)
     husband = None
     child = None
     for family in famList:
         for ind in indList:
             if ind.indi == family.husband:
                 husband = ind
                 lastName = husband.name.split()[1]
                 for child in family.children:
                     for ind in indList:
                         if ind.indi == family.children:
                             child = ind
                             if (child.sex == "M") and (
                                     child.name.split()[1] != lastName):
                                 outputindList.remove(family)
     return outputindList
 def orderSibling(self, indList, fam):
     util = gedUtil()
     siblings = []
     children = []
     ordered = []
     for child in fam.children:
         children.append(str(child))
     for ind in indList:
         indi = str(ind.indi)
         for child in children:
             if (indi == child):
                 siblings.append(ind)
     while len(siblings) > 0:
         oldest = siblings[0]
         for sibling in siblings:
             if util.getAge(sibling) > util.getAge(oldest):
                 oldest = sibling
         ordered.append(siblings.pop(siblings.index(oldest)))
     return ordered
 def recentSurvivors(self, indList, famList):
     for ind in indList:
         if ind.death != "not mentioned":
             if gedUtil().dateLessThanThirtyDays(ind.death):
                 print("Recently deceased: " + ind.name)
                 if ind.husbID != "not mentioned":
                     for h in indList:
                         if h.indi == ind.husbID:
                             if h.death == "not mentioned":
                                 print("Surviving husband: " + h.name)
                                 break
                 if ind.wifeID != "not mentioned":
                     for w in indList:
                         if w.indi == ind.wifeID:
                             if w.death == "not mentioned":
                                 print("Surviving wife: " + w.name)
                                 break
                 for fam in famList:
                     if fam.famid == ind.family:
                         if len(fam.children) > 0:
                             print("-Surviving Descendants-")
                             print(*fam.children, sep=", ")
     return
Exemplo n.º 18
0
    'BIRT': 1,
    'DEAT': 1,
    'FAMC': 1,
    'FAMS': 1,
    'FAM': 0,
    'MARR': 1,
    'HUSB': 1,
    'WIFE': 1,
    'CHIL': 1,
    'DIV': 1,
    'DATE': 2,
    'HEAD': 0,
    'TRLR': 0,
    'NOTE': 0
}
util = gedUtil()


class individual(object):

    #Add the property you need here
    def __init__(
            self,
            indi,
            name="empty",
            sex="not mentioned",
            birth="not mentioned",
            death="not mentioned",
            marrigeDate="not mentioned",
            divorceDate="not mentioned",
            family="not mentioned",
 def divorceBeforeDeath(self, person):
     if (person.divDate == "not mentioned") or (person.death
                                                == "not mentioned"):
         return True
     else:
         return gedUtil().dateCompare(person.death, person.divDate)
 def LoadAgeForPerson(self, person):
     return gedUtil().getAge(person)
 def marriageBeforeDivorce(self, person):
     if (person.marDate == "not mentioned") or (person.divDate
                                                == "not mentioned"):
         return True
     else:
         return gedUtil().dateCompare(person.divDate, person.marDate)
 def birthBeforeDeath(self, person):
     if (person.birth == "not mentioned") or (person.death
                                              == "not mentioned"):
         return True
     else:
         return gedUtil().dateCompare(person.death, person.birth)
 def birthBeforeMarriage(self, person):
     if (person.birth == "not mentioned") or (person.marDate
                                              == "not mentioned"):
         return True
     else:
         return gedUtil().dateCompare(person.marDate, person.birth)