chiark / gitweb /
Change a = a+ to a+= and used better string formatting
[familyTree.git] / familyTree / askQuestion.py
index d0380d734cbf9bcc435130f860f536d2ba6b3deb..8dbe0b1eabc81c58f98d77c3de4fce0b63e749c8 100755 (executable)
@@ -49,7 +49,7 @@ def relationship_html(ID,ID2,newLine):
                relationship = common_ancestors(ID,ID2,newLine)[2]
                        
                if relationship[-11:] != 'not related':
-                       script = "ancestors.py?ID="+str(ID)+"&ID2="+str(ID2)
+                       script = "ancestors.py?ID=%s&ID2=%s" % (ID,ID2)
                        url = link_Template.substitute\
                                (script = script,title = "Common ancestors"\
                                        ,text = "Common ancestors")
@@ -74,8 +74,8 @@ def terr_html(terr,newLine,start,stop):
                        t = (terr,start)
                        myTitle = ''
                        for row in run_query(s,t):
-                               myTitle = myTitle +"previous - " + row[0] \
-                               + ',' + str(row[1])
+                               myTitle += "previous - %s,%s" \
+                               % (row[0],row[1])
                                break
 
                        u = "SELECT name,people.id"\
@@ -86,8 +86,8 @@ def terr_html(terr,newLine,start,stop):
                
                        v = (terr,stop)
                         for r in run_query(u,v):
-                               myTitle = myTitle + '&#xA' +"next - " + r[0] \
-                                + ',' + str(r[1])
+                               myTitle += '&#xA next - %s,%s'\
+                               %(r[0],r[1])
                                 break
 
                        myTitle = add_quotes(myTitle)
@@ -109,59 +109,59 @@ def name_html(row,html):
                return row[0]
        else:
                if html==1:
-                       script = "person.py?ID=" + str(row[1])
+                       script = "person.py?ID=%s" %(row[1])
                        name = row[0]
                        return link_Template.substitute(script = script\
                                ,title = add_quotes(name),text = name)
                else:
-                       return row[0] + "," +str(row[1])
+                       return "%s,%s" % (row[0],row[1])
 
 def print_people(n):
        if n>1:
-               return ' people '
+               return 'people'
        else:
-               return ' person '
+               return 'person'
+def print_children(n):
+       if n>1:
+               return 'children'
+       else:   
+               return 'child'
 
 def print_age_child_count(row,newLine):
        if newLine == '<br>':
-               script = "listAge.py?age="+str(row[0])
+               script = "listAge.py?age=%s" % (row[0])
                link = link_Template.substitute(script = \
                        script, title = add_quotes(row[0]), text = row[0])
-               out = str(row[1])+print_people(row[1])
 
-               out = out + 'had children at age '+ link + newLine
+               out = '%s %s had children at age %s %s'\
+                % (row[1],print_people(row[1]),link,newLine)
                return out
        else:
                return print_row(row,newLine)
 
 def print_age_death_count(row,newLine):
        if newLine =='<br>':
-               script = "listAgeDeath.py?age="+str(row[0])
+               script = "listAgeDeath.py?age=%s" % (row[0])
                link = link_Template.substitute(script = script,\
                        title = add_quotes(row[0]),text = row[0])
-               out = str(row[1])+print_people(row[1])
-               out = out + "died at age " + link + newLine
+               out = "%s %s died at age %s %s " \
+                       %(row[1],print_people(row[1]), link,newLine)
                return out
        else:
                return print_row(row,newLine)
 
 def print_name_count(row,newLine):
        if newLine=='<br>':
-               script = "name.py?name=" + row[0]
+               script = "name.py?name=%s" % (row[0])
                link = link_Template.substitute(script =\
                        script, title = add_quotes(row[0]),text = row[0])
-               return str(row[1]) + " people called "+link + newLine
+               return "%s people called %s%s"\
+                       %(row[1],link, newLine)
        else:
                return print_row(row,newLine)   
 
 def print_children_count(row,newLine):
