def getFutureDates(collection): futureDates = [] today = datetime.datetime.now() for entry in collection: if getDate('Birthday', entry) > today: futureDates.append([entry['ID'], 'Birthday']) gedcom.individualError( 'US01', entry['ID'], ('Birthday %s occurs in the future.' % entry['Birthday']), entry['lines'][entry['ID'] + 'BIRT']) if getDate('Death', entry) > today: futureDates.append([entry['ID'], 'Death']) gedcom.individualError( 'US01', entry['ID'], ('Death %s occurs in the future.' % entry['Death']), entry['lines'][entry['ID'] + 'DEAT']) if getDate('Married', entry) > today: futureDates.append([entry['ID'], 'Married']) gedcom.familyError( 'US01', entry['ID'], ('Marriage date %s occurs in the future.' % entry['Married']), entry['lines'][entry['ID'] + 'MARR']) if getDate('Divorced', entry) > today: futureDates.append([entry['ID'], 'Divorced']) gedcom.familyError( 'US01', entry['ID'], ('Divorce date %s occurs in the future.' % entry['Divorced']), entry['lines'][entry['ID'] + 'MARR']) return futureDates
def birthsBeforeAndAfterMarriage(individualCollection, familyCollection): invalidBirths = [] for family in familyCollection: if family['Children']: for child in family['Children']: for individual in individualCollection: if individual['ID'] == child: birthday = getDate('Birthday', individual) marriage = getDate('Married', family) divorce = getDate('Divorced', family) if birthday != None and (not marriage or birthday < marriage): invalidBirths.append(child) gedcom.individualError( 'US08', child, 'Born before parents married', individual['lines'][individual['ID'] + 'BIRT']) elif birthday != None and (marriage and divorce and birthday > divorce): delta = birthday - divorce if delta.days > 270: invalidBirths.append(child) gedcom.individualError( 'US08', child, 'Born more than 9 months after parents divorce', individual['lines'][individual['ID'] + 'BIRT']) return invalidBirths
def getAgesOver150(individualCollection): over150 = [] for individual in individualCollection: if individual['Age'] and individual['Age'] >= 150: over150.append(individual['ID']) gedcom.individualError('US07', individual['ID'], ('More than 150 years old - Birth date %s (%s years old)' % (individual['Birthday'], individual['Age'])), individual['lines'][individual['ID'] + 'BIRT']) return over150
def getdb4b(collection): db4b = [] for person in collection: if not person['Death'] == None: if getDate('Death', person) < getDate('Birthday', person): db4b.append(person['ID']) gedcom.individualError( 'US03', person['ID'], "This person's death is before their birth...", person['lines'][person['ID'] + 'DEAT']) return db4b
def getDb4M(people, fams): results = [] for fam in fams: husbID = fam['Husband ID'] wifeID = fam['Wife ID'] marriageDate = getDate('Married', fam) for indi in people: if (indi['ID'] == husbID or indi['ID'] == wifeID): if not indi['Alive']: if (getDate('Death', indi) and getDate('Death', indi) < marriageDate): results.append(indi['ID']) gedcom.individualError('US05', indi['ID'], 'Individual died before marriage to spouse', indi['lines'][indi['ID'] + 'DEAT']) return results
def getNonUniqueIds(collection, colType): idPair = getIDs(collection, colType) nonUniqueIds = [] ids = [] for i in idPair: ids.append(i[0]) if i[0] and i[0] not in nonUniqueIds and ids.count(i[0]) != 1: nonUniqueIds.append(i[0]) msg = 'ID not unique, more than one occurence found.' if colType == 'individual': gedcom.individualError('US22', i[0], msg, i[1]) elif colType == 'family': gedcom.familyError('US22', i[0], msg, i[1]) return nonUniqueIds
def getBirthsAfterDeathsOfParents(individualCollection, familyCollection): birthsAfterDeaths = [] for family in familyCollection: parentIDs = {'mom': family['Wife ID'], 'dad': family['Husband ID']} childrenIDs = family['Children'] momDeath = None dadDeath = None childBirths = [] if childrenIDs: for individual in individualCollection: if individual['ID'] == parentIDs['mom']: momDeath = getDate('Death', individual) if individual['ID'] == parentIDs['dad']: dadDeath = getDate('Death', individual) if getDate('Birthday', individual) and individual['ID'] in childrenIDs: childBirths.append([ individual['ID'], getDate('Birthday', individual), individual['lines'][individual['ID'] + 'BIRT'] ]) for births in childBirths: if momDeath and births[1] and births[1] > momDeath: gedcom.individualError( 'US09', births[0], ('Child born %s after death of mother %s' % (births[1], momDeath)), births[2]) birthsAfterDeaths.append(births[0]) if dadDeath and births[1] and births[1] > dadDeath and ( births[1] - dadDeath).days > 270: gedcom.individualError('US09', births[0], ( 'Child born %s more than 9 months after death of father %s' % (births[1], dadDeath)), births[2]) birthsAfterDeaths.append(births[0]) return birthsAfterDeaths
def getBigamousIndividuals(individualCollection, familyCollection): bigamousIndividuals = [] for individual in individualCollection: iid = individual['ID'] families = individual['Spouse'] dateTuples = getIndividualMarriageAndDivorceDates( iid, families, familyCollection) if dateTuples: index = 1 while index < len(dateTuples): prevDates = dateTuples[index - 1] prevMarriage = prevDates[3] prevDivorce = prevDates[4] curIndex = index while curIndex < len(dateTuples): curDates = dateTuples[curIndex] curMarriage = curDates[3] curDivorce = curDates[4] marriedWhileMarried = curMarriage > prevMarriage marriedBeforeDivorce = (prevDivorce and curMarriage and prevDivorce > curMarriage) if marriedWhileMarried or marriedBeforeDivorce: bigamousIndividuals.append( (iid, prevDates[2], curDates[2])) msg = 'Individual is bigamous, married to %s before divorce to %s' % ( curDates[2], prevDates[2]) gedcom.individualError( 'US11', iid, msg, curDates[5][curDates[0] + 'MARR']) curIndex = curIndex + 1 index = index + 1 return bigamousIndividuals
def getInconsistencies(individualCollection, familyCollection): CHILDOF = 0 CHILDREN = 0 SPOUSE = 1 GENDER = 2 HUSB = 1 WIFE = 2 indis = {} fams = {} inconChildOf = [] inconChildren = [] inconSpouse = [] inconHusband = [] inconWife = [] for indi in individualCollection: iid = indi['ID'] gender = indi['Gender'] childOf = indi['Child'] spouseOf = indi['Spouse'] lines = indi['lines'] try: indis[iid] except KeyError: indis[iid] = (childOf, spouseOf, gender, lines) for fam in familyCollection: fid = fam['ID'] children = fam['Children'] husband = fam['Husband ID'] wife = fam['Wife ID'] lines = fam['lines'] try: fams[fid] except KeyError: fams[fid] = (children, husband, wife, lines) for iid, iinfo in indis.items(): childOf = iinfo[CHILDOF] spouseOf = iinfo[SPOUSE] gender = iinfo[GENDER] lines = iinfo[3] if childOf != None: for fid in childOf: try: fam = fams[fid] children = fam[CHILDREN] if children == None or iid not in children: inconChildOf.append((iid, fid)) gedcom.individualError('US26', iid, ( 'Individual is child of %s, but the family has no entry for individual' % fid), lines[fid + 'FAMC']) except KeyError: inconChildOf.append((iid, fid)) gedcom.individualError('US26', iid, ( 'Individual is child to family %s which doesn\'t exist' % fid), lines[fid + 'FAMC']) if spouseOf != None: for fid in spouseOf: try: fam = fams[fid] husband = fam[HUSB] wife = fam[WIFE] if gender == 'M': if husband == None or iid != husband: inconSpouse.append((iid, fid)) gedcom.individualError('US26', iid, ( 'Individual is husband of %s, but the family has no entry for individual' % fid), lines[fid + 'FAMS']) elif gender == 'F': if wife == None or iid != wife: inconSpouse.append((iid, fid)) gedcom.individualError('US26', iid, ( 'Individual is wife of %s, but the family has no entry for individual' % fid), lines[fid + 'FAMS']) except KeyError: inconSpouse.append((iid, fid)) gedcom.individualError('US26', iid, ( 'Individual is spouse in family %s which doesn\'t exist' % fid), lines[fid + 'FAMS']) for fid, finfo in fams.items(): children = finfo[CHILDREN] husband = finfo[HUSB] wife = finfo[WIFE] lines = finfo[3] if children != None: for iid in children: try: indi = indis[iid] childOf = indi[CHILDOF] if childOf == None or fid not in childOf: inconChildren.append((fid, iid)) gedcom.familyError('US26', fid, ( 'Family has child %s listed, but individual has no entry for family' % iid), lines[iid + 'CHIL']) except KeyError: inconChildren.append((fid, iid)) gedcom.familyError( 'US26', fid, ('Family has child %s that doesn\'t exist' % iid), lines[iid + 'CHIL']) if husband != None: try: indi = indis[husband] spouses = indi[SPOUSE] if spouses != None: for spouse in spouses: if spouse == None or spouse != fid: inconHusband.append((fid, husband)) gedcom.familyError('US26', fid, ( 'Family has husband %s listed, but individual has no entry for family' % husband), lines[fid + 'HUSB']) else: inconHusband.append((fid, husband)) gedcom.familyError('US26', fid, ( 'Family has husband %s listed, but individual has no entry for family' % husband), lines[fid + 'HUSB']) except KeyError: inconHusband.append((fid, husband)) gedcom.familyError( 'US26', fid, ('Family has husband %s that doesn\'t exist' % husband), lines[fid + 'HUSB']) if wife != None: try: indi = indis[wife] spouses = indi[SPOUSE] if spouses != None: for spouse in spouses: if spouse == None or spouse != fid: inconWife.append((fid, wife)) gedcom.familyError('US26', fid, ( 'Family has wife %s listed, but individual has no entry for family' % wife), lines[fid + 'WIFE']) else: inconWife.append((fid, wife)) gedcom.familyError('US26', fid, ( 'Family has husband %s listed, but individual has no entry for family' % wife), lines[fid + 'WIFE']) except KeyError: inconWife.append((fid, wife)) gedcom.familyError( 'US26', fid, ('Family has wife %s that doesn\'t exist' % wife), lines[fid + 'WIFE']) return inconChildOf, inconSpouse, inconChildren, inconHusband, inconWife