From 6ab6dccf0b98b4c3eadb668f67415c67d9d48450 Mon Sep 17 00:00:00 2001 From: naath Date: Sun, 6 Apr 2014 12:09:16 +0100 Subject: [PATCH] added some guessing of birth year --- familyTree/askQuestion.py | 54 ++++++++++++++++++++++++++++++++++++++- familyTree/printLists.py | 4 +-- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/familyTree/askQuestion.py b/familyTree/askQuestion.py index df1d95e..d2f5e21 100755 --- a/familyTree/askQuestion.py +++ b/familyTree/askQuestion.py @@ -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 diff --git a/familyTree/printLists.py b/familyTree/printLists.py index a5b59ef..808164c 100755 --- a/familyTree/printLists.py +++ b/familyTree/printLists.py @@ -21,8 +21,8 @@ print o #print o -#o = askQuestion.list_people('\n') -#print o +o = askQuestion.list_people('\n') +print o askQuestion.close(conn) -- 2.30.2