Skip to content

Commit

Permalink
Fix E128 errors in horizon/
Browse files Browse the repository at this point in the history
E128 continuation line under-indented for visual indent

Partial-Bug: #1375929
Change-Id: If4cc09995a74b68a6b037ea8999cebe09c750e65
  • Loading branch information
amotoki committed Oct 15, 2014
1 parent 9d846d1 commit 5dfca25
Show file tree
Hide file tree
Showing 20 changed files with 136 additions and 80 deletions.
9 changes: 6 additions & 3 deletions horizon/base.py
Expand Up @@ -510,13 +510,15 @@ def _decorated_urls(self):
continue
url_slug = panel.slug.replace('.', '/')
urlpatterns += patterns('',
url(r'^%s/' % url_slug, include(panel._decorated_urls)))
url(r'^%s/' % url_slug,
include(panel._decorated_urls)))
# Now the default view, which should come last
if not default_panel:
raise NotRegistered('The default panel "%s" is not registered.'
% self.default_panel)
urlpatterns += patterns('',
url(r'', include(default_panel._decorated_urls)))
url(r'',
include(default_panel._decorated_urls)))

# Require login if not public.
if not self.public:
Expand Down Expand Up @@ -835,7 +837,8 @@ def _urls(self):
# Compile the dynamic urlconf.
for dash in self._registry.values():
urlpatterns += patterns('',
url(r'^%s/' % dash.slug, include(dash._decorated_urls)))
url(r'^%s/' % dash.slug,
include(dash._decorated_urls)))

# Return the three arguments to django.conf.urls.include
return urlpatterns, self.namespace, self.slug
Expand Down
2 changes: 1 addition & 1 deletion horizon/forms/fields.py
Expand Up @@ -173,7 +173,7 @@ def get_title(data):
])
"""
def __init__(self, attrs=None, choices=(), data_attrs=(), transform=None,
transform_html_attrs=None):
transform_html_attrs=None):
self.data_attrs = data_attrs
self.transform = transform
self.transform_html_attrs = transform_html_attrs
Expand Down
9 changes: 6 additions & 3 deletions horizon/site_urls.py
Expand Up @@ -24,12 +24,14 @@

from horizon.test.jasmine import jasmine

urlpatterns = patterns('horizon.views',
urlpatterns = patterns(
'horizon.views',
url(r'^home/$', 'user_home', name='user_home')
)

# Client-side i18n URLconf.
urlpatterns += patterns('',
urlpatterns += patterns(
'',
url(r'^i18n/js/(?P<packages>\S+?)/$',
'django.views.i18n.javascript_catalog',
name='jsi18n'),
Expand All @@ -40,7 +42,8 @@
)

if settings.DEBUG:
urlpatterns += patterns('',
urlpatterns += patterns(
'',
url(r'^qunit/$',
TemplateView.as_view(template_name="horizon/qunit.html"),
name='qunit_tests'),
Expand Down
8 changes: 5 additions & 3 deletions horizon/tables/actions.py
Expand Up @@ -263,7 +263,7 @@ def __init__(self, single_func=None, multiple_func=None, handle_func=None,
self.requires_input = kwargs.get('requires_input', True)
self.verbose_name = kwargs.get('verbose_name', self.name.title())
self.verbose_name_plural = kwargs.get('verbose_name_plural',
"%ss" % self.verbose_name)
"%ss" % self.verbose_name)
self.allowed_data_types = kwargs.get('allowed_data_types', [])
self.icon = kwargs.get('icon', None)

Expand Down Expand Up @@ -465,7 +465,8 @@ def __init__(self, **kwargs):
self.icon = "search"

if self.filter_type == 'server' and self.filter_choices is None:
raise NotImplementedError('A FilterAction object with the '
raise NotImplementedError(
'A FilterAction object with the '
'filter_type attribute set to "server" must also have a '
'filter_choices attribute.')

Expand Down Expand Up @@ -686,7 +687,8 @@ def __init__(self, **kwargs):
self.success_url = kwargs.get('success_url', None)
# If setting a default name, don't initialize it too early
self.verbose_name = kwargs.get('verbose_name', self._get_action_name)
self.verbose_name_plural = kwargs.get('verbose_name_plural',
self.verbose_name_plural = kwargs.get(
'verbose_name_plural',
lambda: self._get_action_name('plural'))

self.current_present_action = 0
Expand Down
18 changes: 8 additions & 10 deletions horizon/tables/base.py
Expand Up @@ -992,8 +992,8 @@ def __init__(self, options):
'context_var_name',
'table'))
self.actions_column = getattr(options,
'actions_column',
len(self.row_actions) > 0)
'actions_column',
len(self.row_actions) > 0)
self.multi_select = getattr(options,
'multi_select',
len(self.table_actions) > 0)
Expand Down Expand Up @@ -1186,13 +1186,11 @@ def filtered_data(self):
if valid_method or needs_preloading:
filter_field = self.get_filter_field()
if self._meta.mixed_data_type:
self._filtered_data = action.data_type_filter(self,
self.data,
filter_string)
self._filtered_data = action.data_type_filter(
self, self.data, filter_string)
elif not action.is_api_filter(filter_field):
self._filtered_data = action.filter(self,
self.data,
filter_string)
self._filtered_data = action.filter(
self, self.data, filter_string)
return self._filtered_data

def slugify_name(self):
Expand Down Expand Up @@ -1298,7 +1296,7 @@ def get_object_by_id(self, lookup):
matches.append(datum)
if len(matches) > 1:
raise ValueError("Multiple matches were returned for that id: %s."
% matches)
% matches)
if not matches:
raise exceptions.Http302(self.get_absolute_url(),
_('No match returned for the id "%s".')
Expand Down Expand Up @@ -1609,7 +1607,7 @@ def maybe_handle(self):
table_name, action_name, obj_id = self.check_handler(request)
if table_name == self.name and action_name:
action_names = [action.name for action in
self.base_actions.values() if not action.preempt]
self.base_actions.values() if not action.preempt]
# do not run preemptive actions here
if action_name in action_names:
return self.take_action(action_name, obj_id)
Expand Down
4 changes: 2 additions & 2 deletions horizon/tables/formset.py
Expand Up @@ -38,7 +38,7 @@ def __init__(self, *args, **kwargs):
else:
if self.field.errors:
self.attrs['class'] = (self.attrs.get('class', '') +
' error form-group')
' error form-group')
self.attrs['title'] = ' '.join(
unicode(error) for error in self.field.errors)

Expand All @@ -64,7 +64,7 @@ def __init__(self, column, datum, form):

def render(self):
return loader.render_to_string(self.template_path,
{"row": self, "form": self.form})
{"row": self, "form": self.form})


class FormsetDataTableMixin(object):
Expand Down
2 changes: 1 addition & 1 deletion horizon/templatetags/parse_date.py
Expand Up @@ -35,7 +35,7 @@ def render(self, datestring):
datetime.
"""
formats = ["%Y-%m-%dT%H:%M:%S.%f", "%Y-%m-%d %H:%M:%S.%f",
"%Y-%m-%dT%H:%M:%S", "%Y-%m-%d %H:%M:%S"]
"%Y-%m-%dT%H:%M:%S", "%Y-%m-%d %H:%M:%S"]
if datestring:
for format in formats:
try:
Expand Down
6 changes: 3 additions & 3 deletions horizon/templatetags/shellfilter.py
Expand Up @@ -22,9 +22,9 @@
def shellfilter(value):
"""Replace HTML chars for shell usage."""
replacements = {'\\': '\\\\',
'`': '\`',
"'": "\\'",
'"': '\\"'}
'`': '\`',
"'": "\\'",
'"': '\\"'}
for search, repl in replacements.items():
value = value.replace(search, repl)
return safestring.mark_safe(value)
4 changes: 2 additions & 2 deletions horizon/templatetags/sizeformat.py
Expand Up @@ -47,12 +47,12 @@ def filesizeformat(bytes, filesize_number_format):
bytes = float(bytes)
except (TypeError, ValueError, UnicodeDecodeError):
return ungettext_lazy("%(size)d Byte",
"%(size)d Bytes", 0) % {'size': 0}
"%(size)d Bytes", 0) % {'size': 0}