-       out = str(row[0])
-
-       if row[0]==1:
-               out = out + ' person '
-       else:
-               out = out + ' people '
-       out = out +'had ' 
+       out = "%s %s had " % (row[0],print_people(row[0]))
 
        if newLine == '<br>':
                script = "listChildCount.py?nc="+str(row[1])
@@ -170,30 +170,24 @@ def print_children_count(row,newLine):
        else:
                link = str(row[1])
 
-       out = out + link
-
-       if row[1] == 1:
-               out = out  + ' child '
-       else:
-               out = out + ' children '
-
-
-       out  = out  + newLine
+       out += "%s %s %s" % (link,print_children(row[1]),newLine)
 
        return out
 
 def print_tagged_name(relationship,row,newLine):
        if row[0]==None:
                        out = relationship + " not yet entered: " + row[1]
+               out = "%s not yet entered: %s" % (relationship,row[1])
                else:
                if newLine == '<br>':
                        html = 1
                else:
                        html=0
                if relationship =='':
-                       out = name_html(row,html) + '   '
+                       out = '%s   ' % (name_html(row,html))
                else:
                        out = relationship + ": " + name_html(row,html)
+                       out = '%s: %s' % (relationship,name_html(row,html))
        return out + newLine
 
 def month_numbers(monthN):
@@ -229,14 +223,15 @@ def month_numbers(monthN):
 
 def ordinal_numbers(number):
        number = int(number)
+       out = '%d' % (number)
        if number % 10==1 and number/10 % 10 !=1:
-               out = str(number) +'st'
+               out +='st'
        elif number % 10==2 and number/10 % 10 !=1:
-               out = str(number) +'nd'
+               out +='nd'
        elif number % 10==3 and number/10 % 10 !=1:
-               out = str(number) +'rd'
+               out +='rd'
        else:
-               out = str(number) +'th'
+               out +='th'
        return out
 
 def list_territories(newLine):
@@ -246,7 +241,7 @@ def list_territories(newLine):
 
        out = ''
        for row in run_query(s,()):
-               out =out + terr_html(row[0],newLine,0,0) +newLine
+               out += terr_html(row[0],newLine,0,0) +newLine
        return out
 
 def list_people_parents():
@@ -276,16 +271,15 @@ def list_people(newLine):
        out = out + 'born in unknown year:' +newLine
        for row in run_query(s,()):
                if row[2]!=0 and row[2]/100==0:
-                       out = out +newLine+ 'born in 1st century:' +newLine
+                       out +='%sborn in 1st century:%s' % (newLine,newLine)
 
                if row[2]/100!=year/100:
                        century = row[2]/100 + 1
-                       out = out +newLine+ 'born in ' 
+                       out +='%sborn in %s century: %s'\
+                        %(newLine,ordinal_numbers(century),newLine)
 
-                       out = out +ordinal_numbers(century) \
-                               + ' century:' + newLine
 
-               out = out + name_html(row,newLine) +newLine
+               out+= name_html(row,newLine) +newLine
 
                if row[2] == 0: #unknown year
 
@@ -296,12 +290,13 @@ def list_people(newLine):
                        u = "SELECT diedyear FROM people WHERE ID = ?;"
 
                        bornAfter = 0
+                       bornBefore = 0
                        for r in run_query(u,t):
                                if r[0] !=0:
-                                       out = out + "died: "\
-                                        + str(r[0]) + newLine
                                        bornAfter = r[0] -100
-
+                                       bornBefore = r[0]
+                                       out += "Died: %s %s"\
+                                       %(r[0],newLine)
                        #find children
                        u = "Select people.bornYear from"\
                                +" people INNER JOIN parents"\
@@ -315,13 +310,11 @@ def list_people(newLine):
                                if r[0] != 0:
                                        hadChild.append(r[0])
                        
-                       bornBefore = 0
                        if len(hadChild)!=0:
