devtools/fill.py
branchstable
changeset 2118 0012d997b992
parent 1977 606923dff11b
child 2476 1294a6bdf3bf
equal deleted inserted replaced
2117:b451bd56c9cd 2118:0012d997b992
     8 """
     8 """
     9 __docformat__ = "restructuredtext en"
     9 __docformat__ = "restructuredtext en"
    10 
    10 
    11 from random import randint, choice
    11 from random import randint, choice
    12 from copy import deepcopy
    12 from copy import deepcopy
    13 from datetime import datetime, date, timedelta
    13 from datetime import datetime, date, time#timedelta
    14 from decimal import Decimal
    14 from decimal import Decimal
    15 
    15 
    16 from yams.constraints import (SizeConstraint, StaticVocabularyConstraint,
    16 from yams.constraints import (SizeConstraint, StaticVocabularyConstraint,
    17                               IntervalBoundConstraint)
    17                               IntervalBoundConstraint)
    18 from rql.utils import decompose_b26 as base_decompose_b26
    18 from rql.utils import decompose_b26 as base_decompose_b26
   161         """generates a random date (format is 'yyyy-mm-dd')"""
   161         """generates a random date (format is 'yyyy-mm-dd')"""
   162         return date(randint(2000, 2004), randint(1, 12), randint(1, 28))
   162         return date(randint(2000, 2004), randint(1, 12), randint(1, 28))
   163 
   163 
   164     def generate_time(self, attrname, index):
   164     def generate_time(self, attrname, index):
   165         """generates a random time (format is ' HH:MM')"""
   165         """generates a random time (format is ' HH:MM')"""
   166         return timedelta(0, 11, index%60) #'11:%02d' % (index % 60)
   166         return time(11, index%60) #'11:%02d' % (index % 60)
   167 
   167 
   168     def generate_datetime(self, attrname, index):
   168     def generate_datetime(self, attrname, index):
   169         """generates a random date (format is 'yyyy-mm-dd HH:MM')"""
   169         """generates a random date (format is 'yyyy-mm-dd HH:MM')"""
   170         return datetime(randint(2000, 2004), randint(1, 12), randint(1, 28), 11, index%60)
   170         return datetime(randint(2000, 2004), randint(1, 12), randint(1, 28), 11, index%60)
   171 
   171