if bytes < 1024:
bytes = int(bytes)
return ungettext_lazy("%(size)d Byte",
"%(size)d Bytes", bytes) % {'size': bytes}
"%(size)d Bytes", bytes) % {'size': bytes}
if bytes < 1024 * 1024:
return _("%s KB") % \
filesize_number_format(bytes / 1024)
Expand Down
10 changes: 6 additions & 4 deletions horizon/test/settings.py
Expand Up @@ -195,12 +195,14 @@

if xstatic.main.XStatic(xstatic.pkg.jquery_ui).version.startswith('1.10.'):
# The 1.10.x versions already contain the 'ui' directory.
STATICFILES_DIRS.append(('horizon/lib/jquery-ui',
xstatic.main.XStatic(xstatic.pkg.jquery_ui).base_dir))
STATICFILES_DIRS.append(
('horizon/lib/jquery-ui',
xstatic.main.XStatic(xstatic.pkg.jquery_ui).base_dir))
else:
# Newer versions dropped the directory, add it to keep the path the same.
STATICFILES_DIRS.append(('horizon/lib/jquery-ui/ui',
xstatic.main.XStatic(xstatic.pkg.jquery_ui).base_dir))
STATICFILES_DIRS.append(
('horizon/lib/jquery-ui/ui',
xstatic.main.XStatic(xstatic.pkg.jquery_ui).base_dir))