-                               out = out + "had children in: "
+                               out += "had children in: "
                                for c in hadChild:
-                                       out = out + str(c) + ','
+                                       out+= '%s,' % (c)
                                out = out[:-1] + newLine
-
                                bornBefore = hadChild[0]-12
                                if bornAfter==0:
                                        bornAfter = hadChild[0]-100
@@ -334,20 +327,19 @@ def list_people(newLine):
                                 +" ORDER BY styles.startYear;"
 
                         for r in run_query(u,t):
-                                out = out + r[1] + " from " + str(r[0])\
-                                + newLine
+                               out += "%s from %s %s"\
+                                       %(r[1],r[0],newLine)
                                if bornAfter ==0:
                                        bornAfter = r[0] -100
                                 break
 
                        if bornAfter!=0:
                                if bornBefore == 0: 
-                                       out = out + "probably born "\
-                                               +"after " + str(bornAfter)
+                                       out += "probably born after %s"\
+                                               %(bornAfter)
                                else:
-                                       out = out + "probably born "\
-                                               +"betwen " + str(bornAfter)\
-                                               +" and " + str(bornBefore)
+                                       out +="probably born between %s and %s"\
+                                               %(bornAfter, bornBefore)
                                out = out + newLine
 
                year = row[2]
@@ -361,7 +353,7 @@ def count_names(newLine):
 
        out = ''
        for row in run_query(s,()):
-               out = out + print_name_count(row,newLine)
+               out += print_name_count(row,newLine)
 
        return out
 
@@ -380,7 +372,7 @@ def count_children(newLine):
 
        out = ''
        for row in run_query(s,()):
-               out = out + print_children_count(row,newLine)
+               out += print_children_count(row,newLine)
        return out
 
 def parents_with_children(nChildren,newLine):
@@ -400,21 +392,15 @@ def parents_with_children(nChildren,newLine):
        +" WHERE parentID = ?"\
        +" AND (diedyear-bornyear>? OR died='present');"
 
-       out = "People who had " + str(nChildren)
-       if nChildren==1:
-               out = out + " child"
-       else:
-               out = out  + " children"
-       out = out + ':' + newLine
-
-
+       out = "People who had %s %s:%s" \
+               %(nChildren,print_children(nChildren),newLine)
 
        for row in run_query(s,(nChildren,)):
-               out = out + name_html(row,newLine)
+               out += name_html(row,newLine)
                for r in run_query(u,(row[1],1)):       
                        out += " %d  survived infancy" % r[0]
                for r in run_query(u,(row[1],18)):
-                       out = out +" and " +str(r[0])+" survived to adulthood"
+                       out += " and %s survived to adulthood" % r[0]
                out = out +newLine
        
        return out
@@ -424,24 +410,23 @@ def search_name(name,newLine):
         +" FROM people"\
         +" WHERE name LIKE ?;"
 
-        out = ''
        IDs=[]
        names=[]
 
-       out = out + 'Names starting with ' + name + ':' + newLine
+       out = 'Names starting with %s:%s' % (name,newLine)
        t = (name + '%',)
        fullIDs=[]
        for row in run_query(s,t):
-                out = out + name_html(row,newLine) + newLine
+                out += name_html(row,newLine) + newLine
                fullIDs.append(row[1])
                names.append(row[0])
                IDs.append(row[1])
 
         t = ('%' + name + '%',)
-       out = out+newLine + 'Names containing ' + name + ':' + newLine
+       out += '%sNames containing %s:%s' %(newLine,name,newLine)
         for row in run_query(s,t):
                if row[1] not in fullIDs:
-                       out = out + name_html(row,newLine) + newLine
+                       out += name_html(row,newLine) + newLine
                        names.append(row[0])
                        IDs.append(row[1])
        
@@ -449,10 +434,9 @@ def search_name(name,newLine):
        +" FROM people INNER JOIN styles"\
        +" ON styles.id = people.id"\
        +" WHERE style LIKE ?;"
