diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-03 10:08:55 -0800 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-03 10:08:55 -0800 |
| commit | c347f78cc1b2a06958f692f0622deceac534dc6b (patch) | |
| tree | c91fa9a8b5843249e2e8e6165848aae0c9fb4b17 /django | |
| parent | 7288e1b02b2504b1694fe14df2d81e6a354c5610 (diff) | |
Fixed all E226 violations
Diffstat (limited to 'django')
37 files changed, 70 insertions, 70 deletions
diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index 534f4c4681..777bfbac81 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -34,12 +34,12 @@ def paginator_number(cl, i): if i == DOT: return '... ' elif i == cl.page_num: - return format_html('<span class="this-page">{0}</span> ', i+1) + return format_html('<span class="this-page">{0}</span> ', i + 1) else: return format_html('<a href="{0}"{1}>{2}</a> ', cl.get_query_string({PAGE_VAR: i}), - mark_safe(' class="end"' if i == cl.paginator.num_pages-1 else ''), - i+1) + mark_safe(' class="end"' if i == cl.paginator.num_pages - 1 else ''), + i + 1) @register.inclusion_tag('admin/pagination.html') diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py index ed3668907a..82f6c42721 100644 --- a/django/contrib/admin/utils.py +++ b/django/contrib/admin/utils.py @@ -412,7 +412,7 @@ def reverse_field_path(model, path): for piece in pieces: field, model, direct, m2m = parent._meta.get_field_by_name(piece) # skip trailing data field if extant: - if len(reversed_path) == len(pieces)-1: # final iteration + if len(reversed_path) == len(pieces) - 1: # final iteration try: get_model_from_relation(field) except NotRelationField: diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index a0ffef90f4..4b0da928a2 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -236,7 +236,7 @@ class ChangeList(six.with_metaclass(RenameChangeListMethods)): result_list = self.queryset._clone() else: try: - result_list = paginator.page(self.page_num+1).object_list + result_list = paginator.page(self.page_num + 1).object_list except InvalidPage: raise IncorrectLookupParameters diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py index 08ebb0a8e7..d9108d6c58 100644 --- a/django/contrib/gis/geos/mutable_list.py +++ b/django/contrib/gis/geos/mutable_list.py @@ -145,7 +145,7 @@ class ListMixin(object): del self[:] else: cache = list(self) - for i in range(n-1): + for i in range(n - 1): self.extend(cache) return self diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py index ef8eb27de5..f617f1fe76 100644 --- a/django/contrib/gis/geos/polygon.py +++ b/django/contrib/gis/geos/polygon.py @@ -134,7 +134,7 @@ class Polygon(GEOSGeometry): return capi.get_extring(self.ptr) else: # Getting the interior ring, have to subtract 1 from the index. - return capi.get_intring(self.ptr, index-1) + return capi.get_intring(self.ptr, index - 1) def _get_single_external(self, index): return GEOSGeometry(capi.geom_clone(self._get_single_internal(index)), srid=self.srid) @@ -170,6 +170,6 @@ class Polygon(GEOSGeometry): @property def kml(self): "Returns the KML representation of this Polygon." - inner_kml = ''.join("<innerBoundaryIs>%s</innerBoundaryIs>" % self[i+1].kml + inner_kml = ''.join("<innerBoundaryIs>%s</innerBoundaryIs>" % self[i + 1].kml for i in xrange(self.num_interior_rings)) return "<Polygon><outerBoundaryIs>%s</outerBoundaryIs>%s</Polygon>" % (self[0].kml, inner_kml) diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py index 59cd9a32cc..3f0ce0652b 100644 --- a/django/contrib/gis/geos/tests/test_geos.py +++ b/django/contrib/gis/geos/tests/test_geos.py @@ -1081,11 +1081,11 @@ class GEOSTest(unittest.TestCase, TestDataMixin): self.assertEqual(ls.project(Point(0, 20)), 10.0) self.assertEqual(ls.project(Point(7, 6)), 24) - self.assertEqual(ls.project_normalized(Point(0, 20)), 1.0/3) + self.assertEqual(ls.project_normalized(Point(0, 20)), 1.0 / 3) self.assertEqual(ls.interpolate(10), Point(0, 10)) self.assertEqual(ls.interpolate(24), Point(10, 6)) - self.assertEqual(ls.interpolate_normalized(1.0/3), Point(0, 10)) + self.assertEqual(ls.interpolate_normalized(1.0 / 3), Point(0, 10)) self.assertEqual(mls.project(Point(0, 20)), 10) self.assertEqual(mls.project(Point(7, 6)), 16) diff --git a/django/contrib/gis/geos/tests/test_mutable_list.py b/django/contrib/gis/geos/tests/test_mutable_list.py index 5340dac99d..9cdd80bc17 100644 --- a/django/contrib/gis/geos/tests/test_mutable_list.py +++ b/django/contrib/gis/geos/tests/test_mutable_list.py @@ -349,8 +349,8 @@ class ListMixinTest(unittest.TestCase): ul.sort() self.assertEqual(pl[:], ul[:], 'sort') mid = pl[len(pl) // 2] - pl.sort(key=lambda x: (mid-x)**2) - ul.sort(key=lambda x: (mid-x)**2) + pl.sort(key=lambda x: (mid - x) ** 2) + ul.sort(key=lambda x: (mid - x) ** 2) self.assertEqual(pl[:], ul[:], 'sort w/ key') pl.insert(0, pl.pop()) @@ -359,8 +359,8 @@ class ListMixinTest(unittest.TestCase): ul.sort(reverse=True) self.assertEqual(pl[:], ul[:], 'sort w/ reverse') mid = pl[len(pl) // 2] - pl.sort(key=lambda x: (mid-x)**2) - ul.sort(key=lambda x: (mid-x)**2) + pl.sort(key=lambda x: (mid - x) ** 2) + ul.sort(key=lambda x: (mid - x) ** 2) self.assertEqual(pl[:], ul[:], 'sort w/ key') def test_12_arithmetic(self): diff --git a/django/contrib/gis/maps/google/zoom.py b/django/contrib/gis/maps/google/zoom.py index 22b3ceac1d..e6e5d9217e 100644 --- a/django/contrib/gis/maps/google/zoom.py +++ b/django/contrib/gis/maps/google/zoom.py @@ -79,7 +79,7 @@ class GoogleZoom(object): fac = min(max(sin(DTOR * lat), -0.9999), 0.9999) # Calculating the pixel y coordinate. - px_y = round(npix + (0.5 * log((1 + fac)/(1 - fac)) * (-1.0 * self._radpp[zoom]))) + px_y = round(npix + (0.5 * log((1 + fac) / (1 - fac)) * (-1.0 * self._radpp[zoom]))) # Returning the pixel x, y to the caller of the function. return (px_x, px_y) @@ -116,8 +116,8 @@ class GoogleZoom(object): # Getting the lower-left and upper-right lat/lon coordinates # for the bounding box of the tile. - ll = self.pixel_to_lonlat((px[0]-delta, px[1]-delta), zoom) - ur = self.pixel_to_lonlat((px[0]+delta, px[1]+delta), zoom) + ll = self.pixel_to_lonlat((px[0] - delta, px[1] - delta), zoom) + ur = self.pixel_to_lonlat((px[0] + delta, px[1] + delta), zoom) # Constructing the Polygon, representing the tile and returning. return Polygon(LinearRing(ll, (ll[0], ur[1]), ur, (ur[0], ll[1]), ll), srid=4326) @@ -143,10 +143,10 @@ class GoogleZoom(object): if (env_w > tile_w) or (env_h > tile_h): if z == 0: raise GoogleMapException('Geometry width and height should not exceed that of the Earth.') - return z-1 + return z - 1 # Otherwise, we've zoomed in to the max. - return self._nzoom-1 + return self._nzoom - 1 def get_width_height(self, extent): """ diff --git a/django/contrib/gis/sitemaps/views.py b/django/contrib/gis/sitemaps/views.py index 8dad5c505c..c4c08de8f5 100644 --- a/django/contrib/gis/sitemaps/views.py +++ b/django/contrib/gis/sitemaps/views.py @@ -32,7 +32,7 @@ def index(request, sitemaps): sites.append('%s://%s%s' % (protocol, current_site.domain, sitemap_url)) if pages > 1: - for page in range(2, pages+1): + for page in range(2, pages + 1): sites.append('%s://%s%s?p=%s' % (protocol, current_site.domain, sitemap_url, page)) xml = loader.render_to_string('sitemap_index.xml', {'sitemaps': sites}) return HttpResponse(xml, content_type='application/xml') diff --git a/django/contrib/gis/tests/test_measure.py b/django/contrib/gis/tests/test_measure.py index 1c4fa448d2..37a0d51dbb 100644 --- a/django/contrib/gis/tests/test_measure.py +++ b/django/contrib/gis/tests/test_measure.py @@ -94,7 +94,7 @@ class DistanceTest(unittest.TestCase): a5 = d1 * D(m=10) self.assertTrue(isinstance(a5, Area)) - self.assertEqual(a5.sq_m, 100*10) + self.assertEqual(a5.sq_m, 100 * 10) with self.assertRaises(TypeError): d1 *= D(m=1) diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py index 5f57bc1749..3ba087b967 100644 --- a/django/contrib/gis/utils/layermapping.py +++ b/django/contrib/gis/utils/layermapping.py @@ -600,7 +600,7 @@ class LayerMapping(object): for i, end in enumerate(indices): # Constructing the slice to use for this step; the last slice is # special (e.g, [100:] instead of [90:100]). - if i+1 == n_i: + if i + 1 == n_i: step_slice = slice(beg, None) else: step_slice = slice(beg, end) diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py index 9b5524da31..e33631a15d 100644 --- a/django/contrib/humanize/templatetags/humanize.py +++ b/django/contrib/humanize/templatetags/humanize.py @@ -148,7 +148,7 @@ def apnumber(value): return value if not 0 < value < 10: return value - return (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'), _('seven'), _('eight'), _('nine'))[value-1] + return (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'), _('seven'), _('eight'), _('nine'))[value - 1] # Perform the comparison in the default time zone when USE_TZ = True diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py index 13c34ea697..2c3151369a 100644 --- a/django/core/cache/backends/base.py +++ b/django/core/cache/backends/base.py @@ -233,9 +233,9 @@ class BaseCache(object): if value is None: raise ValueError("Key '%s' not found" % key) - self.set(key, value, version=version+delta) + self.set(key, value, version=version + delta) self.delete(key, version=version) - return version+delta + return version + delta def decr_version(self, key, delta=1, version=None): """Substracts delta from the cache version for the supplied key. Returns diff --git a/django/core/files/base.py b/django/core/files/base.py index 7abb94b1f2..b1325291c6 100644 --- a/django/core/files/base.py +++ b/django/core/files/base.py @@ -11,7 +11,7 @@ from django.utils.encoding import force_bytes, python_2_unicode_compatible @python_2_unicode_compatible class File(FileProxyMixin): - DEFAULT_CHUNK_SIZE = 64 * 2**10 + DEFAULT_CHUNK_SIZE = 64 * 2 ** 10 def __init__(self, file, name=None): self.file = file diff --git a/django/core/files/images.py b/django/core/files/images.py index e1d6091658..b289d789ad 100644 --- a/django/core/files/images.py +++ b/django/core/files/images.py @@ -65,7 +65,7 @@ def get_image_dimensions(file_or_path, close=False): raise if p.image: return p.image.size - chunk_size = chunk_size*2 + chunk_size *= 2 return None finally: if close: diff --git a/django/core/files/move.py b/django/core/files/move.py index fddee565b4..8aee5afaa6 100644 --- a/django/core/files/move.py +++ b/django/core/files/move.py @@ -38,7 +38,7 @@ def _samefile(src, dst): os.path.normcase(os.path.abspath(dst))) -def file_move_safe(old_file_name, new_file_name, chunk_size=1024*64, allow_overwrite=False): +def file_move_safe(old_file_name, new_file_name, chunk_size=1024 * 64, allow_overwrite=False): """ Moves a file from one location to another in the safest way possible. diff --git a/django/core/files/uploadedfile.py b/django/core/files/uploadedfile.py index b53a502068..aa076a8559 100644 --- a/django/core/files/uploadedfile.py +++ b/django/core/files/uploadedfile.py @@ -23,7 +23,7 @@ class UploadedFile(File): An ``UploadedFile`` object behaves somewhat like a file object and represents some file data that the user submitted with a form. """ - DEFAULT_CHUNK_SIZE = 64 * 2**10 + DEFAULT_CHUNK_SIZE = 64 * 2 ** 10 def __init__(self, file=None, name=None, content_type=None, size=None, charset=None, content_type_extra=None): super(UploadedFile, self).__init__(file, name) diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index de49f5e241..e24193c52b 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -317,7 +317,7 @@ class ManagementUtility(object): cword = int(os.environ['COMP_CWORD']) try: - curr = cwords[cword-1] + curr = cwords[cword - 1] except IndexError: curr = '' @@ -350,7 +350,7 @@ class ManagementUtility(object): options += [(s_opt.get_opt_string(), s_opt.nargs) for s_opt in subcommand_cls.option_list] # filter out previously specified options from available options - prev_opts = [x.split('=')[0] for x in cwords[1:cword-1]] + prev_opts = [x.split('=')[0] for x in cwords[1:cword - 1]] options = [opt for opt in options if opt[0] not in prev_opts] # filter options by current input diff --git a/django/core/management/commands/createcachetable.py b/django/core/management/commands/createcachetable.py index c375fc2b17..be6da1dbf0 100644 --- a/django/core/management/commands/createcachetable.py +++ b/django/core/management/commands/createcachetable.py @@ -69,7 +69,7 @@ class Command(BaseCommand): table_output.append(" ".join(field_output)) full_statement = ["CREATE TABLE %s (" % qn(tablename)] for i, line in enumerate(table_output): - full_statement.append(' %s%s' % (line, ',' if i < len(table_output)-1 else '')) + full_statement.append(' %s%s' % (line, ',' if i < len(table_output) - 1 else '')) full_statement.append(');') with transaction.commit_on_success_unless_managed(): curs = connection.cursor() diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py index 76b50916e0..13919144e5 100644 --- a/django/core/urlresolvers.py +++ b/django/core/urlresolvers.py @@ -147,7 +147,7 @@ def get_mod_func(callback): dot = callback.rindex('.') except ValueError: return callback, '' - return callback[:dot], callback[dot+1:] + return callback[:dot], callback[dot + 1:] class LocaleRegexProvider(object): diff --git a/django/db/migrations/operations/special.py b/django/db/migrations/operations/special.py index ef3f7169a5..f48d8cab05 100644 --- a/django/db/migrations/operations/special.py +++ b/django/db/migrations/operations/special.py @@ -33,7 +33,7 @@ class SeparateDatabaseAndState(Operation): base_state = to_state for pos, database_operation in enumerate(reversed(self.database_operations)): to_state = base_state.clone() - for dbop in self.database_operations[:-(pos+1)]: + for dbop in self.database_operations[:-(pos + 1)]: dbop.state_forwards(app_label, to_state) from_state = base_state.clone() database_operation.state_forwards(app_label, from_state) diff --git a/django/db/migrations/optimizer.py b/django/db/migrations/optimizer.py index 980eedddf7..fe527a5c3e 100644 --- a/django/db/migrations/optimizer.py +++ b/django/db/migrations/optimizer.py @@ -48,13 +48,13 @@ class MigrationOptimizer(object): new_operations = [] for i, operation in enumerate(operations): # Compare it to each operation after it - for j, other in enumerate(operations[i+1:]): + for j, other in enumerate(operations[i + 1:]): result = self.reduce(operation, other) if result is not None: # Optimize! Add result, then remaining others, then return new_operations.extend(result) - new_operations.extend(operations[i+1:i+1+j]) - new_operations.extend(operations[i+j+2:]) + new_operations.extend(operations[i + 1:i + 1 + j]) + new_operations.extend(operations[i + j + 2:]) return new_operations if not self.can_optimize_through(operation, other, app_label): new_operations.append(operation) diff --git a/django/db/models/query.py b/django/db/models/query.py index 5bfa68b071..1289e14755 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -1359,7 +1359,7 @@ def get_klass_info(klass, max_depth=0, cur_depth=0, requested=None, next = requested[f.name] else: next = None - klass_info = get_klass_info(f.rel.to, max_depth=max_depth, cur_depth=cur_depth+1, + klass_info = get_klass_info(f.rel.to, max_depth=max_depth, cur_depth=cur_depth + 1, requested=next, only_load=only_load) related_fields.append((f, klass_info)) diff --git a/django/forms/extras/widgets.py b/django/forms/extras/widgets.py index 95831679b8..7fd209f397 100644 --- a/django/forms/extras/widgets.py +++ b/django/forms/extras/widgets.py @@ -62,7 +62,7 @@ class SelectDateWidget(Widget): self.years = years else: this_year = datetime.date.today().year - self.years = range(this_year, this_year+10) + self.years = range(this_year, this_year + 10) # Optional dict of months to use in the "month" select box. if months: diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 9c8b790d59..625f597117 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -363,7 +363,7 @@ class BaseFormSet(object): if self.can_order: # Only pre-fill the ordering field for initial forms. if index is not None and index < self.initial_form_count(): - form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_('Order'), initial=index+1, required=False) + form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_('Order'), initial=index + 1, required=False) else: form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_('Order'), required=False) if self.can_delete: diff --git a/django/forms/models.py b/django/forms/models.py index 32f0f043ae..6d9a567926 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -572,7 +572,7 @@ class BaseModelFormSet(BaseFormSet): if i >= self.initial_form_count() and self.initial_extra: # Set initial values for extra forms try: - kwargs['initial'] = self.initial_extra[i-self.initial_form_count()] + kwargs['initial'] = self.initial_extra[i - self.initial_form_count()] except IndexError: pass return super(BaseModelFormSet, self)._construct_form(i, **kwargs) diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py index 21617255a8..1c64195f25 100644 --- a/django/http/multipartparser.py +++ b/django/http/multipartparser.py @@ -94,7 +94,7 @@ class MultiPartParser(object): # For compatibility with low-level network APIs (with 32-bit integers), # the chunk size should be < 2^31, but still divisible by 4. possible_sizes = [x.chunk_size for x in upload_handlers if x.chunk_size] - self._chunk_size = min([2**31-4] + possible_sizes) + self._chunk_size = min([2 ** 31 - 4] + possible_sizes) self._meta = META self._encoding = encoding or settings.DEFAULT_CHARSET @@ -267,7 +267,7 @@ class MultiPartParser(object): def IE_sanitize(self, filename): """Cleanup filename from Internet Explorer full paths.""" - return filename and filename[filename.rfind("\\")+1:].strip() + return filename and filename[filename.rfind("\\") + 1:].strip() class LazyStream(six.Iterator): @@ -512,11 +512,11 @@ class BoundaryIter(six.Iterator): end = index next = index + len(self._boundary) # backup over CRLF - last = max(0, end-1) - if data[last:last+1] == b'\n': + last = max(0, end - 1) + if data[last:last + 1] == b'\n': end -= 1 - last = max(0, end-1) - if data[last:last+1] == b'\r': + last = max(0, end - 1) + if data[last:last + 1] == b'\r': end -= 1 return end, next @@ -623,7 +623,7 @@ def parse_header(line): i = p.find(b'=') if i >= 0: name = p[:i].strip().lower().decode('ascii') - value = p[i+1:].strip() + value = p[i + 1:].strip() if len(value) >= 2 and value[:1] == value[-1:] == b'"': value = value[1:-1] value = value.replace(b'\\\\', b'\\').replace(b'\\"', b'"') diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index a4f0a89554..1bd54404b3 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -680,14 +680,14 @@ def unordered_list(value, autoescape=None): sublist_item = title title = '' elif i < list_length - 1: - next_item = list_[i+1] + next_item = list_[i + 1] if next_item and isinstance(next_item, (list, tuple)): # The next item is a sub-list. sublist_item = next_item # We've processed the next item now too. i += 1 if sublist_item: - sublist = _helper(sublist_item, tabs+1) + sublist = _helper(sublist_item, tabs + 1) sublist = '\n%s<ul>\n%s\n%s</ul>\n%s' % (indent, sublist, indent, indent) output.append('%s<li>%s%s</li>' % (indent, diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 77d63ab256..011d15ea65 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -171,7 +171,7 @@ class ForNode(Node): for i, item in enumerate(values): # Shortcuts for current loop iteration number. loop_dict['counter0'] = i - loop_dict['counter'] = i+1 + loop_dict['counter'] = i + 1 # Reverse counter iteration numbers. loop_dict['revcounter'] = len_values - i loop_dict['revcounter0'] = len_values - i - 1 @@ -832,7 +832,7 @@ def do_for(parser, token): raise TemplateSyntaxError("'for' tag received an invalid argument:" " %s" % token.contents) - sequence = parser.compile_filter(bits[in_index+1]) + sequence = parser.compile_filter(bits[in_index + 1]) nodelist_loop = parser.parse(('empty', 'endfor',)) token = parser.next_token() if token.contents == 'empty': diff --git a/django/template/smartif.py b/django/template/smartif.py index 4a9e2ef541..554a214cb6 100644 --- a/django/template/smartif.py +++ b/django/template/smartif.py @@ -158,7 +158,7 @@ class IfParser(object): i = 0 while i < l: token = tokens[i] - if token == "not" and i + 1 < l and tokens[i+1] == "in": + if token == "not" and i + 1 < l and tokens[i + 1] == "in": token = "not in" i += 1 # skip 'in' mapped_tokens.append(self.translate_token(token)) diff --git a/django/test/runner.py b/django/test/runner.py index 148f6a3e17..44adaab141 100644 --- a/django/test/runner.py +++ b/django/test/runner.py @@ -203,10 +203,10 @@ def reorder_suite(suite, classes): """ class_count = len(classes) suite_class = type(suite) - bins = [suite_class() for i in range(class_count+1)] + bins = [suite_class() for i in range(class_count + 1)] partition_suite(suite, classes, bins) for i in range(class_count): - bins[0].addTests(bins[i+1]) + bins[0].addTests(bins[i + 1]) return bins[0] diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py index 78483f2d4c..1640f9ae5a 100644 --- a/django/utils/dateformat.py +++ b/django/utils/dateformat.py @@ -303,7 +303,7 @@ class DateFormat(TimeFormat): weekday = self.data.weekday() + 1 day_of_year = self.z() if day_of_year <= (8 - jan1_weekday) and jan1_weekday > 4: - if jan1_weekday == 5 or (jan1_weekday == 6 and calendar.isleap(self.data.year-1)): + if jan1_weekday == 5 or (jan1_weekday == 6 and calendar.isleap(self.data.year - 1)): week_number = 53 else: week_number = 52 diff --git a/django/utils/datetime_safe.py b/django/utils/datetime_safe.py index a584011db5..6cd0bf1cdd 100644 --- a/django/utils/datetime_safe.py +++ b/django/utils/datetime_safe.py @@ -83,8 +83,8 @@ def strftime(dt, fmt): s1 = time.strftime(fmt, (year,) + timetuple[1:]) sites1 = _findall(s1, str(year)) - s2 = time.strftime(fmt, (year+28,) + timetuple[1:]) - sites2 = _findall(s2, str(year+28)) + s2 = time.strftime(fmt, (year + 28,) + timetuple[1:]) + sites2 = _findall(s2, str(year + 28)) sites = [] for site in sites1: @@ -94,5 +94,5 @@ def strftime(dt, fmt): s = s1 syear = "%04d" % (dt.year,) for site in sites: - s = s[:site] + syear + s[site+4:] + s = s[:site] + syear + s[site + 4:] return s diff --git a/django/utils/jslex.py b/django/utils/jslex.py index 8c481fd1d8..1b47230b6d 100644 --- a/django/utils/jslex.py +++ b/django/utils/jslex.py @@ -25,7 +25,7 @@ def literals(choices, prefix="", suffix=""): individually. """ - return "|".join(prefix+re.escape(c)+suffix for c in choices.split()) + return "|".join(prefix + re.escape(c) + suffix for c in choices.split()) class Lexer(object): diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py index 9e3beb0f7d..69f32bc243 100644 --- a/django/utils/translation/trans_null.py +++ b/django/utils/translation/trans_null.py @@ -59,7 +59,7 @@ gettext_noop = gettext_lazy = _ = gettext def to_locale(language): p = language.find('-') if p >= 0: - return language[:p].lower()+'_'+language[p+1:].upper() + return language[:p].lower() + '_' + language[p + 1:].upper() else: return language.lower() diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index d78b6d6412..0f08056778 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -55,12 +55,12 @@ def to_locale(language, to_lower=False): p = language.find('-') if p >= 0: if to_lower: - return language[:p].lower()+'_'+language[p+1:].lower() + return language[:p].lower() + '_' + language[p + 1:].lower() else: # Get correct locale for sr-latn - if len(language[p+1:]) > 2: - return language[:p].lower()+'_'+language[p+1].upper()+language[p+2:].lower() - return language[:p].lower()+'_'+language[p+1:].upper() + if len(language[p + 1:]) > 2: + return language[:p].lower() + '_' + language[p + 1].upper() + language[p + 2:].lower() + return language[:p].lower() + '_' + language[p + 1:].upper() else: return language.lower() @@ -69,7 +69,7 @@ def to_language(locale): """Turns a locale name (en_US) into a language name (en-us).""" p = locale.find('_') if p >= 0: - return locale[:p].lower()+'-'+locale[p+1:].lower() + return locale[:p].lower() + '-' + locale[p + 1:].lower() else: return locale.lower() diff --git a/django/views/debug.py b/django/views/debug.py index 0ee5d588c7..2706da6268 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -26,8 +26,8 @@ def linebreak_iter(template_source): yield 0 p = template_source.find('\n') while p >= 0: - yield p+1 - p = template_source.find('\n', p+1) + yield p + 1 + p = template_source.find('\n', p + 1) yield len(template_source) + 1 @@ -302,7 +302,7 @@ class ExceptionReporter(object): end = getattr(self.exc_value, 'end', None) if start is not None and end is not None: unicode_str = self.exc_value.args[1] - unicode_hint = smart_text(unicode_str[max(start-5, 0):min(end+5, len(unicode_str))], 'ascii', errors='replace') + unicode_hint = smart_text(unicode_str[max(start - 5, 0):min(end + 5, len(unicode_str))], 'ascii', errors='replace') from django import get_version c = { 'is_email': self.is_email, @@ -419,7 +419,7 @@ class ExceptionReporter(object): pre_context = source[lower_bound:lineno] context_line = source[lineno] - post_context = source[lineno+1:upper_bound] + post_context = source[lineno + 1:upper_bound] return lower_bound, pre_context, context_line, post_context |
