Skip to content

Commit fdf1d94

Browse files
committed
End of pep8
1 parent 19b29df commit fdf1d94

File tree

2 files changed

+224
-116
lines changed

2 files changed

+224
-116
lines changed

tagging/templatetags/tagging_tags.py

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,20 @@ def do_tags_for_model(parser, token):
102102
bits = token.contents.split()
103103
len_bits = len(bits)
104104
if len_bits not in (4, 6):
105-
raise TemplateSyntaxError(_('%s tag requires either three or five arguments') % bits[0])
105+
raise TemplateSyntaxError(
106+
_('%s tag requires either three or five arguments') % bits[0])
106107
if bits[2] != 'as':
107-
raise TemplateSyntaxError(_("second argument to %s tag must be 'as'") % bits[0])
108+
raise TemplateSyntaxError(
109+
_("second argument to %s tag must be 'as'") % bits[0])
108110
if len_bits == 6:
109111
if bits[4] != 'with':
110-
raise TemplateSyntaxError(_("if given, fourth argument to %s tag must be 'with'") % bits[0])
112+
raise TemplateSyntaxError(
113+
_("if given, fourth argument to %s tag must be 'with'") %
114+
bits[0])
111115
if bits[5] != 'counts':
112-
raise TemplateSyntaxError(_("if given, fifth argument to %s tag must be 'counts'") % bits[0])
116+
raise TemplateSyntaxError(
117+
_("if given, fifth argument to %s tag must be 'counts'") %
118+
bits[0])
113119
if len_bits == 4:
114120
return TagsForModelNode(bits[1], bits[3], counts=False)
115121
else:
@@ -149,50 +155,65 @@ def do_tag_cloud_for_model(parser, token):
149155
Examples::
150156
151157
{% tag_cloud_for_model products.Widget as widget_tags %}
152-
{% tag_cloud_for_model products.Widget as widget_tags with steps=9 min_count=3 distribution=log %}
158+
{% tag_cloud_for_model products.Widget as widget_tags
159+
with steps=9 min_count=3 distribution=log %}
153160
154161
"""
155162
bits = token.contents.split()
156163
len_bits = len(bits)
157164
if len_bits != 4 and len_bits not in range(6, 9):
158-
raise TemplateSyntaxError(_('%s tag requires either three or between five and seven arguments') % bits[0])
165+
raise TemplateSyntaxError(
166+
_('%s tag requires either three or between five '
167+
'and seven arguments') % bits[0])
159168
if bits[2] != 'as':
160-
raise TemplateSyntaxError(_("second argument to %s tag must be 'as'") % bits[0])
169+
raise TemplateSyntaxError(
170+
_("second argument to %s tag must be 'as'") % bits[0])
161171
kwargs = {}
162172
if len_bits > 5:
163173
if bits[4] != 'with':
164-
raise TemplateSyntaxError(_("if given, fourth argument to %s tag must be 'with'") % bits[0])
174+
raise TemplateSyntaxError(
175+
_("if given, fourth argument to %s tag must be 'with'") %
176+
bits[0])
165177
for i in range(5, len_bits):
166178
try:
167179
name, value = bits[i].split('=')
168180
if name == 'steps' or name == 'min_count':
169181
try:
170182
kwargs[str(name)] = int(value)
171183
except ValueError:
172-
raise TemplateSyntaxError(_("%(tag)s tag's '%(option)s' option was not a valid integer: '%(value)s'") % {
173-
'tag': bits[0],
174-
'option': name,
175-
'value': value,
176-
})
184+
raise TemplateSyntaxError(
185+
_("%(tag)s tag's '%(option)s' option was not "
186+
"a valid integer: '%(value)s'") % {
187+
'tag': bits[0],
188+
'option': name,
189+
'value': value,
190+
})
177191
elif name == 'distribution':
178192
if value in ['linear', 'log']:
179-
kwargs[str(name)] = {'linear': LINEAR, 'log': LOGARITHMIC}[value]
193+
kwargs[str(name)] = {'linear': LINEAR,
194+
'log': LOGARITHMIC}[value]
180195
else:
181-
raise TemplateSyntaxError(_("%(tag)s tag's '%(option)s' option was not a valid choice: '%(value)s'") % {
196+
raise TemplateSyntaxError(
197+
_("%(tag)s tag's '%(option)s' option was not "
198+
"a valid choice: '%(value)s'") % {
199+
'tag': bits[0],
200+
'option': name,
201+
'value': value,
202+
})
203+
else:
204+
raise TemplateSyntaxError(
205+
_("%(tag)s tag was given an "
206+
"invalid option: '%(option)s'") % {
182207
'tag': bits[0],
183208
'option': name,
184-
'value': value,
185209
})
186-
else:
187-
raise TemplateSyntaxError(_("%(tag)s tag was given an invalid option: '%(option)s'") % {
210+
except ValueError:
211+
raise TemplateSyntaxError(
212+
_("%(tag)s tag was given a badly "
213+
"formatted option: '%(option)s'") % {
188214
'tag': bits[0],
189-
'option': name,
215+
'option': bits[i],
190216
})
191-
except ValueError:
192-
raise TemplateSyntaxError(_("%(tag)s tag was given a badly formatted option: '%(option)s'") % {
193-
'tag': bits[0],
194-
'option': bits[i],
195-
})
196217
return TagCloudForModelNode(bits[1], bits[3], **kwargs)
197218

198219

@@ -211,9 +232,11 @@ def do_tags_for_object(parser, token):
211232
"""
212233
bits = token.contents.split()
213234
if len(bits) != 4:
214-
raise TemplateSyntaxError(_('%s tag requires exactly three arguments') % bits[0])
235+
raise TemplateSyntaxError(
236+
_('%s tag requires exactly three arguments') % bits[0])
215237
if bits[2] != 'as':
216-
raise TemplateSyntaxError(_("second argument to %s tag must be 'as'") % bits[0])
238+
raise TemplateSyntaxError(
239+
_("second argument to %s tag must be 'as'") % bits[0])
217240
return TagsForObjectNode(bits[1], bits[3])
218241

219242

@@ -237,11 +260,14 @@ def do_tagged_objects(parser, token):
237260
"""
238261
bits = token.contents.split()
239262
if len(bits) != 6:
240-
raise TemplateSyntaxError(_('%s tag requires exactly five arguments') % bits[0])
263+
raise TemplateSyntaxError(
264+
_('%s tag requires exactly five arguments') % bits[0])
241265
if bits[2] != 'in':
242-
raise TemplateSyntaxError(_("second argument to %s tag must be 'in'") % bits[0])
266+
raise TemplateSyntaxError(
267+
_("second argument to %s tag must be 'in'") % bits[0])
243268
if bits[4] != 'as':
244-
raise TemplateSyntaxError(_("fourth argument to %s tag must be 'as'") % bits[0])
269+
raise TemplateSyntaxError(
270+
_("fourth argument to %s tag must be 'as'") % bits[0])
245271
return TaggedObjectsNode(bits[1], bits[3], bits[5])
246272

247273

0 commit comments

Comments
 (0)