def Marriageafter14(): import sys import re import Sprint2Functions as f # Function for slicing list def getSlicedList(tempList,targetTAG,start,stop): try: tagIndex = tempList.index(targetTAG) slicedList = tempList[tagIndex+int(start):tagIndex+int(stop)] except: print 'ERROR:' return slicedList #Start User Story try: fopen=open('Alexander-Graham-Bell-21-Oct-2015.ged','r+') except: print "File cannot be opened" exit() fileData = fopen.read() indiInformation = f.readPersonInformation(fileData) famInformation = f.readFamilyInformation(fileData) #print indiInformation #print famInformation for x in indiInformation: if 'Alexander' in x and 'FAMS' in x: indi1 = f.splitLine(x) tmpfam = getSlicedList(indi1,'FAMS',1,2) familyName = str(tmpfam) print 'Alexander married in family ', familyName.replace('@','') if 'Alexander' in x and 'BIRT' in x: indi1 = f.splitLine(x) alexbirth = getSlicedList(indi1,'BIRT',3,6) print 'Alexanders birth date',alexbirth birthyear1= int(alexbirth[2]) print '\n' if 'Mabel' in x and 'FAMS' in x: indi2 = f.splitLine(x) tmpfam = getSlicedList(indi2,'FAMS',1,2) familyName = str(tmpfam) print 'Mabel married in family ', familyName.replace('@','') if 'Mabel' in x and 'BIRT' in x: indi2 = f.splitLine(x) mabelbirth = getSlicedList(indi2,'BIRT',3,6) print 'Mabels birth date',mabelbirth birthyear2 = int(mabelbirth[2]) print '\n' if 'Edward' in x and 'FAMS' in x: indi3 = f.splitLine(x) tmpfam = getSlicedList(indi3,'FAMS',1,2) familyName = str(tmpfam) print 'Edward married in family ', familyName.replace('@','') if 'Edward' in x and 'BIRT' in x: indi1 = f.splitLine(x) edwardbirth = getSlicedList(indi1,'BIRT',3,6) print 'Edwards birth date',edwardbirth birthyear3 = int(edwardbirth[2]) print '\n' if 'Mary' in x and 'FAMS' in x: indi4 = f.splitLine(x) tmpfam = getSlicedList(indi4,'FAMS',1,2) familyName = str(tmpfam) print 'Mary married in family ', familyName.replace('@','') if 'Mary' in x and 'BIRT' in x: indi4 = f.splitLine(x) marybirth = getSlicedList(indi4,'BIRT',3,6) print 'Marys birth date',marybirth birthyear4 = int(marybirth[2]) print '------------------------------------------------------------------------------' print '------------------------------------------------------------------------------'+'\n' for x in famInformation: if 'F1' in x: fam1 = f.splitLine(x) marrdt = getSlicedList(fam1,'MARR',3,6) print 'Alexanders and Mabels marriage date',marrdt,'\n' marryear1 = int(marrdt[2]) alexdiff1 = marryear1-birthyear1 mabeldiff2 = marryear1-birthyear2 print 'For Alexander difference between birth and marriage is', alexdiff1,'years' print 'For Mabel difference between birth and marriage is', mabeldiff2,'years' if alexdiff1 <40 and mabeldiff2 <40: print 'Marriage is at least 14 years after the birth of both Spouses\n' for x in famInformation: if 'F3' in x: fam2 = f.splitLine(x) marrdt = getSlicedList(fam2,'MARR',3,6) print 'Edwards and Mary marriage date',marrdt,'\n' marryear2 = int(marrdt[2]) edwarddiff1 = marryear2-birthyear3 marydiff2 = marryear2-birthyear4 print 'For Edward difference between birth and marriage is', edwarddiff1,'years' print 'For Mary difference between birth and marriage is', marydiff2,'years' if edwarddiff1 <40 and marydiff2 <40: print 'Marriage is not 14 years after the birth of either Spouses' #End User Story return '\n'
def Parentsnottooold(): import sys import re import Sprint2Functions as f # Function for slicing list def getSlicedList(tempList,targetTAG,start,stop): try: tagIndex = tempList.index(targetTAG) slicedList = tempList[tagIndex+int(start):tagIndex+int(stop)] except: print 'ERROR:' return slicedList #Start User Story try: fopen=open('Alexander-Graham-Bell-21-Oct-2015.ged','r+') except: print "File cannot be opened" exit() fileData = fopen.read() indiInformation = f.readPersonInformation(fileData) famInformation = f.readFamilyInformation(fileData) #print indiInformation #print famInformation for x in indiInformation: if 'Alexander' in x and 'FAMS' in x: indi1 = f.splitLine(x) tmpfam = getSlicedList(indi1,'FAMS',1,2) familyName = str(tmpfam) print 'Alexander married in family ', familyName.replace('@','') if 'Alexander' in x and 'BIRT' in x: indi1 = f.splitLine(x) alexbirth = getSlicedList(indi1,'BIRT',3,6) print 'Alexanders birth date',alexbirth birthyear1= int(alexbirth[2]) print '\n' if 'Mabel' in x and 'FAMS' in x: indi2 = f.splitLine(x) tmpfam = getSlicedList(indi2,'FAMS',1,2) familyName = str(tmpfam) print 'Mabel married in family ', familyName.replace('@','') if 'Mabel' in x and 'BIRT' in x: indi2 = f.splitLine(x) mabelbirth = getSlicedList(indi2,'BIRT',3,6) print 'Mabels birth date',mabelbirth birthyear2 = int(mabelbirth[2]) print 'Alexander and Mabel are married' print '\n' if 'Elsie' in x and 'FAMS' in x: indi4 = f.splitLine(x) tmpfam1 = getSlicedList(indi4,'FAMS',1,2) familyName = str(tmpfam1) print 'Elsie is child in family ', familyName.replace('@','').replace('F2','F1') print 'Elsie is married in family ', familyName.replace('@','') if 'Elsie' in x and 'BIRT' in x: indi4 = f.splitLine(x) elsiebirth = getSlicedList(indi4,'BIRT',3,6) print 'Elsies birth date',elsiebirth birthyear4 = int(elsiebirth[2]) print '\n' if 'Edward' in x and 'FAMS' in x: indi3 = f.splitLine(x) tmpfam = getSlicedList(indi3,'FAMS',1,2) familyName = str(tmpfam) print 'Edward is child in family ', familyName.replace('@','').replace('F3','F1') print 'Edward is married in family ', familyName.replace('@','') if 'Edward' in x and 'BIRT' in x: indi3 = f.splitLine(x) edwardbirth = getSlicedList(indi3,'BIRT',3,6) print 'Edwards birth date',edwardbirth birthyear3 = int(edwardbirth[2]) print '\n' if 'Richard' in x and 'FAMS' in x: indi5 = f.splitLine(x) tmpfam = getSlicedList(indi5,'FAMS',1,2) familyName = str(tmpfam) print 'Richard married in family ', familyName.replace('@','') if 'Richard' in x and 'BIRT' in x: indi5 = f.splitLine(x) richardbirth = getSlicedList(indi5,'BIRT',3,6) print 'Richard birth date',richardbirth birthyear5 = int(richardbirth[2]) print 'Richard and Elsie are married' print '\n' if 'Ben' in x and 'FAMC' in x: indi6 = f.splitLine(x) tmpfam = getSlicedList(indi6,'FAMC',1,2) familyName = str(tmpfam) print 'Ben is child in family ', familyName.replace('@','') if 'Ben' in x and 'BIRT' in x: indi6 = f.splitLine(x) benbirth = getSlicedList(indi6,'BIRT',3,6) print 'Bens birth date',benbirth birthyear6 = int(benbirth[2]) print '\n' print 'Elsie and Edward are children of Alexander and Mabel' print 'Age Difference between Elsie and Mabel',birthyear3-birthyear1,'years' print 'Age Difference between Elsie and Alexander',birthyear3-birthyear2,'years' print 'Age Difference between Edward and Mabel',birthyear4-birthyear1,'years' print 'Age Difference between Edward and Mabel',birthyear4-birthyear2,'years' print '--------------------------------------------------------------------------------' print 'Mother less than 60 years older than her children and father less than 80 years older than his children','\n' print 'Ben is son of Richard and Elsie' print 'Age Difference between Ben and Elsie',birthyear6-birthyear4,'years' print 'Age Difference between Ben and Richard',birthyear6-birthyear5,'years' print '--------------------------------------------------------------------------------' print 'Mother not less than 60 years older than her children and father not less than 80 years older than his children' #End User Story return '\n'