mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +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:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							50c1d8f24b
						
					
				
				
					commit
					560b4207b1
				
			| @@ -645,7 +645,7 @@ class BoundField(object): | ||||
|         # Translators: If found as last label character, these punctuation | ||||
|         # characters will prevent the default label_suffix to be appended to the label | ||||
|         if label_suffix and contents and contents[-1] not in _(':?.!'): | ||||
|             contents = format_html('{0}{1}', contents, label_suffix) | ||||
|             contents = format_html('{}{}', contents, label_suffix) | ||||
|         widget = self.field.widget | ||||
|         id_ = widget.attrs.get('id') or self.auto_id | ||||
|         if id_: | ||||
| @@ -659,7 +659,7 @@ class BoundField(object): | ||||
|                 else: | ||||
|                     attrs['class'] = self.form.required_css_class | ||||
|             attrs = flatatt(attrs) if attrs else '' | ||||
|             contents = format_html('<label{0}>{1}</label>', attrs, contents) | ||||
|             contents = format_html('<label{}>{}</label>', attrs, contents) | ||||
|         else: | ||||
|             contents = conditional_escape(contents) | ||||
|         return mark_safe(contents) | ||||
|   | ||||
| @@ -39,8 +39,8 @@ def flatatt(attrs): | ||||
|             key_value_attrs.append((attr, value)) | ||||
|  | ||||
|     return ( | ||||
|         format_html_join('', ' {0}="{1}"', sorted(key_value_attrs)) + | ||||
|         format_html_join('', ' {0}', sorted(boolean_attrs)) | ||||
|         format_html_join('', ' {}="{}"', sorted(key_value_attrs)) + | ||||
|         format_html_join('', ' {}', sorted(boolean_attrs)) | ||||
|     ) | ||||
|  | ||||
|  | ||||
| @@ -61,8 +61,8 @@ class ErrorDict(dict): | ||||
|         if not self: | ||||
|             return '' | ||||
|         return format_html( | ||||
|             '<ul class="errorlist">{0}</ul>', | ||||
|             format_html_join('', '<li>{0}{1}</li>', ((k, force_text(v)) for k, v in self.items())) | ||||
|             '<ul class="errorlist">{}</ul>', | ||||
|             format_html_join('', '<li>{}{}</li>', ((k, force_text(v)) for k, v in self.items())) | ||||
|         ) | ||||
|  | ||||
|     def as_text(self): | ||||
| @@ -110,9 +110,9 @@ class ErrorList(UserList, list): | ||||
|             return '' | ||||
|  | ||||
|         return format_html( | ||||
|             '<ul class="{0}">{1}</ul>', | ||||
|             '<ul class="{}">{}</ul>', | ||||
|             self.error_class, | ||||
|             format_html_join('', '<li>{0}</li>', ((force_text(e),) for e in self)) | ||||
|             format_html_join('', '<li>{}</li>', ((force_text(e),) for e in self)) | ||||
|         ) | ||||
|  | ||||
|     def as_text(self): | ||||
|   | ||||
| @@ -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))) | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user