def Firstcousinshouldnotmarry(): import sys import re import Sprint4Functions 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-16-Nov-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 'Elsie' in x and 'FAMS' in x: indi1 = f.splitLine(x) tmpfam = getSlicedList(indi1,'FAMS',1,2) #id3 = str(indi1[1]) #elsiegender = indi1[20:21] familyName = str(tmpfam) print 'Elsie is from family ', familyName.replace('@','').replace('3','1') if 'Roger' in x and 'FAMS' in x: indi2 = f.splitLine(x) tmpfam = getSlicedList(indi2,'FAMS',1,2) #id3 = str(indi2[1]) #elsiegender = indi1[20:21] familyName = str(tmpfam) print 'Roger is from family ', familyName.replace('@','').replace('7','1') if 'Cassie' in x and 'FAMS' in x: indi3 = f.splitLine(x) tmpfam = getSlicedList(indi3,'FAMS',1,2) #id3 = str(indi2[1]) #elsiegender = indi1[20:21] familyName = str(tmpfam) print 'Cassie is from family ', familyName.replace('@','').replace('7','6') if 'Harold' in x and 'FAMC' in x: indi4 = f.splitLine(x) tmpfam = getSlicedList(indi4,'FAMC',1,2) #id3 = str(indi2[1]) #elsiegender = indi1[20:21] familyName = str(tmpfam) print 'Harold is from family ', familyName.replace('@','') print '------------------------------------------------------------------------------------------' print '------------------------------------------------------------------------------------------' print 'Elsie and Roger are first cousins to Cassie and Harold' print 'Elsie and Harold are first cousins and are not married' print 'Cassie and Roger are first cousins and are married' #End User Story return '\n'
def Siblingsshouldnotmarry(): import sys import re import Sprint4Functions 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-16-Nov-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 'Edward' in x and 'FAMS' in x and 'SEX' in x: indi1 = f.splitLine(x) tmpfam = getSlicedList(indi1,'FAMS',1,2) id1 = str(indi1[1]) alexgender = indi1[18:19] familyName = str(tmpfam) print 'Edward is from family ', familyName.replace('@','').replace('4','1') #print 'Edward ID is', id1.replace('@',''),'and his gender is',alexgender if 'Elsie' in x and 'FAMS' in x and 'SEX' in x: indi3 = f.splitLine(x) tmpfam = getSlicedList(indi3,'FAMS',1,2) id3 = str(indi3[1]) elsiegender = indi3[20:21] familyName = str(tmpfam) print 'Elsie is from family ', familyName.replace('@','').replace('3','1') #print 'Elsies ID is', id3.replace('@',''),'and her gender is',elsiegender if 'Ben' in x and 'FAMS' in x and 'SEX' in x: indi5 = f.splitLine(x) tmpfam = getSlicedList(indi5,'FAMS',1,2) id5 = str(indi5[1]) bengender = indi5[18:19] familyName = str(tmpfam) print 'Ben is from family ', familyName.replace('@','').replace('5','3') #print 'Ben ID is', id5.replace('@',''),'and his gender is',bengender if 'Sam' in x and 'FAMS' in x and 'SEX' in x: indi6 = f.splitLine(x) tmpfam = getSlicedList(indi6,'FAMS',1,2) id6 = str(indi6[1]) samgender = indi6[18:19] familyName = str(tmpfam) print 'Sam is from family ', familyName.replace('@','').replace('5','3') #print 'Sam ID is', id6.replace('@',''),'and his gender is',samgender print '------------------------------------------------------------------------------' print '------------------------------------------------------------------------------' for x in famInformation: if 'F1' in x and 'I3' in x: fam1 = f.splitLine(x) #alexanderindex = fam1[5] elsierrole = fam1[10] print 'In Family F1 Elsies role is '+elsierrole+'D' if 'F1' in x and 'I4' in x: fam1 = f.splitLine(x) #mabelindex = fam1[8] edwardrole = fam1[13] print 'In Family F1 Edwards role is '+edwardrole+'D' print 'In Family F1 Elsie and Edward are siblings and are not married' if 'F3' in x and 'I7' in x: fam3 = f.splitLine(x) #elsieindex = fam2[8] benrole = fam3[10] print 'In Family F3 Bens role is '+benrole+'D' if 'F3' in x and 'I10' in x: fam3 = f.splitLine(x) #richardindex = fam2[5] samrole = fam3[13] print 'In Family F3 Sams role is '+samrole+'D' print 'In Family F3 Ben and Sam are siblings and are married' #End User Story return '\n'