-       out = out +newLine+ 'Styles containing ' + name + ':' + newLine
+       out += '%sStyles containing %s:%s' %(newLine,name,newLine)
        for row in run_query(s,t):
-               out = out + name_html(row,newLine)+' ' + row[2] + newLine
-
+               out +="%s %s %s" %(name_html(row,newLine),row[2],newLine)
         return [out,names,IDs]
 
 
@@ -466,7 +450,7 @@ def people_with_name(name,newLine):
        t = (name,)
 
        for row in run_query(s,t):
-               out = out + name_html(row,newLine) + newLine
+               out += name_html(row,newLine) + newLine
 
        return out
 
@@ -481,11 +465,11 @@ def count_birth_month(newLine):
        out = ''
        for row in run_query(s,()):
                month = month_numbers(row[0])
-               out = out + month + ': ' + str(row[1]) + newLine
+               out += "%s:%s%s" %( month,row[1],newLine)
 
                if row[0]>12:
                        u = (row[0],)
-                       out =  out +print_query(t,u,newLine)
+                       out +=print_query(t,u,newLine)
                
        return out
 
@@ -500,11 +484,11 @@ def count_death_month(newLine):
         out = ''
         for row in run_query(s,()):
                 month = month_numbers(row[0])
-                out = out + month + ': ' + str(row[1]) + newLine
+                out += '%s:%s%s'%(month,row[1], newLine)
 
                if row[0]>12:
                         u = (row[0],)
-                        out =  out +print_query(t,u,newLine)
+                        out +=print_query(t,u,newLine)
 
         return out
 
@@ -521,7 +505,7 @@ def count_age_at_child(newLine):
 
        out = ''
        for row in run_query(s,()):
-               out = out + print_age_child_count(row,newLine)
+               out +=print_age_child_count(row,newLine)
 
        return out
 
@@ -540,10 +524,9 @@ def people_had_child_at_age(age,newLine):
        out = ''
        out = 'At age ' + str(age) + ' :'
        for row in run_query(s,t):
-               out = out + newLine
-               out =out + name_html([row[3],row[4]],newLine) + ' had '\
-                       +name_html([row[1],row[2]],newLine)
-
+               parent = name_html([row[3],row[4]],newLine)
+               child = name_html([row[1],row[2]],newLine)
+               out += "%s%s had %s" % (newLine,parent,child)
        return out
 
 def count_age_at_death(newLine):
@@ -553,7 +536,7 @@ def count_age_at_death(newLine):
                +" GROUP BY age;"
        out=''
        for row in run_query(s,()):
-               out = out + print_age_death_count(row,newLine)
+               out += print_age_death_count(row,newLine)
 
        return out
 
@@ -565,8 +548,7 @@ def people_died_at_age(age,newLine):
        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)
+               out += newLine+ name_html([row[1],row[2]],newLine)
        return out
 
 def all_ancestors(personID,newLine):
@@ -582,20 +564,20 @@ def all_ancestors(personID,newLine):
 
        out = "Ancestors of "
        for row in run_query(t,id):
-               out = out + name_html(row,newLine)+newLine
+               out += name_html(row,newLine)+newLine
 
        while len(ancestors)>0:
                level = level+1
                newA =[]
-               thisout = newLine + parent_level(level,'parent') +\
-                       ':' + newLine
+               thisout = "%s %s:%s" \
+               % (newLine,parent_level(level,'parent'),newLine)
+
                for ancestor in ancestors:
                        [parents, parentIDs,parentNames] \
                                = find_parents(ancestor)
                        for i in range(len(parents)):
                                r = [parentNames[i],parentIDs[i]]
-                               thisout = thisout + \
-                               name_html(r,newLine)+newLine
+                               thisout +=name_html(r,newLine)+newLine
                                
                                if r[1] not in allAncestors\
                                and r[1]!=0:
@@ -604,11 +586,11 @@ def all_ancestors(personID,newLine):
                                        trackLevel.append(level)
                                
                ancestors = newA
