chiark / gitweb /
added some guessing of birth year
[familyTree.git] / familyTree / askQuestion.py
index df1d95efcf065b6b0a5594ee9df4733d7efcff0c..d2f5e2185e4d1e6b1ca4acc3597e1dd44c363910 100755 (executable)
@@ -150,9 +150,61 @@ def list_people(newLine):
                        century = row[2]/100 + 1
                        out = out +newLine+ 'born in ' 
 
-                       out = out +ordinal_numbers(century) + ' century:' + newLine
+                       out = out +ordinal_numbers(century) \
+                               + ' century:' + newLine
 
                out = out + name_html(row,newLine) +newLine
+
+               if row[2] == 0: #unknown year
+
+                       t = (row[1],) #person ID
+
+
+                       #died
+                       u = "SELECT diedyear FROM people WHERE ID = ?;"
+
+                       bornAfter = 0
+                       for r in run_query(u,t):
+                               if r[0] !=0:
+                                       out = out + "died: "\
+                                        + str(r[0]) + newLine
+                                       bornAfter = r[0] -100
+
+                       #find children
+                       u = "Select people.bornYear from"\
+                               +" people INNER JOIN parents"\
+                               +" ON people.ID = parents.ID"\
+                               +" WHERE parents.parentID = ?"\
+                               + " ORDER BY people.bornYear;"
+                       
+                       hadChild=[]
+                       
+                       for r in run_query(u,t):
+                               if r[0] != 0:
+                                       hadChild.append(r[0])
+                       
+                       bornBefore = 0
+                       if len(hadChild)!=0:
+                               out = out + "had children in: "
+                               for c in hadChild:
+                                       out = out + str(c) + ','
+                               out = out[:-1] + newLine
+
+                               bornBefore = hadChild[0]-12
+                               if bornAfter==0:
+                                       bornAfter = hadChild[0]-100
+                       
+                       if bornAfter!=0:
+                               if bornBefore == 0: 
+                                       out = out + "probably born "\
+                                               +"after " + str(bornAfter)
+                               else:
+                                       out = out + "probably born "\
+                                               +"betwen " + str(bornAfter)\
+                                               +" and " + str(bornBefore)
+                               out = out + newLine
+
+
                year = row[2]
        return out