From 84fd0efcfe841c786055ad912edec74fad0d2bfc Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Sun, 15 Feb 2015 16:37:54 +0100 Subject: [PATCH] [depenses.py] Utilisable en l'important --- bde/stats/depenses.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bde/stats/depenses.py b/bde/stats/depenses.py index 248411b..b0ca825 100755 --- a/bde/stats/depenses.py +++ b/bde/stats/depenses.py @@ -49,16 +49,21 @@ def get_depenses(idbde): con, cur = get_cursor() cur.execute(create_temp_table, {"idbde" : idbde}) cur.execute(display_all) - l = cur.fetchall() + all = cur.fetchall() + cur.execute(display_sum) + tot = cur.fetchall()[0] + return (all, tot) + +def display_depenses(all, tot): + """Pretty-printing des résultats.""" print "annee\tdepenses\tgains" - for li in l: + for li in all: li = [int(li[0]), li[1], li[2]] print "%s\t%s\t\t%s" % tuple(li) - cur.execute(display_sum) - l = cur.fetchall() print "\nTotal :\n\tdepenses\tgains" - print "\t%s\t\t%s" % tuple(l[0]) + print "\t%s\t\t%s" % tuple(tot) if __name__ == "__main__": idbde = int(sys.argv[1]) - get_depenses(idbde) + all, tot = get_depenses(idbde) + display_depenses(all, tot) -- 2.39.2