-               out  = out+thisout
+               out  +=thisout
 
 
-       image = "<img src = ancestorGraph.py?id="+str(personID)+">"
-       out = out+newLine + image+newLine
+       image = "<img src = ancestorGraph.py?id=%s>" %personID
+       out +=newLine + image+newLine
        return [out, allAncestors,trackLevel]
 
 
@@ -622,15 +604,15 @@ def common_ancestors(IDA, IDB,newLine):
        for id in (IDA,IDB):
                t = (id,)
                for row in run_query(s,t):
-                       out = out + name_html(row,newLine)+newLine
+                       out += name_html(row,newLine)+newLine
                        names.append(row[0])
                if id==IDA:
-                       out = out + 'and'
+                       out += 'and'
                out = out + newLine
 
        if len(names)!=2:
                related = 'No details held on one party'
-               out = out + related
+               out += related
                return [out,[],related]
        
 
@@ -656,19 +638,19 @@ def common_ancestors(IDA, IDB,newLine):
        +" FROM people"\
        +" WHERE ID IN ("
        for i in range(len(common)):
-               s = s+ "?,"
+               s += "?,"
        if len(common)>0:
                s = s[:-1]
        s = s+") ORDER BY bornyear;"
 
 
        if len(common)==0:
-               related = names[0]+' and '+names[1]+' are not related'
+               related = '%s and %s are not related' %(names[0], names[1])
                out = out + newLine + related
                return [out, common,related]
 
 
-       out = out + print_tagged_query('',s,common,newLine)
+       out += print_tagged_query('',s,common,newLine)
 
        indexA=[]
        indexB=[]
@@ -685,52 +667,57 @@ def common_ancestors(IDA, IDB,newLine):
        +" FROM people"\
        +" WHERE id=?"
 
-       out  = out + newLine + 'Most Recent Common Ancestors:' + newLine
+       out  += '%sMost Recent Common Ancestors:%s' %(newLine,newLine)
        mrca = []
        for a in indexA:
                t = (common[a],)
                mrca.append(common[a])
-               out = out + print_tagged_query('',s,t,newLine)
+               out += print_tagged_query('',s,t,newLine)
                if a!=indexA[-1]:
-                       out = out + 'and' + newLine
+                       out += 'and' + newLine
 
-       out = out + parent_level(aLevels[indexA[0]],'parent')
+       out += parent_level(aLevels[indexA[0]],'parent')
        if len(indexA) >1:
-               out = out + 's'
+               out += 's'
 
-       out = out + ' of ' + name_html([names[0],IDA],newLine)+newLine
+       out +=' of %s%s'%( name_html([names[0],IDA],newLine),newLine)
 
-       out = out + parent_level(bLevels[indexB[0]],'parent')
+       out += parent_level(bLevels[indexB[0]],'parent')
        if len(indexB)>1:
-               out = out + 's'
-       out = out + ' of ' + name_html([names[1],IDB],newLine)+newLine
+               out += 's'
+       out += ' of %s%s' %(name_html([names[1],IDB],newLine),newLine)
 
 
        al = aLevels[indexA[0]]
        bl = bLevels[indexB[0]]
 
        related = relationship(al,bl,names)
-       out = out+newLine + related
+       out +=newLine + related
 
 
        image = "<img src = jointAncestorGraph.py?id="+str(IDA)\
                +"&id2="+str(IDB) + "&LA=" + str(min(aLevels)) \
                +"&LB=" + str(min(bLevels))+">"
 
+       image = "<img src = jointAncestorGraph.py?id=%s&id2=%s&LA=%d&LB=%d>"\
+               %(IDA,IDB,min(aLevels),min(bLevels))
 
 
-        out = out+newLine + image+newLine
+        out +=newLine + image+newLine
 
        return [out,common,related]
 
 def relationship(level1, level2,names):
 
        if level1==0 and level2==0:
-               return names[0] + ' is ' +names[1]
+               return "%s is %s" %(names[0],names[1])
        if level1==0:
