chiark / gitweb /
I'm sure I've done something since I remembered to commit...
[familyTree.git] / cgiFiles / jointAncestorGraph.py
1 #!/usr/bin/python
2
3 import cgi
4 #import cgitb
5 #cgitb.enable()
6 import sys
7 sys.path.append('/home/naath/familyTreeProject/familyTree')
8 import make_dot as d
9 import askQuestion as aQ
10 import graphQuestions as gQ
11
12
13
14 def make_graph(ID,ID2):
15         d.start_dot(8)  
16
17
18         mrca,otherRCA,lA,lB = gQ.relationship(ID,ID2)
19
20         nodes = gQ.join_up([ID,ID2],mrca+otherRCA)
21         
22
23         for node in nodes:
24                 [Self, selfID, selfName] = aQ.find_person(node)
25
26                 if node==ID or node==ID2 or node in mrca or node in otherRCA:
27                         d.add_highlight(Self)
28
29                 [ps,pIDs,pNames] = aQ.find_parents(node)
30                 if node not in mrca+otherRCA:
31                         d.add_marriage(ps[0],ps[1],[Self],1)
32                 elif (pIDs[0] in mrca+otherRCA) or (pIDs[1] in mrca+otherRCA):
33                         d.add_marriage(ps[0],ps[1],[Self],1)
34
35
36
37
38         if web==0:
39                 return
40         d.create_dot()
41         d.add_subgraphs()
42         d.end_dot()
43         d.render_dot()
44         aQ.close(conn)
45
46 global web
47 global maxLevel
48 web = 1
49 if web == 1:
50         form = cgi.FieldStorage()
51
52         ID = int(form.getvalue('id'))
53         ID2 = int(form.getvalue('id2'))
54         maxLevel = int(int(form.getvalue('mL')))
55 else:
56
57         ID = 60
58         ID2 = 226
59         maxLevel = 3
60 conn = aQ.connect()
61 make_graph(ID,ID2)
62 aQ.close()
63