Exemplo n.º 1
0
 def populate(cls):
     size, nwords = cls.sizes[cls.cfg.size]
     published = populate('date', size=size)
     blog = cls.models.blog
     with cls.models.begin() as t:
         for dt in published:
             title = populate('choice', 5,
                              choice_from=basic_english_words)
             words = populate('choice', size,
                              choice_from=basic_english_words)
             t.add(blog(published=dt, title=' '.join(title),
                        body=' '.join(words)))
     return t.wait()
Exemplo n.º 2
0
def populate_from_file(size, path):
    p = os.path
    path = p.join(p.dirname(p.dirname(p.abspath(__file__))), 'data', path)
    with open(path) as f:
        all = f.read()
    all = [a for a in all.split('\n') if a]
    return populate('choice', size, choice_from=all)
Exemplo n.º 3
0
def populate_from_file(size, path):
    p = os.path
    path = p.join(p.dirname(p.dirname(p.abspath(__file__))), 'data', path)
    with open(path) as f:
        all = f.read()
    all = [a for a in all.split('\n') if a]
    return populate('choice', size, choice_from=all)
Exemplo n.º 4
0
 def random(self):
     string = populate('string', size=100)
     values = populate('float', size=100, min=-10, max=10)
     s = self.zset()
     s.update(zip(values, string))
     return s
Exemplo n.º 5
0
 def random(self, size=100, score_min=-10, score_max=10):
     scores = populate('float', size, score_min, score_max)
     data = populate('string', size, min_len=5, max_len=10)
     return self.skiplist(zip(scores, data))
Exemplo n.º 6
0
 def random(self):
     string = populate('string', size=100)
     values = populate('float', size=100, min=-10, max=10)
     s = self.zset()
     s.update(zip(values, string))
     return s
 def random(self, size=100, score_min=-10, score_max=10):
     scores = populate('float', size, score_min, score_max)
     return Skiplist(scores)
Exemplo n.º 8
0
 def random(self, size=100, score_min=-10, score_max=10):
     scores = populate('float', size, score_min, score_max)
     data = populate('string', size, min_len=5, max_len=10)
     return self.skiplist(zip(scores, data))