[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUtrition-commits] /srv/bzr/gnutrition/development r27: Upped version
From: |
Thomas Sinclair |
Subject: |
[GNUtrition-commits] /srv/bzr/gnutrition/development r27: Upped version to 0.33 to reflect significant changes: |
Date: |
Thu, 26 Jul 2012 21:47:47 -0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 27
committer: Thomas Sinclair <address@hidden>
branch nick: development
timestamp: Thu 2012-07-26 21:47:47 -0400
message:
Upped version to 0.33 to reflect significant changes:
SQLite in use.
No longer re-write WEIGTHT.txt or create MEASURE.txt. sr24 data used as-is.
Nutrient composition now calculates.
Fewer dialogs pop up.
A lot of console output for now. Will be removed later when app seems stable.
removed:
data/prep_data.py
modified:
autom4te.cache/output.0
configure
configure.in
data/Makefile.in
data/README
data/prep_data_files.sh
src/database.py
src/food_edit_dlg.py
src/food_srch_dlg_ui.py
src/food_srch_res_dlg.py
src/food_win.py
src/nutr_composition_dlg.py
src/person.py
src/plan_compute_dlg.py
src/plan_win.py
src/recipe_srch_res_dlg.py
src/recipe_win.py
src/store.py
=== modified file 'autom4te.cache/output.0'
--- a/autom4te.cache/output.0 2012-07-25 04:49:08 +0000
+++ b/autom4te.cache/output.0 2012-07-27 01:47:47 +0000
@@ -1660,9 +1660,9 @@
MAJOR_VERSION=0
-MINOR_VERSION=32
-REVISION=1
-VERSION="0.32.1"
+MINOR_VERSION=33
+REVISION=0
+VERSION="0.33.0"
=== modified file 'configure'
--- a/configure 2012-07-25 04:49:08 +0000
+++ b/configure 2012-07-27 01:47:47 +0000
@@ -1660,9 +1660,9 @@
MAJOR_VERSION=0
-MINOR_VERSION=32
-REVISION=1
-VERSION="0.32.1"
+MINOR_VERSION=33
+REVISION=0
+VERSION="0.33.0"
=== modified file 'configure.in'
--- a/configure.in 2012-07-25 04:49:08 +0000
+++ b/configure.in 2012-07-27 01:47:47 +0000
@@ -23,9 +23,9 @@
AC_SUBST(PACKAGE)
MAJOR_VERSION=0
-MINOR_VERSION=32
-REVISION=1
-VERSION="0.32.1"
+MINOR_VERSION=33
+REVISION=0
+VERSION="0.33.0"
AC_SUBST(MAJOR_VERSION)
AC_SUBST(MINOR_VERSION)
AC_SUBST(REVISION)
=== modified file 'data/Makefile.in'
--- a/data/Makefile.in 2012-06-04 17:03:48 +0000
+++ b/data/Makefile.in 2012-07-27 01:47:47 +0000
@@ -38,8 +38,6 @@
rm -rf ${datadir}/data
clean:
- rm -f MEASURE.txt; \
- [ -f WEIGHT.orig ] && mv WEIGHT.orig WEIGHT.txt
-dist_clean: clean
+distclean: clean
rm -f Makefile
=== modified file 'data/README'
--- a/data/README 2012-05-28 03:12:23 +0000
+++ b/data/README 2012-07-27 01:47:47 +0000
@@ -1,1 +1,1 @@
-CATEGORY.txt and MEASURE.txt are not part of the USDA data.
+CATEGORY.txt is not part of the USDA data.
=== removed file 'data/prep_data.py'
--- a/data/prep_data.py 2012-06-04 17:03:48 +0000
+++ b/data/prep_data.py 1970-01-01 00:00:00 +0000
@@ -1,53 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2012 Free Software Foundation, Inc.
-#
-# This file is part of GNUtrition.
-#
-# GNUtrition is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# GNUtrition is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNUtrition. If not, see <http://www.gnu.org/licenses/>.
-
-from os import path, rename
-
-pfx = path.join('..', 'data')
-weight_orig = path.join(pfx, 'WEIGHT.orig')
-weight_out = path.join(pfx, 'WEIGHT.txt')
-if not path.isfile(weight_orig):
- rename(weight_out, weight_orig)
-measure = path.join(pfx, 'MEASURE.txt')
-
-field_dict = {'NDB_No':0, 'Seq':1, 'Amount':2, 'Msre_Desc':3, 'Gm_wgt':4}
-weight_fmt = "%s^%s^%s^%s^%s\n"
-measure_fmt = "%s^%s\n"
-
-measure_out = open(measure, 'w')
-weight_out = open(weight_out, 'w')
-weight_in = open(weight_orig, 'r')
-
-for line in weight_in:
- field_list = line.rstrip().split('^')
- Msre_No = int(str(field_list[field_dict['NDB_No']]) +
- str(field_list[field_dict['Seq']]))
-
- weight_out.write(weight_fmt % (field_list[field_dict['NDB_No']],
- field_list[field_dict['Seq']],
- field_list[field_dict['Amount']],
- Msre_No,
- field_list[field_dict['Gm_wgt']]))
-
-
- measure_out.write(measure_fmt % (Msre_No,
field_list[field_dict['Msre_Desc']]))
-
-weight_in.close()
-weight_out.close()
-measure_out.close()
=== modified file 'data/prep_data_files.sh'
--- a/data/prep_data_files.sh 2012-05-28 03:12:23 +0000
+++ b/data/prep_data_files.sh 2012-07-27 01:47:47 +0000
@@ -28,4 +28,3 @@
mv ${1}.tmp ${1}
shift 1
done
-./prep_data.py
=== modified file 'src/database.py'
--- a/src/database.py 2012-07-22 20:00:57 +0000
+++ b/src/database.py 2012-07-27 01:47:47 +0000
@@ -154,23 +154,18 @@
"Seq INTEGER NOT NULL, " +
# Amount == Unit modifier (for example, 1 in "1 cup").
"Amount REAL NOT NULL, " +
- "Msre_No INTEGER NOT NULL, " +
+ "Msre_Desc TEXT NOT NULL, " +
"Gm_wgt REAL NOT NULL, " +
+ "Num_Data_Pts INTEGER, " +
+ "Std_Dev REAL, " +
"PRIMARY KEY(NDB_No, Seq))",
### Insert statement
"INSERT INTO 'weight' VALUES " +
- "(?, ?, ?, ?, ?)",
+ "(?, ?, ?, ?, ?, ?, ?)",
'weight')
- # create measure table
- self.create_load_table("CREATE TABLE measure " +
- "(Msre_No INTEGER PRIMARY KEY NOT NULL, " +
- "Msre_Desc TEXT NOT NULL)",
- "INSERT INTO 'measure' VALUES (?, ?)",
- 'measure')
-
# create recipe table
- # HERE: recipe_no had AUTOINCREMENT but barfs on the syntax
+ # HERE: recipe_no had AUTOINCREMENT in MySQL version
self.create_table("CREATE TABLE recipe " +
"(recipe_no INTEGER NOT NULL, " +
"recipe_name TEXT NOT NULL, " +
@@ -179,20 +174,11 @@
"category_no INTEGER NOT NULL, " +
"PRIMARY KEY (recipe_no , recipe_name, category_no))", 'recipe')
- #trigger = """\
- #CREATE TRIGGER recipe_number BEFORE INSERT ON recipe
- # BEGIN
- # UPDATE recipe SET recipe_no = recipe.ROWID WHERE recipe_no = NULL;
- # END;
- #"""
- #self.query(trigger)
-
-
# create ingredient table
self.create_table("CREATE TABLE ingredient " +
- "(recipe_no INTEGER NOT NULL, " +
+ "(recipe_no INTEGER PRIMARY KEY NOT NULL, " +
"amount REAL NOT NULL, " +
- "Msre_No INTEGER NOT NULL, " +
+ "Msre_Desc TEXT NOT NULL, " +
"NDB_No INTEGER NOT NULL)", 'ingredient')
# create recipe category table
@@ -221,7 +207,7 @@
"date TEXT NOT NULL, " +
"time TEXT NOT NULL, " +
"amount REAL NOT NULL, " +
- "Msre_No INTEGER NOT NULL, " +
+ "Msre_Desc TEXT NOT NULL, " +
"Ndb_No INTEGER NOT NULL)", 'food_plan')
# create recipe_plan table
@@ -361,7 +347,3 @@
else:
m += 1
return m
-
-if __name__ == '__main__':
- db = Database()
- #db.initialize()
=== modified file 'src/food_edit_dlg.py'
--- a/src/food_edit_dlg.py 2012-06-04 17:03:48 +0000
+++ b/src/food_edit_dlg.py 2012-07-27 01:47:47 +0000
@@ -48,7 +48,6 @@
except ValueError:
gnutr.Dialog('error', 'The amount must be a number.')
self.ingr.msre_desc = self.ui.combo.get_active_text()
- self.ingr.msre_num = self.store.msre_desc2num[self.ingr.msre_desc]
if self.view == gnutr_consts.RECIPE:
self.app.base_win.recipe.replace_ingredient(self.ingr)
=== modified file 'src/food_srch_dlg_ui.py'
--- a/src/food_srch_dlg_ui.py 2012-06-04 17:03:48 +0000
+++ b/src/food_srch_dlg_ui.py 2012-07-27 01:47:47 +0000
@@ -119,7 +119,7 @@
label45.set_alignment(1, 0.5)
constraint_spin_adj = gtk.Adjustment(1, -5, 5, 1, 1, 1)
- self.constraint_spin = gtk.SpinButton(constraint_spin_adj, 1, 0)
+ self.constraint_spin = gtk.SpinButton(constraint_spin_adj, 0, 0)
label45.set_mnemonic_widget(self.constraint_spin)
self.table_nutr.attach(self.constraint_spin, 3, 4, 4, 5,
gtk.FILL, 0, 0, 0)
=== modified file 'src/food_srch_res_dlg.py'
--- a/src/food_srch_res_dlg.py 2012-06-04 17:03:48 +0000
+++ b/src/food_srch_res_dlg.py 2012-07-27 01:47:47 +0000
@@ -101,7 +101,7 @@
ingr = gnutr.Ingredient()
ingr.food_num = food_num
- ingr.food_desc = self.store.fd_num2desc[ ingr.food_num]
+ ingr.food_desc = self.store.fd_num2desc[ingr.food_num]
if self.view_type != gnutr_consts.FOOD:
try:
@@ -112,7 +112,6 @@
if (self.view_type == gnutr_consts.PLAN or
self.view_type == gnutr_consts.RECIPE):
ingr.msre_desc = self.ui.combo.get_active_text()
- ingr.msre_num = self.store.msre_desc2num[ ingr.msre_desc]
if self.view_type == gnutr_consts.PLAN:
self.ui.dialog.hide()
=== modified file 'src/food_win.py'
--- a/src/food_win.py 2012-06-04 17:03:48 +0000
+++ b/src/food_win.py 2012-07-27 01:47:47 +0000
@@ -90,12 +90,11 @@
return
fd_num = self.store.fd_desc2num[fd_desc]
msre_desc = self.ui.msre_combo.get_active_text()
- msre_num = self.store.msre_desc2num[msre_desc]
try:
amount = float(self.ui.amount_entry.get_text())
except ValueError:
gnutr.Dialog('error', 'The amount must be a number.', self.parent)
- self.nutr_comp_dlg.compute_food(amount, msre_num, fd_num)
+ self.nutr_comp_dlg.compute_food(amount, msre_desc, fd_num)
def on_goals_released(self, w, d=None):
if not hasattr(self, 'nutr_goal_dlg'):
=== modified file 'src/nutr_composition_dlg.py'
--- a/src/nutr_composition_dlg.py 2012-05-28 03:12:23 +0000
+++ b/src/nutr_composition_dlg.py 2012-07-27 01:47:47 +0000
@@ -54,14 +54,14 @@
self.list_nutr_tot = nutr_list
self.list_pcnt_goal = self.compute_pcnt_nutr_goal()
- def compute_food(self, amount, msre_num, food_num):
+ def compute_food(self, amount, msre_desc, food_num):
nutr_num_list = self.store.nutr_num_list
self.list_nutr_tot[:] = []
for nutr_num in nutr_num_list:
self.list_nutr_tot.append((nutr_num, 0.000))
- self.add_food_to_nutr_total(amount, msre_num, food_num)
+ self.add_food_to_nutr_total(amount, msre_desc, food_num)
self.list_pcnt_goal = self.compute_pcnt_nutr_goal()
self.update()
@@ -87,18 +87,16 @@
self.ui.fat_entry.set_text('%.3f' %(fat))
self.ui.carb_entry.set_text('%.3f' %(carbs))
- def add_food_to_nutr_total(self, amount, msre_num, food_num):
+ def add_food_to_nutr_total(self, amount, msre_desc, food_num):
self.db.query("SELECT Nutr_No, Nutr_Val FROM nut_data " +
"WHERE NDB_No ='%d'" % (food_num))
list_food_nutr = self.db.get_result()
- if int(msre_num) == 99999:
- gm_per_msre = 1.0
- else:
- self.db.query("SELECT Gm_wgt FROM weight " +
- "WHERE NDB_No ='%d' AND Msre_No ='%d'" % (food_num, msre_num))
- gm_per_msre = self.db.get_single_result()
+ self.db.query("SELECT Gm_wgt FROM weight " +
+ "WHERE NDB_No ='{0:d}' AND Msre_Desc ='{1:s}'".format(
+ food_num, msre_desc))
+ gm_per_msre = self.db.get_single_result()
for i in range(len(self.list_nutr_tot)):
tot_nutr_num, tot_nutr_val = self.list_nutr_tot[i]
@@ -140,10 +138,11 @@
for nutr_num in list_nutr_num:
self.list_nutr_tot.append((nutr_num, 0.000))
+ print 'compute_nutr_total(recipe):'
# iterate over ingredients
for ingr in recipe.ingr_list:
- self.add_food_to_nutr_total(ingr.amount, ingr.msre_num,
- ingr.food_num)
+ print '
amount:',ingr.amount,'msre_desc:',ingr.msre_desc,'food_num:',ingr.food_num
+ self.add_food_to_nutr_total(ingr.amount, ingr.msre_desc,
ingr.food_num)
# divide by the number of servings
for i in range(len(self.list_nutr_tot)):
@@ -164,15 +163,23 @@
list_nutr_goal = self.db.get_result()
dict = {}
+ print 'list_nutr_tot:'
for num, val in self.list_nutr_tot:
+ print 'num:', num, 'val:', val
dict[num] = val
list_pcnt_goal = []
+ print 'list_nutr_goal:'
for num, val in list_nutr_goal:
+ print 'num:', num, 'val:', val
if val == 0.0:
pcnt = 0.0
else:
- pcnt = dict[num] * 100.0 / val
+ try:
+ pcnt = dict[num] * 100.0 / val
+ except KeyError:
+ print 'nutr_composition_dlg: line 179, key error', num
+ continue
list_pcnt_goal.append((num, pcnt))
return list_pcnt_goal
=== modified file 'src/person.py'
--- a/src/person.py 2012-06-26 19:06:03 +0000
+++ b/src/person.py 2012-07-27 01:47:47 +0000
@@ -63,7 +63,7 @@
"date TEXT NOT NULL, " +
"time TEXT NOT NULL, " +
"amount REAL NOT NULL, " +
- "Msre_No INTEGER NOT NULL, " +
+ "Msre_Desc TEXT NOT NULL, " +
"NDB_No INTEGER NOT NULL, " +
"PRIMARY KEY (date, time, NDB_No))")
@@ -81,10 +81,10 @@
result = self.db.get_result()
if result and len(result) != 0:
- for person_no, date, time, amount, msre_no, ndb_no in result:
+ for person_no, date, time, amount, msre_desc, ndb_no in result:
self.db.query("INSERT INTO food_plan_temp VALUES" +
- "('%d', '%s', '%s', '%f', '%d', '%d' )"
- %(person_no, str(date), str(time), amount, msre_no,
ndb_no))
+ "('%d', '%s', '%s', '%f', '%s', '%d' )"
+ %(person_no, str(date), str(time), amount, msre_desc,
ndb_no))
self.db.query("SELECT * FROM recipe_plan WHERE person_no = '%d'"
% (person_num))
=== modified file 'src/plan_compute_dlg.py'
--- a/src/plan_compute_dlg.py 2012-05-28 03:12:23 +0000
+++ b/src/plan_compute_dlg.py 2012-07-27 01:47:47 +0000
@@ -28,7 +28,6 @@
self.ui = plan_compute_dlg_ui.PlanComputeDlgUI()
self.app = app
self.db = database.Database()
-
self.ui.dialog.connect('response', self.on_response)
def show(self):
@@ -82,13 +81,13 @@
self.add_recipe_to_total(tot_list, recipe_num, num_portions)
# get foods in plan within the dates
- self.db.query("SELECT amount, Msre_No, NDB_No FROM " +
+ self.db.query("SELECT amount, Msre_Desc, NDB_No FROM " +
"food_plan_temp WHERE date >='%s' AND date <='%s'"
%(start_date, end_date))
result = self.db.get_result()
- for amount, msre_num, fd_num in result:
- self.add_food_to_total(tot_list, amount, msre_num, fd_num)
+ for amount, msre_desc, fd_num in result:
+ self.add_food_to_total(tot_list, amount, msre_desc, fd_num)
if avg:
self.divide_total_by_no_days(tot_list, start_date, end_date)
@@ -115,7 +114,7 @@
tot_list[i] = (nutr_no, avg)
def get_ingredients(self, recipe_num):
- self.db.query("SELECT amount, Msre_No, NDB_No FROM " +
+ self.db.query("SELECT amount, Msre_Desc, NDB_No FROM " +
"ingredient WHERE recipe_no = '%d'" %(recipe_num))
return self.db.get_result()
@@ -124,11 +123,9 @@
"WHERE NDB_No = '%d'" %(food_num))
return self.db.get_result()
#HERE: take into account Amount unit modifier
- def get_gm_per_measure(self, food_num, msre_num):
- if int(msre_num) == 99999:
- return 1.0
+ def get_gm_per_measure(self, food_num, msre_desc):
self.db.query("SELECT Gm_wgt FROM weight WHERE " +
- "NDB_No = '%d' AND Msre_No = '%d'" %(food_num, msre_num))
+ "NDB_No = '%d' AND Msre_Desc = '%s'" %(food_num, msre_desc))
return float(self.db.get_single_result())
def add_food_nutr_comp(self, tot_list, food_num, amount, gm_per_msre):
@@ -148,11 +145,11 @@
self.db.query("SELECT no_serv FROM recipe WHERE " +
"recipe_no = '%d'" %(recipe_num))
num_serv = float(self.db.get_single_result())
- for amount, msre_num, fd_num in ingr_list:
+ for amount, msre_desc, fd_num in ingr_list:
tot_amount = amount * num_portions / num_serv
- gm_per_msre = self.get_gm_per_measure(fd_num, msre_num)
+ gm_per_msre = self.get_gm_per_measure(fd_num, msre_desc)
self.add_food_nutr_comp(tot_list, fd_num, tot_amount, gm_per_msre)
- def add_food_to_total(self, tot_list, amount, msre_no, fd_no):
- gm_per_msre = self.get_gm_per_measure(fd_no, msre_no)
+ def add_food_to_total(self, tot_list, amount, msre_desc, fd_no):
+ gm_per_msre = self.get_gm_per_measure(fd_no, msre_desc)
self.add_food_nutr_comp(tot_list, fd_no, amount, gm_per_msre)
=== modified file 'src/plan_win.py'
--- a/src/plan_win.py 2012-06-26 19:06:03 +0000
+++ b/src/plan_win.py 2012-07-27 01:47:47 +0000
@@ -300,30 +300,28 @@
if not hasattr(self, 'store'):
import store
self.store = store.Store()
- self.db.query("SELECT time, amount, Msre_No, NDB_No " +
- "FROM food_plan_temp WHERE date = '%s'" % (date))
+ self.db.query("SELECT time, amount, Msre_Desc, NDB_No " +
+ "FROM food_plan_temp WHERE date = '{0:s}'".format(date))
result = self.db.get_result()
food_list = []
- for time, amount, msre_no, ndb_no in result:
+ for time, amount, msre_desc, ndb_no in result:
food = gnutr.Ingredient()
food.time = str(time)
food.amount = amount
- food.msre_num = msre_no
food.food_num = ndb_no
food.food_desc = self.store.fd_num2desc[food.food_num]
- food.msre_desc = self.store.msre_num2desc[food.msre_num]
+ food.msre_desc = msre_desc
food_list.append(food)
return food_list
def food_desc_from_NDB_No(self, food_no):
- self.db.query("SELECT Long_Desc FROM food_des WHERE NDB_No = '%d'" %
- (food_no, seq_no))
+ self.db.query("SELECT Long_Desc FROM food_des WHERE NDB_No =
'{0:d}'".format(food_no))
return self.db.get_result()
- def food_quantity_info(self, food_no, seq_no):
- self.db.query("SELECT Amount, Gm_wgt FROM weight WHERE NDB_No = '%d'" +
- "AND Msre_No = '%d'" % (food_no, seq_no))
+ def food_quantity_info(self, food_no, msre_desc):
+ self.db.query("SELECT Amount, Gm_wgt FROM weight WHERE NDB_No =
'{0:d}'" +
+ "AND Msre_Desc = '{1:s}'".format(food_no, msre_desc))
return self.db.get_result()
@@ -375,15 +373,15 @@
def edit_plan_temp_db(self, date, food=None, recipe=None):
if food:
self.db.query("SELECT * FROM food_plan_temp WHERE " +
- "date = '%s' AND time = '%s' AND NDB_No = '%d'"
- %(date, food.time, food.food_num))
+ "date = '{0:s}' AND time = '{1:s}' AND NDB_No =
'{2:d}'".format(
+ date, food.time, food.food_num))
data = self.db.get_result()
# FIXME: catches a bug where two foods have the same name,
# date and time. At present can't distinguish between them
if len(data) > 1:
- person_num, date2, time, amount, msre_num, food_num = data[0]
+ person_num, date2, time, amount, msre_desc, food_num = data[0]
else:
- ((person_num, date2, time, amount, msre_num, food_num),) = \
+ ((person_num, date2, time, amount, msre_desc, food_num),) = \
data
self.db.query("DELETE FROM food_plan_temp WHERE " +
@@ -391,9 +389,8 @@
%(date, food.time, food.food_num))
self.db.query("INSERT INTO food_plan_temp VALUES (" +
- "'%d', '%s', '%s', '%s', '%d', '%d')"
- %(person_num, date2, time, food.amount, food.msre_num,
- food_num))
+ "'{0:d}', '{1:s}', '{2:s}', '{3:f}', '{4:s}', '{5:d}')".format(
+ person_num, date2, time, food.amount, food.msre_desc,food_num))
else:
self.db.query("SELECT * FROM recipe_plan_temp WHERE " +
"date = '%s' AND time = '%s' AND recipe_no = '%d'"
@@ -428,10 +425,10 @@
self.db.query("SELECT * FROM food_plan_temp")
plan_list = self.db.get_result()
- for person, date, time, amount, msre_no, ndb_no in plan_list:
+ for person, date, time, amount, msre_desc, ndb_no in plan_list:
self.db.query("INSERT INTO food_plan VALUES (" +
- "'%d', '%s', '%s', '%f', '%d', '%d' )"
- % (person, date, time, amount, msre_no, ndb_no))
+ "'{0:d}', '{1:s}', '{2:s}', '{3:f}', '{4:s}', '{5:d}')".format(
+ person, date, time, amount, msre_desc, ndb_no))
self.db.query("SELECT * FROM recipe_plan_temp")
recipe_list = self.db.get_result()
@@ -470,7 +467,6 @@
# Note: the temporary table is used
self.db.query("INSERT INTO food_plan_temp VALUES (" +
- "'%d', '%s', '%s', '%f', '%d', '%d' )"
- %(person_num, date, time, food.amount, food.msre_num,
- food.food_num))
+ "'{0:d}', '{1:s}', '{2:s}', '{3:f}', '{4:s}', '{5:d}')".format(
+ person_num, date, time, food.amount, food.msre_desc,
food.food_num))
self.update()
=== modified file 'src/recipe_srch_res_dlg.py'
--- a/src/recipe_srch_res_dlg.py 2012-05-28 03:12:23 +0000
+++ b/src/recipe_srch_res_dlg.py 2012-07-27 01:47:47 +0000
@@ -90,27 +90,25 @@
# plan_win.py
if self.view == gnutr_consts.RECIPE:
self.db.query("SELECT no_serv, category_no FROM " +
- "recipe WHERE recipe_no = '%d'" %(recipe.num))
+ "recipe WHERE recipe_no = '{0:d}'".format(recipe.num))
recipe.num_serv, recipe.cat_num = self.db.get_row_result()
recipe.cat_desc = self.store.cat_num2desc[ recipe.cat_num]
self.db.query("SELECT prep_desc FROM preparation WHERE " +
- "recipe_no = '%d'" %(recipe.num))
+ "recipe_no = '{0:d}'".format(recipe.num))
recipe.prep_desc = self.db.get_single_result()
- self.db.query("SELECT Amount, Msre_No, NDB_No FROM " +
- "ingredient WHERE recipe_no = '%d'"
- %(recipe.num))
+ self.db.query("SELECT amount, Msre_Desc, NDB_No FROM " +
+ "ingredient WHERE recipe_no = '{0:d}'".format(recipe.num))
ingr_list = self.db.get_result()
recipe.ingr_list = []
- for amount, msre_num, food_num in ingr_list:
+ for amount, msre_desc, food_num in ingr_list:
ingr = gnutr.Ingredient()
ingr.amount = amount
ingr.food_num = food_num
- ingr.msre_num = msre_num
ingr.food_desc = self.store.fd_num2desc[ food_num]
- ingr.msre_desc = self.store.msre_num2desc[ msre_num]
+ ingr.msre_desc = msre_desc
recipe.ingr_list.append(ingr)
self.app.base_win.recipe.update(recipe)
=== modified file 'src/recipe_win.py'
--- a/src/recipe_win.py 2012-07-25 04:49:08 +0000
+++ b/src/recipe_win.py 2012-07-27 01:47:47 +0000
@@ -201,8 +201,8 @@
for ingr in recipe.ingr_list:
self.db.query("""INSERT INTO ingredient VALUES
- ('%d', '%s', '%s', '%s' )""" % (recipe_no,
- str(ingr.amount), str(ingr.msre_num), str(ingr.food_num)))
+ ('{0:d}', '{1:f}', '{2:s}', '{3:d}')""".format(recipe_no,
+ ingr.amount, ingr.msre_desc, ingr.food_num))
self.db.query("""INSERT INTO preparation VALUES
('%d', '0.0', "%s")""" % (recipe_no, recipe.prep_desc))
@@ -294,12 +294,6 @@
if prep_desc != curr_prep_desc:
print 'Recipe Instructions have changed.'
return True
- # Create ingredient list to compare
- # self.db.query("""SELECT amount, Msre_No, NDB_No FROM ingredient
- # WHERE recipe_no = '{0:s}'""".format(recipe_no))
- # result = self.db.get_result()
- # for (amount, msre_no, food_no) in result:
- # pass
return False
def on_save_released(self, w, d=None):
@@ -370,8 +364,8 @@
self.ui.recipe_entry.set_text(recipe.desc)
self.ui.num_serv_entry.set_text(str(recipe.num_serv))
self.ui.category_combo.set_active_text(recipe.cat_desc)
-
- self.ui.text_buffer.set_text(recipe.prep_desc)
+ if recipe.prep_desc:
+ self.ui.text_buffer.set_text(recipe.prep_desc)
def get_ingredient_list(self):
ingr_list = []
=== modified file 'src/store.py'
--- a/src/store.py 2012-05-28 03:12:23 +0000
+++ b/src/store.py 2012-07-27 01:47:47 +0000
@@ -35,11 +35,7 @@
self.fg_desc2num = {}
self.fd_desc2num = {}
self.fd_num2desc = {}
- self.msre_num2desc = {}
- self.msre_desc2num = {}
-
self.db = database.Database()
-
self.create_nutr_num_list()
self.create_nutr_desc_list()
self.create_cat_desc_list()
@@ -47,7 +43,6 @@
self.create_nutr_desc_nutr_no_dict()
self.create_fd_gp_desc_fd_gp_no_dict()
self.create_fd_desc_fd_no_dict()
- self.create_msre_no_msre_desc_dict()
self.create_cat_desc_cat_no_dict()
def create_cat_desc_cat_no_dict(self):
@@ -110,17 +105,7 @@
self.fd_num2desc[num] = desc
def get_msre_desc_tuples(self, fd_num):
- self.db.query("SELECT Msre_Desc FROM measure, weight WHERE " +
- "weight.NDB_No = '%d' AND measure.Msre_No = weight.Msre_No"
- %(fd_num))
+ self.db.query("SELECT Msre_Desc FROM weight WHERE " +
+ "NDB_No = '{0:d}'".format(fd_num))
result = self.db.get_result()
return (('gm',),) + result
-
- def create_msre_no_msre_desc_dict(self):
- self.db.query("SELECT Msre_No, Msre_Desc FROM measure")
- result = self.db.get_result()
- for num, desc in result:
- self.msre_num2desc[num] = desc
- self.msre_desc2num[desc] = num
- self.msre_num2desc[99999] = 'gm'
- self.msre_desc2num['gm'] = 99999
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUtrition-commits] /srv/bzr/gnutrition/development r27: Upped version to 0.33 to reflect significant changes:,
Thomas Sinclair <=