diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-05-17 16:33:36 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-05-17 18:08:58 +0200 |
| commit | 9c487b5974ee7e7f196079611d7352364e8873ed (patch) | |
| tree | efc6ffa38da07b4302e145c33047cf2c41da105a /django/utils | |
| parent | b1bfd9630ef049070b0cd6ae215470d3d1facd40 (diff) | |
Replaced an antiquated pattern.
Thanks Lennart Regebro for pointing it out.
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/dateformat.py | 2 | ||||
| -rw-r--r-- | django/utils/html.py | 5 | ||||
| -rw-r--r-- | django/utils/log.py | 2 | ||||
| -rw-r--r-- | django/utils/translation/trans_real.py | 5 | ||||
| -rw-r--r-- | django/utils/tree.py | 2 |
5 files changed, 11 insertions, 5 deletions
diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py index b2586ba1ff..6d0a7b63f7 100644 --- a/django/utils/dateformat.py +++ b/django/utils/dateformat.py @@ -234,7 +234,7 @@ class DateFormat(TimeFormat): def T(self): "Time zone of this machine; e.g. 'EST' or 'MDT'" - name = self.timezone and self.timezone.tzname(self.data) or None + name = self.timezone.tzname(self.data) if self.timezone else None if name is None: name = self.format('O') return six.text_type(name) diff --git a/django/utils/html.py b/django/utils/html.py index 650e8485ab..8b28d97d13 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -187,7 +187,10 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False): If autoescape is True, the link text and URLs will get autoescaped. """ - trim_url = lambda x, limit=trim_url_limit: limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x + def trim_url(x, limit=trim_url_limit): + if limit is None or len(x) <= limit: + return x + return '%s...' % x[:max(0, limit - 3)] safe_input = isinstance(text, SafeData) words = word_split_re.split(force_text(text)) for i, word in enumerate(words): diff --git a/django/utils/log.py b/django/utils/log.py index b291b86706..a9b62caae1 100644 --- a/django/utils/log.py +++ b/django/utils/log.py @@ -111,7 +111,7 @@ class AdminEmailHandler(logging.Handler): message = "%s\n\n%s" % (stack_trace, request_repr) reporter = ExceptionReporter(request, is_email=True, *exc_info) - html_message = self.include_html and reporter.get_traceback_html() or None + html_message = reporter.get_traceback_html() if self.include_html else None mail.mail_admins(subject, message, fail_silently=True, html_message=html_message, connection=self.connection()) diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index ad172407de..07353c35ee 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -651,7 +651,10 @@ def parse_accept_lang_header(lang_string): first, lang, priority = pieces[i : i + 3] if first: return [] - priority = priority and float(priority) or 1.0 + if priority: + priority = float(priority) + if not priority: # if priority is 0.0 at this point make it 1.0 + priority = 1.0 result.append((lang, priority)) result.sort(key=lambda k: k[1], reverse=True) return result diff --git a/django/utils/tree.py b/django/utils/tree.py index 4152b4600b..3f93738b4f 100644 --- a/django/utils/tree.py +++ b/django/utils/tree.py @@ -20,7 +20,7 @@ class Node(object): Constructs a new Node. If no connector is given, the default will be used. """ - self.children = children and children[:] or [] + self.children = children[:] if children else [] self.connector = connector or self.default self.negated = negated |