-               return names[0] + ' is ' + names[1] + '\'s '+ parent_level(level2,'parent')
+               return "%s is %s's %s" \
+                       %(names[0],names[1],parent_level(level2,'parent'))
+
        if level2==0:
-               return names[1] + ' is ' + names[0] + '\'s '+ parent_level(level1,'parent')
+               return "%s is %s's %s" \
+                       %(names[1],names[0],parent_level(level1,'parent'))
 
 
        if level1>=level2:
@@ -743,10 +730,10 @@ def relationship(level1, level2,names):
        if cousinNum==0:
                uaLevel =  parent_level(remove,'uncle or aunt')
                if level1<= level2:
-                       return names[0] + ' is ' + names[1] + '\'s ' + uaLevel
+                       return "%s is %s's %s" % (names[0],names[1],uaLevel)
 
                if level2<level1:
-                       return names[1] + ' is ' + names[0] + '\'s ' + uaLevel
+                       return "%s is %s's %s" % (names[1],names[0],uaLevel)
 
        c=ordinal_numbers(cousinNum)
        if remove == 1:
@@ -756,9 +743,9 @@ def relationship(level1, level2,names):
        else:
                rem = str(remove) + ' times'            
 
-       r = names[0] +' and '+names[1] +' are ' + c + ' cousins '
+       r = "%s and %s are %s cousins" % (names[0],names[1],c)
        if remove !=0:
-               r = r+ rem + ' removed'
+               r += ' %s removed' % rem
 
        return r
 
@@ -772,7 +759,7 @@ def parent_level(level,type):
        if level ==1:
                return out
        if type =='parent':
-               out = 'grand '+out
+               out = 'grand ' + out
        else:
                out = 'great '+out
        if level ==2:
@@ -796,16 +783,16 @@ def rulers_of(aTerritory,newLine):
        out = ''
        for row in run_query(tq,(aTerritory+'%',)):
                if row[4]!=last and last!='':
-                        out  = out + 'Rulers of '+terr_html(last,newLine,0,0) \
-                       +':'+ newLine +thisT +newLine
-                        thisT = ''
+                       out += 'Rulers of %s:%s%s%s'\
+                       %(terr_html(last,newLine,0,0),newLine,thisT,newLine)
+                       thisT = ''
 
-               thisT = thisT +name_html(row,newLine)
-               thisT = thisT +' from ' + str(row[2])+' to '+str(row[3]) + newLine
+               thisT += "%s from %s to %s%s" \
+               % (name_html(row,newLine),row[2],row[3],newLine)
                last = row[4]
 
-       out  = out + 'Rulers of '+terr_html(row[4],newLine,0,0) +':'+ \
-               newLine +thisT
+       out += 'Rulers of %s:%s%s' \
+       % (terr_html(row[4],newLine,0,0),newLine,thisT)
 
        return out      
 
@@ -948,32 +935,31 @@ def person_info(personID,newLine):
        #Id, Name, Dates, Style, Style-Dates
        s = "SELECT * FROM people WHERE ID = ?"
        for row in run_query(s,t):
