Ticket #4276: lorem_words.diff

File lorem_words.diff, 1002 bytes (added by Trent Mick <trentm@…>, 18 years ago)

patch to fix the issues described

  • django/contrib/webdesign/lorem_ipsum.py

     
    5757        word_list = list(COMMON_WORDS)
    5858    else:
    5959        word_list = []
    60     c = len(word_list)
    61     if count > c:
    62         count = min(count - c, len(WORDS))
    63         word_list += random.sample(WORDS, count - c)
     60    remaining = count - len(word_list)
     61    print remaining, len(WORDS)
     62    if remaining < 0:
     63        word_list = word_list[:count]
     64    elif remaining <= len(WORDS):
     65        word_list += random.sample(WORDS, remaining)
    6466    else:
    65         word_list = word_list[:count]
     67        extra_words = list(WORDS * (remaining // len(WORDS))) \
     68                      + random.sample(WORDS, remaining % len(WORDS))
     69        random.shuffle(extra_words)
     70        word_list += extra_words
    6671    return ' '.join(word_list)
Back to Top