diff options
Diffstat (limited to 'django/utils')
-rw-r--r-- | django/utils/text.py | 12 | ||||
-rw-r--r-- | django/utils/translation/trans_real.py | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/django/utils/text.py b/django/utils/text.py index 5d633b7afe..b05460486d 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -39,7 +39,10 @@ wrap = allow_lazy(wrap, unicode) def truncate_words(s, num, end_text='...'): """Truncates a string after a certain number of words. Takes an optional argument of what should be used to notify that the string has been - truncated, defaults to ellipsis (...)""" + truncated, defaulting to ellipsis (...) + + Newlines in the string will be stripped. + """ s = force_unicode(s) length = int(num) words = s.split() @@ -51,10 +54,13 @@ def truncate_words(s, num, end_text='...'): truncate_words = allow_lazy(truncate_words, unicode) def truncate_html_words(s, num, end_text='...'): - """Truncates html to a certain number of words (not counting tags and + """Truncates HTML to a certain number of words (not counting tags and comments). Closes opened tags if they were correctly closed in the given html. Takes an optional argument of what should be used to notify that the - string has been truncated, defaults to ellipsis (...).""" + string has been truncated, defaulting to ellipsis (...). + + Newlines in the HTML are preserved. + """ s = force_unicode(s) length = int(num) if length <= 0: diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index b528f8e586..98b8d940b3 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -496,7 +496,7 @@ def parse_accept_lang_header(lang_string): return [] priority = priority and float(priority) or 1.0 result.append((lang, priority)) - result.sort(lambda x, y: -cmp(x[1], y[1])) + result.sort(key=lambda k: k[1], reverse=True) return result # get_date_formats and get_partial_date_formats aren't used anymore by Django |