--- a/devtools/fill.py Thu May 14 10:24:56 2009 +0200
+++ b/devtools/fill.py Thu May 14 11:38:40 2009 +0200
@@ -33,7 +33,7 @@
if isinstance(cst, StaticVocabularyConstraint):
return cst.vocabulary()
return None
-
+
def get_max_length(eschema, attrname):
"""returns the maximum length allowed for 'attrname'"""
@@ -75,7 +75,7 @@
value = self.__generate_value(attrname, index, **kwargs)
_GENERATED_VALUES.setdefault((self.e_schema.type, attrname), set()).add(value)
return value
-
+
def __generate_value(self, attrname, index, **kwargs):
"""generates a consistent value for 'attrname'"""
attrtype = str(self.e_schema.destination(attrname)).lower()
@@ -100,7 +100,7 @@
if choices is None:
return None
return unicode(choice(choices)) # FIXME
-
+
def generate_string(self, attrname, index, format=None):
"""generates a consistent value for 'attrname' if it's a string"""
# First try to get choices
@@ -133,7 +133,7 @@
def generate_password(self, attrname, index):
"""generates a consistent value for 'attrname' if it's a password"""
return u'toto'
-
+
def generate_integer(self, attrname, index):
"""generates a consistent value for 'attrname' if it's an integer"""
choosed = self.generate_choice(attrname, index)
@@ -145,17 +145,17 @@
else:
maxvalue = maxvalue or index
return randint(minvalue or 0, maxvalue)
-
+
generate_int = generate_integer
-
+
def generate_float(self, attrname, index):
"""generates a consistent value for 'attrname' if it's a float"""
return float(randint(-index, index))
-
+
def generate_decimal(self, attrname, index):
"""generates a consistent value for 'attrname' if it's a float"""
return Decimal(str(self.generate_float(attrname, index)))
-
+
def generate_date(self, attrname, index):
"""generates a random date (format is 'yyyy-mm-dd')"""
return date(randint(2000, 2004), randint(1, 12), randint(1, 28))
@@ -163,11 +163,11 @@
def generate_time(self, attrname, index):
"""generates a random time (format is ' HH:MM')"""
return timedelta(0, 11, index%60) #'11:%02d' % (index % 60)
-
+
def generate_datetime(self, attrname, index):
"""generates a random date (format is 'yyyy-mm-dd HH:MM')"""
return datetime(randint(2000, 2004), randint(1, 12), randint(1, 28), 11, index%60)
-
+
def generate_bytes(self, attrname, index, format=None):
# modpython way
@@ -175,7 +175,7 @@
fakefile.filename = "file_%s" % attrname
fakefile.value = fakefile.getvalue()
return fakefile
-
+
def generate_boolean(self, attrname, index):
"""generates a consistent value for 'attrname' if it's a boolean"""
return index % 2 == 0
@@ -185,7 +185,7 @@
# need this method else stupid values will be set which make mtconverter
# raise exception
return u'application/octet-stream'
-
+
def generate_Any_content_format(self, index, **kwargs):
# content_format attribute of EmailPart has no vocabulary constraint, we
# need this method else stupid values will be set which make mtconverter
@@ -250,7 +250,7 @@
args))
assert not 'eid' in args, args
else:
- queries.append(('INSERT %s X' % etype, {}))
+ queries.append(('INSERT %s X' % etype, {}))
return queries
@@ -365,7 +365,7 @@
continue
subjcard, objcard = rschema.rproperty(subj, obj, 'cardinality')
# process mandatory relations first
- if subjcard in '1+' or objcard in '1+':
+ if subjcard in '1+' or objcard in '1+':
queries += self.make_relation_queries(sedict, oedict,
rschema, subj, obj)
else:
@@ -374,7 +374,7 @@
queries += self.make_relation_queries(sedict, oedict, rschema,
subj, obj)
return queries
-
+
def qargs(self, subjeids, objeids, subjcard, objcard, subjeid, objeid):
if subjcard in '?1':
subjeids.remove(subjeid)
@@ -411,7 +411,7 @@
subjeids.remove(subjeid)
if not subjeids:
check_card_satisfied(objcard, objeids, subj, rschema, obj)
- return
+ return
if not objeids:
check_card_satisfied(subjcard, subjeids, subj, rschema, obj)
return
@@ -452,7 +452,7 @@
used.add( (subjeid, objeid) )
yield q, self.qargs(subjeids, objeids, subjcard, objcard,
subjeid, objeid)
-
+
def check_card_satisfied(card, remaining, subj, rschema, obj):
if card in '1+' and remaining:
raise Exception("can't satisfy cardinality %s for relation %s %s %s"
@@ -466,8 +466,8 @@
while objeid == avoid: # avoid infinite recursion like in X comment X
objeid = choice(values)
return objeid
-
-
+
+
# UTILITIES FUNCS ##############################################################
def make_tel(num_tel):