mirror of https://github.com/django/django.git
Fed tuples to startswith when appropriate
This commit is contained in:
parent
b9d9ab23bd
commit
a52cd407b8
|
@ -12,9 +12,8 @@ from django.utils._os import npath, upath
|
||||||
def has_bom(fn):
|
def has_bom(fn):
|
||||||
with open(fn, 'rb') as f:
|
with open(fn, 'rb') as f:
|
||||||
sample = f.read(4)
|
sample = f.read(4)
|
||||||
return sample[:3] == b'\xef\xbb\xbf' or \
|
return (sample[:3] == b'\xef\xbb\xbf' or
|
||||||
sample.startswith(codecs.BOM_UTF16_LE) or \
|
sample.startswith((codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE)))
|
||||||
sample.startswith(codecs.BOM_UTF16_BE)
|
|
||||||
|
|
||||||
|
|
||||||
def is_writable(path):
|
def is_writable(path):
|
||||||
|
|
|
@ -197,7 +197,7 @@ def resolve_url(to, *args, **kwargs):
|
||||||
|
|
||||||
if isinstance(to, six.string_types):
|
if isinstance(to, six.string_types):
|
||||||
# Handle relative URLs
|
# Handle relative URLs
|
||||||
if any(to.startswith(path) for path in ('./', '../')):
|
if to.startswith(('./', '../')):
|
||||||
return to
|
return to
|
||||||
|
|
||||||
# Next try a reverse URL resolution.
|
# Next try a reverse URL resolution.
|
||||||
|
|
|
@ -232,7 +232,7 @@ class Token(object):
|
||||||
bits = iter(smart_split(self.contents))
|
bits = iter(smart_split(self.contents))
|
||||||
for bit in bits:
|
for bit in bits:
|
||||||
# Handle translation-marked template pieces
|
# Handle translation-marked template pieces
|
||||||
if bit.startswith('_("') or bit.startswith("_('"):
|
if bit.startswith(('_("', "_('")):
|
||||||
sentinal = bit[2] + ')'
|
sentinal = bit[2] + ')'
|
||||||
trans_bit = [bit]
|
trans_bit = [bit]
|
||||||
while not bit.endswith(sentinal):
|
while not bit.endswith(sentinal):
|
||||||
|
|
Loading…
Reference in New Issue