-               mainDiv = mainDiv + startP
-               mainDiv = mainDiv  + 'ID: '+str(row[0]) +newLine
-               mainDiv = mainDiv + print_tagged_name('Name',[row[1], row[0]]\
+               mainDiv += startP
+               mainDiv += 'ID: %s%s' %(row[0] ,newLine)
+               mainDiv += print_tagged_name('Name',[row[1], row[0]]\
                        ,newLine)
-               mainDiv = mainDiv + endP
+               mainDiv +=endP
                name = row[1]
                url = row[9]
                picture = row[10]
 
-               mainDiv = mainDiv + startP
-               mainDiv = mainDiv + newLine + 'Born: '+row[3] + newLine
+               mainDiv += startP
+               mainDiv += '%sBorn:%s%s '% (newLine,row[3],newLine)
                bornYear = row[4]
-               mainDiv = mainDiv + 'Died: '+row[5]
+               mainDiv +='Died: %s' % row[5]
 
                if row[6] != 0 and row[4] !=0:
-                       mainDiv = mainDiv + ", aged " \
-                               +str(row[6]-row[4])
-               mainDiv = mainDiv + endP
+                       mainDiv += ", aged %s" %(row[6]-row[4])
+               mainDiv +=endP
 
 
        s = "SELECT * FROM styles WHERE ID = ?"
        for row in run_query(s,t):
-               mainDiv = mainDiv + startP
-               mainDiv = mainDiv +newLine+ 'Style: '+row[1] + newLine
+               mainDiv += startP
+               mainDiv +='%sStyle: %s%s'%(newLine,row[1],newLine)
 
-               mainDiv = mainDiv + 'Territories:' + newLine
+               mainDiv += 'Territories:%s' % newLine
 
                u = "SELECT * FROM territories"\
                +"  WHERE ID =? AND startYear =? AND stopYear=?"
@@ -981,50 +967,48 @@ def person_info(personID,newLine):
 
                any = 0
                for r in run_query(u,v):
-                       mainDiv = mainDiv \
-                       + terr_html(r[1],newLine,r[3],r[5])\
-                       +','
+                       mainDiv += terr_html(r[1],newLine,r[3],r[5]) +','
                        any = 1
                if any ==1:
                        mainDiv = mainDiv[:-1] + newLine
 
-               mainDiv = mainDiv +  'From: '+row[2] + newLine
-                mainDiv = mainDiv +  'To: '+row[4]     
+               mainDiv +=  'From: '+row[2] + newLine
+                mainDiv +=  'To: '+row[4]      
 
-               mainDiv = mainDiv + endP
+               mainDiv += endP
 
 
 
 
-       mainDiv = mainDiv + startP
+       mainDiv += startP
        s = "SELECT people.Name,consort "\
                +"FROM consorts LEFT JOIN people"\
                +" ON people.ID = consorts.consort"\
                +" WHERE consorts.ID = ?"
        for row in run_query(s,t):
-               mainDiv = mainDiv + print_tagged_name\
+               mainDiv += print_tagged_name\
                ('Consort of',row,newLine)
-       mainDiv = mainDiv + endP
+       mainDiv += endP
 
        #find parents
 
        [parents,parentIDs,parentNames] = find_parents(personID)
-       mainDiv = mainDiv + startP
+       mainDiv += startP
        for i in range(len(parents)):
                r = [parentNames[i],parentIDs[i]]
-               mainDiv = mainDiv + print_tagged_name('Parent',r,newLine)
-       mainDiv = mainDiv + endP
+               mainDiv += print_tagged_name('Parent',r,newLine)
+       mainDiv += endP
 
        #find spouses
 
        [spouses,spousesID,spousesNames] = find_spouses(personID)
 
-       mainDiv = mainDiv + startP
+       mainDiv += startP
 
        for i in range(len(spouses)):
                r = [spousesNames[i],spousesID[i]]
-               mainDiv = mainDiv + print_tagged_name('Spouse',r,newLine)
-               mainDiv = mainDiv + \
+               mainDiv += print_tagged_name('Spouse',r,newLine)
+               mainDiv += \
                relationship_html(personID,r[1],newLine)
 
        mainDiv  = mainDiv + endP
@@ -1041,9 +1025,9 @@ def person_info(personID,newLine):
                opr=[names[i][1],IDs[i][1]]
                top = names[i][1]
                if i==0 or  top != names[i-1][1]:
-                       mainDiv = mainDiv +endP
-                       mainDiv = mainDiv + startP
-                       mainDiv = mainDiv + print_tagged_name\
+                       mainDiv +=endP
+                       mainDiv += startP
+                       mainDiv += print_tagged_name\
                         ('With',opr, newLine)
 
 
@@ -1053,90 +1037,90 @@ def person_info(personID,newLine):
                        age = cb-bornYear
                        thisChild = thisChild[:-4] + \
                                " at the age of "+str(age) + newLine
-               mainDiv = mainDiv + thisChild
+               mainDiv += thisChild
        
-       mainDiv = mainDiv + endP
+       mainDiv += endP
 
 
        if newLine == '<br>':
                output = '<div id = "main" style = " float:left">';
-               output = output + mainDiv +  "</div>"
+               output += mainDiv +  "</div>"
 
-               output = output + "<div id = 'image' "\
+               output += "<div id = 'image' "\
                        +"style = 'float:left; margin-left:20px'>"
 
                imageDiv = ''
                if picture!='.':
-                       imageDiv = imageDiv + "<a href=" + url+">"\
+                       imageDiv += "<a href=" + url+">"\
                        +"<img src=" + picture +" alt = 'wiki link'"\
                        +" title = 'wiki link'></a>"\
                        + newLine
 
                elif url!='.' and url!='. ':
-                       imageDiv = imageDiv + "<a href=" + url +">"\
+                       imageDiv += "<a href=" + url +">"\
                        +name + " (wiki link)</a>"+newLine
 
-               output = output + imageDiv + "</div>"
+               output += imageDiv + "</div>"
 
 
                url = 'http://www.chiark.greenend.org.uk/ucgi/~naath/'\
                        +'smallGraph.py'
 
                form = ''
-               form = form + "<form id ='controlForm'"\
+               form += "<form id ='controlForm'"\
                +" action ="+ url +" method = 'get'>"
 
-               form = form +\
+               form +=\
                        "<input type = 'hidden' name = 'ID' value = "\
                        +personID + "><br>"
 
-                form = form +\
+                form +=\
                "Generations of Parents: "\
                +"<input type = 'text' name = 'pl' value='1'>"
-               form = form + newLine
-               form = form + \
+               form += newLine
+               form += \
                "Generations of Children: "\
                +" <input type = 'text' name = 'cl' value = '1'>"
-               form = form + newLine
-                form = form + \
+               form += newLine
+                form += \
                 "Show siblings: <select name = 's'>"+\
                 "<option value = '0'>No</option>"+\
                 "<option value = '1'>Yes</option>"+\
                "</select>"
-               form = form + newLine
-                form = form + \
+               form += newLine
+                form += \
                 "Show spouse's other spouses: <select name = 'os'>"+\
                 "<option value = '0'>No</option>"+\
                 "<option value = '1'>Yes</option>"+\
                 "</select>"
-               form = form + newLine
-                form = form + \
+               form += newLine
+                form += \
                 "Show parents' other spouses: <select name = 'pos'>"+\
                 "<option value = '0'>No</option>"+\
                 "<option value = '1'>Yes</option>"+\
                 "</select>"            
-               form = form + newLine
-                form = form + \
+               form += newLine
+                form += \
                "Fount size: "+\
                 "<input type = 'text' name = 'fs' value='8'>"
-                form = form + newLine
-               form = form + "</form>"
+                form += newLine
+               form += "</form>"
 
                graph =  "smallGraph.py?ID="+str(personID)+"&fs=8"
 
                graph = "<img src ="+ graph + '>'
 
-               output = output + "<div id = 'graph' style = 'clear:both'>"
-               output = output + "<p id = 'agraph'>"+graph+"</p>"
-               output = output + "Draw this graph with more relatives:"
-               output = output + newLine + form
+               output += "<div id = 'graph' style = 'clear:both'>"
+               output += "<p id = 'agraph'>"+graph+"</p>"
+               output += "Draw this graph with more relatives:"
+               output += newLine + form
                
-               output = output + "<button onclick='myFunction()'>"+\
+               output += "<button onclick='myFunction()'>"+\
                        "Go</button>"
 
-               output = output + "</div>"
+               output += "</div>"
 
-               output = output +\
+               output +=\
                '<script>'+\
                'function myFunction()'+\
                '{'+\