-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUS05_marriageBeforeDeath.py
80 lines (68 loc) · 2.26 KB
/
US05_marriageBeforeDeath.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
Marriage Before Death
"""
from all_db_operations import *
from print_data import *
#Datebase Connection
connection=MongoClient('localhost',27017)
db=connection['GEDCOMDB']
def US05_marriageBeforeDeath():
userStoryName('US05')
family=db.family.find({})
marriageDate=0
flag=0
for document in family:
try:
famID=document["FAMID"]
marriageDate=getMarriageDate(famID)
marriageDate=marriageDate.split("-")
deathData=getDeathDate(famID)
marriageAfterDeath=[]
marriageBeforeDeath=[]
for death in deathData:
death=death.split("-")
if death[0]<marriageDate[0]:
flag=0
elif death[0]==marriageDate[0]:
if death[1]<marriageDate[0]:
flag=0
elif death[1]==marriageDate[1]:
if death[2]<marriageDate[2]:
flag=0
else:
flag=1
else:
flag=1
else:
flag=1
if(flag==0):
#return False
marriageAfterDeath.append(famID)
else:
#return True
marriageBeforeDeath.append(famID)
for familyID in marriageAfterDeath:
message="A member of this family has marriage date after their death date"
save_invalid_family_for_print(familyID,"US05",message)
except:
marriageDate="No marriage"
deathData="No Death"
def getMarriageDate(id):
family=db.family.find({"FAMID":id})
for document in family:
try:
marriage_date=document["marriage"]
except:
continue
marriage_date=marriage_date.split(" ")
return marriage_date[0]
def getDeathDate(id):
people=db.people.find({"FAMS":id})
peoples=list()
for document in people:
try:
death=document["deathDate"]
death=death.split(" ")
peoples.append(death[0])
except:continue
return peoples