LOGGING = {
'version': 1,
Expand Down
15 changes: 14 additions & 1 deletion horizon/test/test_dashboards/cats/kittens/urls.py
@@ -1,8 +1,21 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from django.conf.urls import patterns
from django.conf.urls import url

from horizon.test.test_dashboards.cats.kittens.views import IndexView # noqa

urlpatterns = patterns('',
urlpatterns = patterns(
'',
url(r'^$', IndexView.as_view(), name='index'),
)
15 changes: 14 additions & 1 deletion horizon/test/test_dashboards/cats/tigers/urls.py
@@ -1,8 +1,21 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from django.conf.urls import patterns
from django.conf.urls import url

from horizon.test.test_dashboards.cats.tigers.views import IndexView # noqa

urlpatterns = patterns('',
urlpatterns = patterns(
'',
url(r'^$', IndexView.as_view(), name='index'),
)
15 changes: 14 additions & 1 deletion horizon/test/test_dashboards/dogs/puppies/urls.py
@@ -1,10 +1,23 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from django.conf.urls import patterns
from django.conf.urls import url

from horizon.test.test_dashboards.dogs.puppies.views import IndexView # noqa
from horizon.test.test_dashboards.dogs.puppies.views import TwoTabsView # noqa

urlpatterns = patterns('',
urlpatterns = patterns(
'',
url(r'^$', IndexView.as_view(), name='index'),
url(r'^tabs/$', TwoTabsView.as_view(), name='tabs'),
)
37 changes: 22 additions & 15 deletions horizon/test/tests/forms.py
Expand Up @@ -30,7 +30,8 @@ def _prepare_view(self, cls, request_headers, *args, **kwargs):
return view

def test_modal_form_mixin_hide_true_if_ajax(self):
view = self._prepare_view(forms.views.ModalFormView,
view = self._prepare_view(
forms.views.ModalFormView,
dict(HTTP_X_REQUESTED_WITH='XMLHttpRequest'))
context = view.get_context_data()
self.assertTrue(context['hide'])
Expand All @@ -55,7 +56,8 @@ def _test_form_mixin_add_to_field_header(self, add_field=False):
self.assertNotIn('add_to_field', context)

def test_template_name_change_based_on_ajax_request(self):
view = self._prepare_view(forms.views.ModalFormView,
view = self._prepare_view(
forms.views.ModalFormView,
dict(HTTP_X_REQUESTED_WITH='XMLHttpRequest'))
self.assertEqual('_' + view.template_name,
view.get_template_names())
Expand Down Expand Up @@ -105,20 +107,21 @@ class TestChoiceFieldForm(forms.SelfHandlingForm):
"label2": {"title": "This is choice 2"},
"label3": {"title": "This is choice 3"}}
name = forms.CharField(max_length=255,
label="Test Name",
help_text="Please enter a name")
label="Test Name",
help_text="Please enter a name")
test_choices = forms.ChoiceField(label="Test Choices",
required=False,
help_text="Testing drop down choices",
widget=forms.fields.SelectWidget(attrs={
'class': 'switchable',
'data-slug': 'source'},
transform_html_attrs=title_dic.get))
required=False,
help_text="Testing drop down choices",
widget=forms.fields.SelectWidget(
attrs={
'class': 'switchable',
'data-slug': 'source'},
transform_html_attrs=title_dic.get))

def __init__(self, request, *args, **kwargs):
super(TestChoiceFieldForm, self).__init__(request, *args, **kwargs)
choices = ([('choice1', 'label1'),
('choice2', 'label2')])
('choice2', 'label2')])
self.fields['test_choices'].choices = choices

def handle(self, request, data):
Expand All @@ -139,7 +142,11 @@ def _render_form(self):

def test_choicefield_title(self):
resp = self._render_form()
self.assertContains(resp, '<option value="choice1" '
'title="This is choice 1">label1</option>', count=1, html=True)
self.assertContains(resp, '<option value="choice2" '
'title="This is choice 2">label2</option>', count=1, html=True)
self.assertContains(
resp,
'<option value="choice1" title="This is choice 1">label1</option>',
count=1, html=True)
self.assertContains(
resp,
'<option value="choice2" title="This is choice 2">label2</option>',
count=1, html=True)
2 changes: 1 addition & 1 deletion horizon/test/tests/tables.py
Expand Up @@ -209,7 +209,7 @@ class MyTable(tables.DataTable):
tooltip_dict = {'up': {'title': 'service is up and running',
'style': 'color:green;cursor:pointer'},
'down': {'title': 'service is not available',
'style': 'color:red;cursor:pointer'}}
'style': 'color:red;cursor:pointer'}}
id = tables.Column('id', hidden=True, sortable=False)
name = tables.Column(get_name,
verbose_name="Verbose Name",
Expand Down
2 changes: 1 addition & 1 deletion horizon/test/tests/templatetags.py
Expand Up @@ -53,7 +53,7 @@ def test_site_branding_tag(self):
"""Test if site_branding tag renders the correct setting."""
rendered_str = self.render_template_tag("site_branding", "branding")
self.assertEqual(settings.SITE_BRANDING, rendered_str.strip(),
"tag site_branding renders %s" % rendered_str.strip())
"tag site_branding renders %s" % rendered_str.strip())

def test_size_format_filters(self):
size_str = ('5|diskgbformat', '10|diskgbformat',
Expand Down

0 comments on commit 5dfca25

Please sign in to comment.