1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Replaced some map() and filter() calls with generators.

This commit is contained in:
Tom 2017-05-20 22:33:51 +01:00 committed by Tim Graham
parent 37ab3c3f9d
commit 94475aab80
2 changed files with 3 additions and 3 deletions

View File

@ -256,9 +256,9 @@ class EmailMessage:
msg['From'] = self.extra_headers.get('From', self.from_email)
msg['To'] = self.extra_headers.get('To', ', '.join(map(str, self.to)))
if self.cc:
msg['Cc'] = ', '.join(map(str, self.cc))
msg['Cc'] = ', '.join(str(cc) for cc in self.cc)
if self.reply_to:
msg['Reply-To'] = self.extra_headers.get('Reply-To', ', '.join(map(str, self.reply_to)))
msg['Reply-To'] = self.extra_headers.get('Reply-To', ', '.join(str(r) for r in self.reply_to))
# Email header names are case-insensitive (RFC 2045), so we have to
# accommodate that when doing comparisons.

View File

@ -85,7 +85,7 @@ class Loader(BaseLoader):
if matching:
skip_prefix = self.generate_hash(matching)
return '-'.join(filter(bool, [str(template_name), skip_prefix, dirs_prefix]))
return '-'.join(s for s in (str(template_name), skip_prefix, dirs_prefix) if s)
def generate_hash(self, values):
return hashlib.sha1(force_bytes('|'.join(values))).hexdigest()