def anyCousinsMarried(familyCollections, individualCollection): ret = [] for i in familyCollections: if (bool(set(getParentsParents(i['Husband ID'], familyCollections, individualCollection)) & set(getParentsParents(i['Wife ID'], familyCollections, individualCollection)))): ret.append(i['ID']) gedcom.familyError('US19', i['ID'], 'First cousins should not be married', i['lines'][i['ID'] + 'FAM']) return ret
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 getHusbandGender(individualCollection, familyCollection): reversedGenders = [] for f in familyCollection: husbandID = f['Husband ID'] for i in individualCollection: if i['ID'] == husbandID: if i['Gender'] != 'M': reversedGenders.append(husbandID) gedcom.familyError('US21', f['ID'], ('Husband (%s) gender should be M' % husbandID), i['lines'][husbandID + 'SEX']) return reversedGenders
def getWifeGender(individualCollection, familyCollection): reversedGenders = [] for f in familyCollection: wifeID = f['Wife ID'] for i in individualCollection: if i['ID'] == wifeID: if i['Gender'] != 'F': reversedGenders.append(wifeID) gedcom.familyError('US21', f['ID'], ('Wife (%s) should be F' % wifeID), i['lines'][wifeID + 'SEX']) return reversedGenders
def noSiblingsMarried(familyCollection,individualCollection): Husband = None Wife = None WrongFamList = [] for family in familyCollection: for individual in individualCollection: if individual["ID"] == family["Husband ID"]: Husband = individual elif individual["ID"] == family["Wife ID"]: Wife = individual if Husband != None and Wife != None and Husband["Child"] == Wife["Child"]: if (Husband["Child"] != None and Wife["Child"] != None): WrongFamList.append(Husband["Child"]) gedcom.familyError('US18', family['ID'], ('Husband and Wife are siblings in family: %s' % Husband['Child']), family['lines'][family['ID'] + 'FAM']) return WrongFamList
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 birthBeforeMarriage(familyCollection, individualCollection): WrongFamList = [] for family in familyCollection: for spouse in individualCollection: if family['Husband ID'] == spouse['ID'] or family[ 'Wife ID'] == spouse['ID']: if getDate('Married', family) and getDate( 'Birthday', spouse) and getDate( 'Married', family) < getDate('Birthday', spouse): WrongFamList.append(family['ID']) gedcom.familyError('US02', family['ID'], ('Birthday %s after being married' % spouse['Birthday']), spouse['lines'][spouse['ID'] + 'BIRT']) return set(WrongFamList)
def getDivb4D(people, fams): results = [] for fam in fams: husbID = fam['Husband ID'] wifeID = fam['Wife ID'] if (not fam['Divorced'] == None): divorceDate = getDate('Divorced', fam) for indi in people: if (indi['ID'] == husbID or indi['ID'] == wifeID): if (not indi['Death'] == None): if (getDate('Death', indi) < divorceDate): results.append(fam['ID']) gedcom.familyError( 'US06', fam['ID'], 'Divorce occurs after death of both spouses', fam['lines'][fam['ID'] + 'DIV']) return results
def marriedBeforeDivorced(familyCollection): wrongFamList = [] for family in familyCollection: if getDate('Married', family) == None and getDate('Divorced', family) != None: wrongFamList.append(family['ID']) gedcom.familyError('US04', family['ID'], ('Divorced %s without ever being married' % family['Divorced']), family['lines'][family['ID'] + 'DIV']) elif getDate('Married', family) != None and getDate( 'Divorced', family) != None and getDate( 'Married', family) > getDate('Divorced', family): wrongFamList.append(family['ID']) gedcom.familyError('US04', family['ID'], ('Divorced %s before marriage %s' % (family['Divorced'], family['Married'])), family['lines'][family['ID'] + 'DIV']) return wrongFamList
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