Permalink
Browse files

Fixed all E226 violations

  • Loading branch information...
1 parent 7288e1b commit c347f78cc1b2a06958f692f0622deceac534dc6b @alex alex committed Nov 3, 2013
Showing with 150 additions and 150 deletions.
  1. +3 −3 django/contrib/admin/templatetags/admin_list.py
  2. +1 −1 django/contrib/admin/utils.py
  3. +1 −1 django/contrib/admin/views/main.py
  4. +1 −1 django/contrib/gis/geos/mutable_list.py
  5. +2 −2 django/contrib/gis/geos/polygon.py
  6. +2 −2 django/contrib/gis/geos/tests/test_geos.py
  7. +4 −4 django/contrib/gis/geos/tests/test_mutable_list.py
  8. +5 −5 django/contrib/gis/maps/google/zoom.py
  9. +1 −1 django/contrib/gis/sitemaps/views.py
  10. +1 −1 django/contrib/gis/tests/test_measure.py
  11. +1 −1 django/contrib/gis/utils/layermapping.py
  12. +1 −1 django/contrib/humanize/templatetags/humanize.py
  13. +2 −2 django/core/cache/backends/base.py
  14. +1 −1 django/core/files/base.py
  15. +1 −1 django/core/files/images.py
  16. +1 −1 django/core/files/move.py
  17. +1 −1 django/core/files/uploadedfile.py
  18. +2 −2 django/core/management/__init__.py
  19. +1 −1 django/core/management/commands/createcachetable.py
  20. +1 −1 django/core/urlresolvers.py
  21. +1 −1 django/db/migrations/operations/special.py
  22. +3 −3 django/db/migrations/optimizer.py
  23. +1 −1 django/db/models/query.py
  24. +1 −1 django/forms/extras/widgets.py
  25. +1 −1 django/forms/formsets.py
  26. +1 −1 django/forms/models.py
  27. +7 −7 django/http/multipartparser.py
  28. +2 −2 django/template/defaultfilters.py
  29. +2 −2 django/template/defaulttags.py
  30. +1 −1 django/template/smartif.py
  31. +2 −2 django/test/runner.py
  32. +1 −1 django/utils/dateformat.py
  33. +3 −3 django/utils/datetime_safe.py
  34. +1 −1 django/utils/jslex.py
  35. +1 −1 django/utils/translation/trans_null.py
  36. +5 −5 django/utils/translation/trans_real.py
  37. +4 −4 django/views/debug.py
  38. +2 −2 docs/_ext/literals_to_xrefs.py
  39. +1 −1 extras/csrf_migration_helper.py
  40. +1 −1 setup.cfg
  41. +1 −1 tests/admin_filters/tests.py
  42. +4 −4 tests/aggregation_regress/tests.py
  43. +4 −4 tests/bulk_create/tests.py
  44. +4 −4 tests/cache/tests.py
  45. +18 −18 tests/defaultfilters/tests.py
  46. +1 −1 tests/expressions/tests.py
  47. +2 −2 tests/forms_tests/tests/test_fields.py
  48. +14 −14 tests/lookup/tests.py
  49. +1 −1 tests/requests/tests.py
  50. +3 −3 tests/sites_framework/tests.py
  51. +24 −24 tests/utils_tests/test_timesince.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')
@@ -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:
@@ -236,7 +236,7 @@ def get_results(self, request):
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
@@ -145,7 +145,7 @@ def __imul__(self, n):
del self[:]
else:
cache = list(self)
- for i in range(n-1):
+ for i in range(n - 1):
self.extend(cache)
return self
@@ -134,7 +134,7 @@ def _get_single_internal(self, index):
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 @@ def tuple(self):
@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)
@@ -1081,11 +1081,11 @@ def test_linearref(self):
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)
@@ -349,8 +349,8 @@ def test_11_sorting(self):
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 @@ def test_11_sorting(self):
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):
@@ -79,7 +79,7 @@ def lonlat_to_pixel(self, lonlat, zoom):
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 @@ def tile(self, lonlat, zoom):
# 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 @@ def get_zoom(self, geom):
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):
"""
@@ -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')
@@ -94,7 +94,7 @@ def testMultiplication(self):
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)
@@ -600,7 +600,7 @@ def _save(feat_range=default_range, num_feat=0, num_saved=0):
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)
@@ -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
@@ -233,9 +233,9 @@ def incr_version(self, key, delta=1, version=None):
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
@@ -11,7 +11,7 @@
@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
@@ -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:
@@ -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.
@@ -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)
@@ -317,7 +317,7 @@ def autocomplete(self):
cword = int(os.environ['COMP_CWORD'])
try:
- curr = cwords[cword-1]
+ curr = cwords[cword - 1]
except IndexError:
curr = ''
@@ -350,7 +350,7 @@ def autocomplete(self):
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
@@ -69,7 +69,7 @@ def create_table(self, database, tablename):
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()
@@ -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):
@@ -33,7 +33,7 @@ def database_backwards(self, app_label, schema_editor, from_state, to_state):
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)
@@ -48,13 +48,13 @@ def optimize_inner(self, operations, app_label=None):
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)
@@ -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))
@@ -62,7 +62,7 @@ def __init__(self, attrs=None, years=None, required=True, months=None):
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:
@@ -363,7 +363,7 @@ def add_fields(self, form, index):
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:
@@ -572,7 +572,7 @@ def _construct_form(self, i, **kwargs):
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)
@@ -94,7 +94,7 @@ def __init__(self, META, input_data, upload_handlers, encoding=None):
# 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 @@ def handle_file_complete(self, old_field_name, counters):
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 @@ def _find_boundary(self, data, eof=False):
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'"')
@@ -680,14 +680,14 @@ def _helper(list_, tabs=1):
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,
@@ -171,7 +171,7 @@ def render(self, context):
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':
@@ -158,7 +158,7 @@ def __init__(self, tokens):
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))
Oops, something went wrong.

0 comments on commit c347f78

Please sign in to comment.