except ValueError:
return 0
-def print_relation(relationship,s,t,newLine):
+def print_tagged_query(relationship,s,t,newLine):
mine = ''
for row in run_query(s,t):
- mine = mine + print_none_value(relationship,row,newLine)
+ mine = mine + print_tagged_name(relationship,row,newLine)
return mine
+def base_url():
+ return "http://www.chiark.greenend.org.uk/ucgi/~naath/"
+
def relationship_html(ID,ID2,newLine):
if newLine=='<br>':
relationship = common_ancestors(ID,ID2,newLine)[2]
- url="http://www.chiark.greenend.org.uk/ucgi/~naath/ancestors.py?ID="+ID+"&ID2="\
+ url=base_url()+"ancestors.py?ID="+ID+"&ID2="\
+str(ID2)
return relationship + ':<a href='+url+'> Common Ancestors</a>'+newLine
else:
def terr_html(terr,newLine):
if newLine=='<br>':
- url = "http://www.chiark.greenend.org.uk/ucgi/~naath/territory.py?terr="
+ url = base_url()+"territory.py?terr="
return '<a href ='+url + terr+'>'+terr+'</a>'
else:
return terr
-def row_html(row,html):
+def name_html(row,html):
+ if html=='<br>':
+ html=1
+ elif html=='\n':
+ html=0
if html == 1:
- url = "http://www.chiark.greenend.org.uk/ucgi/~naath/person.py?ID=" + str(row[1])
+ url = base_url()+"person.py?ID=" + str(row[1])
name = row[0]
- return "<a href = "+url+">"+name+"</a>"
+ return "<a href = "+url+">"+str(name)+"</a>"
if row[0] == None:
return row[1]
else:
return row[0] + "," +str(row[1])
-def print_none_value(relationship,row,newLine):
+def print_tagged_name(relationship,row,newLine):
if row[0]==None:
out = relationship + " not yet entered: " + row[1]
else:
else:
html=0
if relationship =='':
- out = row_html(row,html) + ' '
+ out = name_html(row,html) + ' '
else:
- out = relationship + ": " + row_html(row,html)
+ out = relationship + ": " + name_html(row,html)
return out + newLine
def list_territories(newLine):
out = out + ' century:' + newLine
- out = out + print_none_value('',row,newLine)
+ out = out + name_html(row,newLine) +newLine
year = row[2]
return out
out = "Ancestors of "
for row in run_query(t,id):
- out = out + print_none_value('',row,newLine)
+ out = out + name_html(row,newLine)+newLine
while len(ancestors)>0:
level = level+1
for ancestor in ancestors:
id = (ancestor,)
for row in run_query(s,id):
- out = out + print_none_value('',row,newLine)
+ out = out + name_html(row,newLine)+newLine
if row[1] not in allAncestors and is_number(row[1])!=0:
newA.append(row[1])
allAncestors.append(row[1])
for id in (IDA,IDB):
t = (id,)
for row in run_query(s,t):
- out = out + print_none_value('',row,newLine)
+ out = out + name_html(row,newLine)+newLine
names.append(row[0])
if id==IDA:
out = out + 'and'
return [out, common,related]
- out = out + print_relation('',s,common,newLine)
+ out = out + print_tagged_query('',s,common,newLine)
indexA=[]
indexB=[]
out = out + newLine + 'Most Recent Common Ancestors:' + newLine
for a in indexA:
t = (common[a],)
- out = out + print_relation('',s,t,newLine)
+ out = out + print_tagged_query('',s,t,newLine)
if a!=indexA[-1]:
out = out + 'and' + newLine
if len(indexA) >1:
out = out + 's'
- out = out + ' of ' + print_none_value('',[names[0],IDA],newLine)
+ out = out + ' of ' + name_html([names[0],IDA],newLine)+newLine
out = out + newLine
for b in indexB:
t = (common[b],)
- out = out + print_relation('',s,t,newLine)
+ out = out + print_tagged_query('',s,t,newLine)
if b!=indexB[-1]:
out = out + 'and' + newLine
out = out + parent_level(bLevels[indexB[0]])
if len(indexB)>1:
out = out + 's'
- out = out + ' of ' + print_none_value('',[names[1],IDB],newLine)
+ out = out + ' of ' + name_html([names[1],IDB],newLine)+newLine
al = aLevels[indexA[0]]
out = out + 'Rulers of '+terr_html(last,newLine) +':'+ newLine +thisT +newLine
thisT = ''
- thisT = thisT +print_none_value('',row,newLine)
- thisT = thisT[:-4] + ' from ' + str(row[2])+' to '+str(row[3]) + newLine
+ thisT = thisT +name_html(row,newLine)
+ thisT = thisT +' from ' + str(row[2])+' to '+str(row[3]) + newLine
last = row[4]
out = out + 'Rulers of '+terr_html(row[4],newLine) +':'+ newLine +thisT
s = "SELECT * FROM people WHERE ID = ?"
for row in run_query(s,t):
output = output + 'ID: '+str(row[0]) +newLine
- output = output + 'Name: '+print_none_value('',[row[1], row[0]],newLine) +newLine
+ output = output + print_tagged_name('Name',[row[1], row[0]],newLine) +newLine
output = output + 'Born: '+row[3] + newLine
output = output + 'Died: '+row[5] + newLine
+" ON parents.parentID = people.ID"\
+" WHERE parents.ID = ?"
for row in run_query(s,t):
- output = output + print_none_value('Parent',row,newLine)
+ output = output + print_tagged_name('Parent',row,newLine)
#find spouses
s = "SELECT people.NAME, marriages.IDb from"\
+" WHERE marriages.IDa = ?"
for row in run_query(s,t):
output = output + newLine
- output = output + print_none_value('Spouse',row,newLine)
+ output = output + print_tagged_name('Spouse',row,newLine)
output = output + relationship_html(personID,row[1],newLine)
s = "SELECT people.NAME, marriages.IDa from"\
+" WHERE marriages.IDb = ?"
for row in run_query(s,t):
output = output + newLine
- output = output + print_none_value('Spouse',row,newLine)
+ output = output + print_tagged_name('Spouse',row,newLine)
output = output + relationship_html(personID,row[1],newLine)
output = output + newLine
+" WHERE parents.parentID = ?"
for row in run_query(s,t):
- output = output + print_none_value('Child',row,newLine)
+ output = output + print_tagged_name('Child',row,newLine)
#find children's other parent
u = "Select people.NAME, parents.parentID FROM"\
ids = (row[1],t[0])
for row in run_query(u,ids):
- output = output + print_none_value('With',row,newLine)
+ output = output + print_tagged_name('With',row,newLine)
output = output + newLine