populate(...contents), thanks Vinicius

This commit is contained in:
mdipierro
2013-04-03 14:46:13 -05:00
parent 6b3cdb5a99
commit e87a2bf0d5
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.4.5-stable+timestamp.2013.04.03.11.31.36
Version 2.4.5-stable+timestamp.2013.04.03.14.45.24
+8 -1
View File
@@ -75,7 +75,7 @@ def da_du_ma(n=4):
[random.randint(0, 11)] for i in range(n)])
def populate(table, n, default=True, compute=False):
def populate(table, n, default=True, compute=False, contents={}):
ell = Learner()
#ell.learn(open('20417.txt','r').read())
#ell.save('frequencies.pickle')
@@ -84,7 +84,14 @@ def populate(table, n, default=True, compute=False):
ids = {}
for i in range(n):
record = {}
record.update(contents) # load user supplied contents.
for fieldname in table.fields:
if record.get(fieldname) is not None:
continue # if user supplied it, let it be.
field = table[fieldname]
if not isinstance(field.type, (str, unicode)):
continue