def relationship_html(ID,ID2,newLine):
if newLine=='<br>':
relationship = common_ancestors(ID,ID2,newLine)[2]
- script = "ancestors.py?ID="+ID+"&ID2="+str(ID2)
- return link_Template.substitute(script = script,text = "Common ancestors")
+ script = "ancestors.py?ID="+str(ID)+"&ID2="+str(ID2)
+ url = link_Template.substitute(script = script,text = "Common ancestors")
+ return relationship + ' '+url + newLine
else:
return ''
out = relationship + ": " + name_html(row,html)
return out + newLine
+
+def ordinal_numbers(number):
+ out = str(number)
+ if number==1:
+ out = out +'st'
+ elif number==2:
+ out = out +'nd'
+ elif number==3:
+ out = out +'rd'
+ else:
+ out = out +'th'
+ return out
+
def list_territories(newLine):
s = "SELECT DISTINCT territory"\
+" FROM territories"\
if row[2]/100!=year/100:
century = row[2]/100 + 1
- out = out +newLine+ 'born in ' + str(century)
+ out = out +newLine+ 'born in '
- if century==21:
- out = out + 'st'
- elif century==2:
- out = out + 'nd'
- else:
- out = out + 'th'
-
- out = out + ' century:' + newLine
+ out = out +ordinal_numbers(century) + ' century:' + newLine
out = out + name_html(row,newLine) +newLine
year = row[2]
while len(ancestors)>0:
level = level+1
newA =[]
- out = out+newLine + parent_level(level) +':' + newLine
+ out = out+newLine + parent_level(level,'parent') +':' + newLine
for ancestor in ancestors:
id = (ancestor,)
for row in run_query(s,id):
if a!=indexA[-1]:
out = out + 'and' + newLine
- out = out + parent_level(aLevels[indexA[0]])
+ out = out + parent_level(aLevels[indexA[0]],'parent')
if len(indexA) >1:
out = out + 's'
if b!=indexB[-1]:
out = out + 'and' + newLine
- out = out + parent_level(bLevels[indexB[0]])
+ out = out + parent_level(bLevels[indexB[0]],'parent')
if len(indexB)>1:
out = out + 's'
out = out + ' of ' + name_html([names[1],IDB],newLine)+newLine
if level1==0 and level2==0:
return names[0] + ' is ' +names[1]
if level1==0:
- return names[0] + ' is ' + names[1] + '\'s '+ parent_level(level2)
+ return names[0] + ' is ' + names[1] + '\'s '+ parent_level(level2,'parent')
if level2==0:
- return names[1] + ' is ' + names[0] + '\'s '+ parent_level(level1)
+ return names[1] + ' is ' + names[0] + '\'s '+ parent_level(level1,'parent')
- if level1==level2:
- remove = 0
- if level1==1:
- return names[0] +' and '+names[1] +' are '+' siblings'
- else:
- cousinNum = level1-1
- if level1>level2:
+ if level1>=level2:
remove = level1-level2
cousinNum = level2-1
else:
cousinNum = level1-1
if cousinNum==0:
- if level1< level2:
- return names[0] + ' is ' + names[1] + '\'s uncle or aunt'
+ uaLevel = parent_level(remove,'uncle or aunt')
+ if level1<= level2:
+ return names[0] + ' is ' + names[1] + '\'s ' + uaLevel
if level2<level1:
- return names[1] + ' is ' + names[0] + '\'s uncle or aunt'
-
- if cousinNum ==1:
- c = '1st'
- elif cousinNum==2:
- c = '2nd'
- elif cousinNum==3:
- c = '3rd'
- else:
- c = str(cousinNum)+'th'
+ return names[1] + ' is ' + names[0] + '\'s ' + uaLevel
+ c=ordinal_numbers(cousinNum)
if remove == 1:
rem = 'once'
elif remove ==2:
return r
-def parent_level(level):
+def parent_level(level,type):
if level == 0:
- return 'self'
- out = 'parent'
+ if type=='parent':
+ return 'self'
+ else:
+ return 'sibling'
+ out = type
if level ==1:
return out
out = 'grand '+out