global link_Template
link_Template= Template("<a href = http://www.chiark.greenend.org.uk/ucgi/~naath/$script>$text</a>")
-
def run_query(s,t):
c = make_cursor()
return c.execute(s,t)
else:
return row[0] + "," +str(row[1])
-def print_age_count(row,newLine):
+def print_people(n):
+ if n>1:
+ return ' people '
+ else:
+ return ' person '
+
+def print_age_child_count(row,newLine):
if newLine == '<br>':
script = "age.py?age="+str(row[0])
link = link_Template.substitute(script = \
script, text = row[0])
- out = str(row[1])
- if row[1]>1:
- out = out + ' people '
- else:
- out = out + ' person '
+ out = str(row[1])+print_people(row[1])
out = out + 'had children at age '+ link + newLine
return out
else:
return print_row(row,newLine)
+def print_age_death_count(row,newLine):
+ if newLine =='<br>':
+ script = "ageDeath.py?age="+str(row[0])
+ link = link_Template.substitute(script = script,text = row[0])
+ out = str(row[1])+print_people(row[1])
+ out = out + "died at age " + link + newLine
+ return out
+ else:
+ return print_row(row,newLine)
def print_name_count(row,newLine):
if newLine=='<br>':
out =out + terr_html(row[0],newLine) +newLine
return out
+def list_people_parents():
+ s = "SELECT name,id"\
+ +" FROM people"\
+ +" ORDER BY id;"
+
+ output = []
+ for row in run_query(s,()):
+ t = "SELECT parentid"\
+ +" FROM parents"\
+ +" WHERE id = ?;"
+
+ u = "SELECT name,id"\
+ +" FROM people"\
+ +" WHERE id = ?";
+
+ parents =[]
+ for r in run_query(t,(row[1],)):
+ parentID = r[0]
+ hasParent = 0
+ for q in run_query(u,(r[0],)):
+ parents.append(q[0] + ' ' + str(q[1]))
+ hasParent=1
+ if hasParent==0:
+ parents.append(r[0] + ' p' +\
+ str(row[1]))
+
+ spouses=[]
+ v = "SELECT name,idb"\
+ +" FROM marriages LEFT JOIN people"\
+ +" ON idb = id"\
+ +" WHERE ida = ?"
+ for r in run_query(v,(row[1],)):
+ if r[0]!=None:
+ spouses.append(r[0]+ ' '+str(r[1]))
+ else:
+ spouses.append(r[1] + ' s' +\
+ str(row[1]))
+
+
+ myName = row[0]
+ myID = str(row[1])
+ output.append([myName+ ' '+ myID,parents,spouses])
+ return output
+
def list_people(newLine):
s = "SELECT name,id,bornyear"\
out = ''
for row in run_query(s,()):
- out = out + print_age_count(row,newLine)
+ out = out + print_age_child_count(row,newLine)
return out
return out
+def count_age_at_death(newLine):
+ s = "select diedYear-bornYear as age,count(*)"\
+ +" FROM people"\
+ +" WHERE diedYear<>0 AND bornYear<>0"\
+ +" GROUP BY age;"
+ out=''
+ for row in run_query(s,()):
+ out = out + print_age_death_count(row,newLine)
+
+ return out
+def people_died_at_age(age,newLine):
+ s = "SELECT diedYear-bornYear as age, name,ID"\
+ +" FROM people"\
+ +" WHERE age = ? AND bornYear<>0 AND diedYear<>0;"
+ t = (int(age),)
+ out =''
+ out = 'These people died at age ' +str(age) + ' :'
+ for row in run_query(s,t):
+ out = out +newLine
+ out = out + name_html([row[1],row[2]],newLine)
+ return out
def all_ancestors(personID,newLine):
#find parents
allAncestors.append(row[1])
trackLevel.append(level)
ancestors = newA
- if len(ancestors)>0:
- out = out+thisout
-
+ out = out+thisout
+
+ image = "<img src = ancestorGraph.py?id="+str(personID)+">"
+ out = out+newLine + image+newLine
return [out, allAncestors,trackLevel]
+" WHERE id=?"
out = out + newLine + 'Most Recent Common Ancestors:' + newLine
+ mrca = []
for a in indexA:
t = (common[a],)
+ mrca.append(common[a])
out = out + print_tagged_query('',s,t,newLine)
if a!=indexA[-1]:
out = out + 'and' + newLine
related = relationship(al,bl,names)
out = out+newLine + related
+
+ image = "<img src = jointAncestorGraph.py?id="+str(IDA)\
+ +"&id2="+str(IDB) + "&LA=" + str(min(aLevels)) \
+ +"&LB=" + str(min(bLevels))+">"
+
+
+
+ out = out+newLine + image+newLine
+
return [out,common,related]
def relationship(level1, level2,names):
for row in run_query(s,t):
output = output + 'ID: '+str(row[0]) +newLine
output = output + print_tagged_name('Name',[row[1], row[0]],newLine) +newLine
+ name = row[1]
output = output + 'Born: '+row[3] + newLine
bornYear = row[4]
- output = output + 'Died: '+row[5] + newLine
+ output = output + 'Died: '+row[5] + ", aged " \
+ +str(row[6]-row[4]) +newLine
s = "SELECT * FROM styles WHERE ID = ?"
for row in run_query(s,t):
+" parents LEFT JOIN people"\
+" ON parents.parentID = people.ID"\
+" WHERE parents.ID = ?"
+
+ parents =[]
for row in run_query(s,t):
output = output + print_tagged_name('Parent',row,newLine)
+ if row[0]!=None:
+ parents.append(row[0] + ' ' + row[1])
+ else:
+ parents.append(row[1] + ' p' + personID)
#find spouses
s = "SELECT people.NAME, marriages.IDb from"\
+" marriages LEFT JOIN people"\
+" ON people.ID = marriages.IDb"\
- +" WHERE marriages.IDa = ?"
+ +" WHERE marriages.IDa = ?"\
+ +" ORDER BY IDb;"
+ spouses = []
for row in run_query(s,t):
+ if row[0]!=None:
+ spouses.append(row[0] + ' '+str(row[1]))
+ else:
+ spouses.append(row[1] + ' s' + personID)
output = output + newLine
output = output + print_tagged_name('Spouse',row,newLine)
output = output + relationship_html(personID,row[1],newLine)
s = "SELECT people.NAME, marriages.IDa from"\
+" marriages LEFT JOIN people"\
+" ON people.ID = marriages.IDa"\
- +" WHERE marriages.IDb = ?"
+ +" WHERE marriages.IDb = ?"\
+ +" ORDER BY IDa;"
for row in run_query(s,t):
+ if row[0]!=None:
+ spouses.append(row[0] + ' '+str(row[1]))
+ else:
+ spouses.append(row[1] + ' s' + personID)
output = output + newLine
output = output + print_tagged_name('Spouse',row,newLine)
output = output + relationship_html(personID,row[1],newLine)
+" WHERE parents.parentID = ?"\
+" ORDER BY people.bornYear;"
+ children = []
+ ops =[]
for row in run_query(s,t):
output = output + print_tagged_name('Child',row,newLine)
-
+ children.append(row[0] + ' ' + str(row[1]))
+
#find children's other parent
u = "Select people.NAME, parents.parentID FROM"\
- +" parents LEFT JOIN people"\
+ +" parents INNER JOIN people"\
+" ON people.ID = parents.parentID"\
- +" WHERE parents.ID = ? AND parents.parentID <> ?"
+ +" WHERE parents.ID = ? AND parents.parentID <>?;"
ids = (row[1],t[0])
+ op = 0
for r in run_query(u,ids):
output = output + print_tagged_name('With',r,newLine)
+ op = 1
+ ops.append(r[0] + ' ' + str(r[1]))
+ if op==0:
+ ops.append('?' + ' s' + personID)
#age when child born
if row[2] !=0 and bornYear != 0:
age = row[2]-bornYear
output = output[:-4] + " at the age of "+str(age) + newLine
- output = output + newLine
+
+ Self = name +' ' + str(personID)
+
+ image = "smallGraph.py?Self="+Self
+ for p in parents:
+ image = image + '&p='+p
+ for c in children:
+ image = image + '&c='+c
+ for op in ops:
+ if op !=None:
+ image = image + '&op='+op
+ for s in spouses:
+ if s !=None:
+ image = image + '&s='+str(s)
+
+ image = image.replace(' ','%20')
+ image ="<img src ="+ image + '>'
+
+
+ output = newLine+ output+ image+newLine
+
+
return output
Alfred the Great\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Alfred_the_Great\r
\r
Born:\r
849\r
Edward the Elder\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Edward_the_Elder\r
\r
Born:\r
874-877\r
Aethelstan\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/%C3%86thelstan\r
\r
Born:\r
893-895\r
Edmund I\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Edmund_I\r
\r
Born:\r
921\r
Eadred\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Eadred\r
\r
Born:\r
?\r
Eadwig (Edwy)\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Eadwig\r
\r
Born:\r
941?\r
Edgar the Peaceful\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Edgar_the_Peaceful\r
\r
Born:\r
-07/28/943\r
+07/08/943\r
Died:\r
08/07/975\r
\r
Edward the Martyr\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Edward_the_Martyr\r
\r
Born:\r
962\r
Aethelred the Unready\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/%C3%86thelred_the_Unready\r
\r
Born:\r
966-968\r
Sweyn Forkbeard\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Sweyn_Forkbeard\r
\r
Born:\r
960\r
Edmund Ironside\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Edmund_Ironside\r
\r
Born:\r
989\r
Cnut\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Cnut_the_Great\r
\r
Born:\r
985\r
Harold I Harefoot\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Harold_Harefoot\r
\r
Born:\r
c1015\r
Harthacnut\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Harthacnut\r
\r
Born:\r
c1018\r
Edward the Confessor\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Edward_the_Confessor\r
\r
Born:\r
C1003-1005\r
Harold II Godwinson\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Harold_Godwinson\r
\r
Born:\r
c1022\r
William I the Conqueror\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/William_the_Conqueror\r
\r
Born:\r
c1028\r
William II\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/William_II_of_England\r
\r
Born:\r
c1056\r
Henry I Beuclerc\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Henry_I_of_England\r
\r
Born:\r
1068\r
Stephen\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Stephen_of_England\r
\r
Born:\r
C1092-1096\r
Matilda\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Empress_Matilda\r
\r
Born:\r
07/02/1102\r
Henry II Plantagenet\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Henry_II_of_England\r
\r
Born:\r
05/03/1133\r
Henry the young king\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Henry_the_Young_King\r
\r
Born:\r
28/02/1155\r
Richard I Lionheart\r
\r
URL:\r
-.\r
+http://en.wikipedia.org/wiki/Richard_I_of_England\r
\r
Born:\r
08/09/1157\r
Father:\r
208\r
Mother:\r
-209\r
+211\r
\r
Spouses:\r
27\r
Born:\r
11/06/1456\r
Died:\r
-06/031485\r
+06/03/1485\r
\r
Father:\r
236\r
Born:\r
21/05/1527\r
Died:\r
-1309/1598\r
+13/09/1598\r
\r
Father:\r
257\r
Style:\r
Count of Blois\r
Territories:\r
-1089\r
+Blois\r
\r
From:\r
-19/05/1102\r
+1089\r
To:\r
-Count of Chartres\r
+19/05/1102\r
\r
Style:\r
-Chartres\r
+Count of Chartres\r
Territories:\r
-?\r
+Chartres\r
\r
From:\r
?\r
To:\r
-\r
+?\r
\r
\r
\r
.\r
\r
Born:\r
-1403?\r
+1430?\r
Died:\r
01-03/11/1456\r
\r
Born:\r
1373\r
Died:\r
-21/04/10\r
+21/04/1410\r
\r
Father:\r
134\r
Mother:\r
-Jatherine Swynford\r
+Katherine Swynford\r
\r
Spouses:\r
Margaret Holland\r
120\r
\r
Spouses:\r
-163\r
+227\r
\r
Style:\r
Duke of Kent and Strathearn\r
.\r
\r
Born:\r
-972\r
+?\r
Died:\r
-992\r
+992-994\r
\r
Father:\r
Gunnar or Oslac\r
Father:\r
Siemomyst\r
Mother:\r
-173\r
+?\r
\r
Spouses:\r
-73\r
+173\r
\r
Style:\r
Duke of Poland\r
Born:\r
1099\r
Died:\r
-09/04/37\r
+19/04/1137\r
\r
Father:\r
William IX\r
Style:\r
Earl of Gloucester\r
Territories:\r
-1213\r
+Gloucester\r
\r
From:\r
-1216\r
+1213\r
To:\r
-\r
+1216\r
\r
\r
\r
Born:\r
13/05/1254\r
Died:\r
-12/01/132\r
+12/01/1321\r
\r
Father:\r
Henry III Duke of Brabant\r
.\r
\r
Born:\r
-1415/1416\r
+1415-1416\r
Died:\r
30/05/1472\r
\r
02/03/1502\r
\r
Father:\r
-103\r
+37\r
Mother:\r
-104\r
+103\r
\r
Spouses:\r
-37\r
+104\r
\r
Style:\r
Print of Wales, Earl of Chester, Duke of Cornwall\r
.\r
\r
Born:\r
-c1523\r
+c1478\r
Died:\r
-13/02/1542\r
+19/03/1539\r
\r
Father:\r
Thomas Howard\r
280\r
\r
Name:\r
-Luise Eleonor of Hohenlohe-Langenburg\r
+Luise Eleonore of Hohenlohe-Langenburg\r
\r
URL:\r
.\r