mirror of
https://github.com/django/django.git
synced 2025-07-22 20:55:17 +00:00
Removed redundant numbered parameters from str.format().
Since Python 2.7 and 3.1, "{0} {1}" is equivalent to "{} {}".
This commit is contained in:
parent
50c1d8f24b
commit
560b4207b1
24 changed files with 72 additions and 72 deletions
|
@ -53,7 +53,7 @@ class Media(object):
|
|||
def render_js(self):
|
||||
return [
|
||||
format_html(
|
||||
'<script type="text/javascript" src="{0}"></script>',
|
||||
'<script type="text/javascript" src="{}"></script>',
|
||||
self.absolute_path(path)
|
||||
) for path in self._js
|
||||
]
|
||||
|
@ -64,7 +64,7 @@ class Media(object):
|
|||
media = sorted(self._css.keys())
|
||||
return chain(*[[
|
||||
format_html(
|
||||
'<link href="{0}" type="text/css" media="{1}" rel="stylesheet" />',
|
||||
'<link href="{}" type="text/css" media="{}" rel="stylesheet" />',
|
||||
self.absolute_path(path), medium
|
||||
) for path in self._css[medium]
|
||||
] for medium in media])
|
||||
|
@ -252,7 +252,7 @@ class Input(Widget):
|
|||
if value != '':
|
||||
# Only add the 'value' attribute if a value is non-empty.
|
||||
final_attrs['value'] = force_text(self._format_value(value))
|
||||
return format_html('<input{0} />', flatatt(final_attrs))
|
||||
return format_html('<input{} />', flatatt(final_attrs))
|
||||
|
||||
|
||||
class TextInput(Input):
|
||||
|
@ -315,7 +315,7 @@ class MultipleHiddenInput(HiddenInput):
|
|||
# An ID attribute was given. Add a numeric index as a suffix
|
||||
# so that the inputs don't all have the same ID attribute.
|
||||
input_attrs['id'] = '%s_%s' % (id_, i)
|
||||
inputs.append(format_html('<input{0} />', flatatt(input_attrs)))
|
||||
inputs.append(format_html('<input{} />', flatatt(input_attrs)))
|
||||
return mark_safe('\n'.join(inputs))
|
||||
|
||||
def value_from_datadict(self, data, files, name):
|
||||
|
@ -429,7 +429,7 @@ class Textarea(Widget):
|
|||
if value is None:
|
||||
value = ''
|
||||
final_attrs = self.build_attrs(attrs, name=name)
|
||||
return format_html('<textarea{0}>\r\n{1}</textarea>',
|
||||
return format_html('<textarea{}>\r\n{}</textarea>',
|
||||
flatatt(final_attrs),
|
||||
force_text(value))
|
||||
|
||||
|
@ -478,7 +478,7 @@ class CheckboxInput(Widget):
|
|||
if not (value is True or value is False or value is None or value == ''):
|
||||
# Only add the 'value' attribute if a value is non-empty.
|
||||
final_attrs['value'] = force_text(value)
|
||||
return format_html('<input{0} />', flatatt(final_attrs))
|
||||
return format_html('<input{} />', flatatt(final_attrs))
|
||||
|
||||
def value_from_datadict(self, data, files, name):
|
||||
if name not in data:
|
||||
|
@ -507,7 +507,7 @@ class Select(Widget):
|
|||
if value is None:
|
||||
value = ''
|
||||
final_attrs = self.build_attrs(attrs, name=name)
|
||||
output = [format_html('<select{0}>', flatatt(final_attrs))]
|
||||
output = [format_html('<select{}>', flatatt(final_attrs))]
|
||||
options = self.render_options(choices, [value])
|
||||
if options:
|
||||
output.append(options)
|
||||
|
@ -525,7 +525,7 @@ class Select(Widget):
|
|||
selected_choices.remove(option_value)
|
||||
else:
|
||||
selected_html = ''
|
||||
return format_html('<option value="{0}"{1}>{2}</option>',
|
||||
return format_html('<option value="{}"{}>{}</option>',
|
||||
option_value,
|
||||
selected_html,
|
||||
force_text(option_label))
|
||||
|
@ -536,7 +536,7 @@ class Select(Widget):
|
|||
output = []
|
||||
for option_value, option_label in chain(self.choices, choices):
|
||||
if isinstance(option_label, (list, tuple)):
|
||||
output.append(format_html('<optgroup label="{0}">', force_text(option_value)))
|
||||
output.append(format_html('<optgroup label="{}">', force_text(option_value)))
|
||||
for option in option_label:
|
||||
output.append(self.render_option(selected_choices, *option))
|
||||
output.append('</optgroup>')
|
||||
|
@ -579,7 +579,7 @@ class SelectMultiple(Select):
|
|||
if value is None:
|
||||
value = []
|
||||
final_attrs = self.build_attrs(attrs, name=name)
|
||||
output = [format_html('<select multiple="multiple"{0}>', flatatt(final_attrs))]
|
||||
output = [format_html('<select multiple="multiple"{}>', flatatt(final_attrs))]
|
||||
options = self.render_options(choices, value)
|
||||
if options:
|
||||
output.append(options)
|
||||
|
@ -615,12 +615,12 @@ class ChoiceInput(SubWidget):
|
|||
|
||||
def render(self, name=None, value=None, attrs=None, choices=()):
|
||||
if self.id_for_label:
|
||||
label_for = format_html(' for="{0}"', self.id_for_label)
|
||||
label_for = format_html(' for="{}"', self.id_for_label)
|
||||
else:
|
||||
label_for = ''
|
||||
attrs = dict(self.attrs, **attrs) if attrs else self.attrs
|
||||
return format_html(
|
||||
'<label{0}>{1} {2}</label>', label_for, self.tag(attrs), self.choice_label
|
||||
'<label{}>{} {}</label>', label_for, self.tag(attrs), self.choice_label
|
||||
)
|
||||
|
||||
def is_checked(self):
|
||||
|
@ -631,7 +631,7 @@ class ChoiceInput(SubWidget):
|
|||
final_attrs = dict(attrs, type=self.input_type, name=self.name, value=self.choice_value)
|
||||
if self.is_checked():
|
||||
final_attrs['checked'] = 'checked'
|
||||
return format_html('<input{0} />', flatatt(final_attrs))
|
||||
return format_html('<input{} />', flatatt(final_attrs))
|
||||
|
||||
@property
|
||||
def id_for_label(self):
|
||||
|
@ -693,7 +693,7 @@ class ChoiceFieldRenderer(object):
|
|||
if isinstance(choice_label, (tuple, list)):
|
||||
attrs_plus = self.attrs.copy()
|
||||
if id_:
|
||||
attrs_plus['id'] += '_{0}'.format(i)
|
||||
attrs_plus['id'] += '_{}'.format(i)
|
||||
sub_ul_renderer = ChoiceFieldRenderer(name=self.name,
|
||||
value=self.value,
|
||||
attrs=attrs_plus,
|
||||
|
@ -707,7 +707,7 @@ class ChoiceFieldRenderer(object):
|
|||
output.append(format_html(self.inner_html,
|
||||
choice_value=force_text(w), sub_widgets=''))
|
||||
return format_html(self.outer_html,
|
||||
id_attr=format_html(' id="{0}"', id_) if id_ else '',
|
||||
id_attr=format_html(' id="{}"', id_) if id_ else '',
|
||||
content=mark_safe('\n'.join(output)))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue