Fix Flake8 style warnings in horizon/

Warnings H904, H307 and H405 are new or considerably changed, and will
be fixed in a separate patch.

Partial-bug: #1347472

Change-Id: Id9325a40d443f77242d3634002789501afbfc35a
Co-Authored-By: Juan M. Olle <juan.m.olle@intel.com>
This commit is contained in:
Pawel Skowron 2014-07-29 20:59:41 +02:00 committed by Juan Manuel Olle
parent 91f3fe9973
commit 791f384e3e
12 changed files with 57 additions and 35 deletions

View File

@ -44,8 +44,10 @@ class ResourceBrowserView(MultiTableView):
def get_tables(self): def get_tables(self):
tables = super(ResourceBrowserView, self).get_tables() tables = super(ResourceBrowserView, self).get_tables()
# Tells the navigation table what is selected. # Tells the navigation table what is selected.
navigation_table = tables[self.browser_class.navigation_table_class._meta.name] navigation_table = tables[
navigation_item = self.kwargs.get(self.browser_class.navigation_kwarg_name) self.browser_class.navigation_table_class._meta.name]
navigation_item = self.kwargs.get(
self.browser_class.navigation_kwarg_name)
navigation_table.current_item_id = navigation_item navigation_table.current_item_id = navigation_item
return tables return tables

View File

@ -21,6 +21,7 @@ from django.conf.urls import include # noqa
from django.conf.urls import patterns # noqa from django.conf.urls import patterns # noqa
from django.conf.urls import url # noqa from django.conf.urls import url # noqa
from django.views.generic import TemplateView # noqa from django.views.generic import TemplateView # noqa
from horizon.test.jasmine import jasmine from horizon.test.jasmine import jasmine
urlpatterns = patterns('horizon.views', urlpatterns = patterns('horizon.views',

View File

@ -14,7 +14,7 @@
from collections import defaultdict from collections import defaultdict
import logging import logging
import new import types
from django.conf import settings from django.conf import settings
from django.core import urlresolvers from django.core import urlresolvers
@ -293,12 +293,12 @@ class Action(BaseAction):
if not has_single: if not has_single:
def single(self, data_table, request, object_id): def single(self, data_table, request, object_id):
return self.handle(data_table, request, [object_id]) return self.handle(data_table, request, [object_id])
self.single = new.instancemethod(single, self) self.single = types.MethodType(single, self)
if not has_multiple and self.handles_multiple: if not has_multiple and self.handles_multiple:
def multiple(self, data_table, request, object_ids): def multiple(self, data_table, request, object_ids):
return self.handle(data_table, request, object_ids) return self.handle(data_table, request, object_ids)
self.multiple = new.instancemethod(multiple, self) self.multiple = types.MethodType(multiple, self)
def get_param_name(self): def get_param_name(self):
"""Returns the full POST parameter name for this action. """Returns the full POST parameter name for this action.

View File

@ -1,9 +1,20 @@
from django import forms # Licensed under the Apache License, Version 2.0 (the "License"); you may
from django.template import Context # not use this file except in compliance with the License. You may obtain
from django.template.loader import get_template # a copy of the License at
from django import template #
# 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 import forms
from django import template as django_template
register = django_template.Library()
register = template.Library()
@register.filter @register.filter
def bootstrap_form_field(element): def bootstrap_form_field(element):
@ -12,8 +23,10 @@ def bootstrap_form_field(element):
def add_input_classes(field): def add_input_classes(field):
if not is_checkbox(field) and not is_multiple_checkbox(field) and not is_radio(field) \ if (not is_checkbox(field) and
and not is_file(field): not is_multiple_checkbox(field) and
not is_radio(field) and
not is_file(field)):
field_classes = field.field.widget.attrs.get('class', '') field_classes = field.field.widget.attrs.get('class', '')
field_classes += ' form-control' field_classes += ' form-control'
field.field.widget.attrs['class'] = field_classes field.field.widget.attrs['class'] = field_classes
@ -21,8 +34,10 @@ def add_input_classes(field):
def render(element, markup_classes): def render(element, markup_classes):
add_input_classes(element) add_input_classes(element)
template = get_template("horizon/common/_bootstrap_form_field.html") template = django_template.loader.get_template(
context = Context({'field': element, 'classes': markup_classes}) "horizon/common/_bootstrap_form_field.html")
context = django_template.Context({'field': element,
'classes': markup_classes})
return template.render(context) return template.render(context)

View File

@ -21,6 +21,7 @@ Template tags for parsing date strings.
""" """
from datetime import datetime # noqa from datetime import datetime # noqa
from django import template from django import template
from django.utils import timezone from django.utils import timezone

View File

@ -37,9 +37,10 @@ LOG = logging.getLogger(__name__)
try: try:
from horizon.test.webdriver import WebDriver # noqa
from selenium.webdriver.support import ui as selenium_ui from selenium.webdriver.support import ui as selenium_ui
import xvfbwrapper # Only needed when running the Selenium tests headless import xvfbwrapper # Only needed when running the Selenium tests headless
from horizon.test.webdriver import WebDriver # noqa
except ImportError as e: except ImportError as e:
# NOTE(saschpe): Several distribution can't ship selenium due to its # NOTE(saschpe): Several distribution can't ship selenium due to its
# non-free license. So they have to patch it out of test-requirements.txt # non-free license. So they have to patch it out of test-requirements.txt

View File

@ -10,11 +10,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import django.shortcuts
import django.views.defaults
import inspect import inspect
import sys import sys
import django.shortcuts
import django.views.defaults
def dispatcher(request, test_name): def dispatcher(request, test_name):
# import is included in this non-standard location to avoid # import is included in this non-standard location to avoid

View File

@ -22,10 +22,11 @@ import sys
import django import django
from django.utils import html_parser from django.utils import html_parser
from horizon.test import patches
import xstatic.main import xstatic.main
import xstatic.pkg.jquery import xstatic.pkg.jquery
from horizon.test import patches
# Patch django.utils.html_parser.HTMLParser as a workaround for bug 1273943 # Patch django.utils.html_parser.HTMLParser as a workaround for bug 1273943
if django.get_version() == '1.4' and sys.version_info[:3] > (2, 7, 3): if django.get_version() == '1.4' and sys.version_info[:3] > (2, 7, 3):

View File

@ -14,12 +14,12 @@
from __future__ import with_statement # Python 2.5 compliance from __future__ import with_statement # Python 2.5 compliance
import lockfile
import os import os
import random import random
import string import string
import lockfile
class FilePermissionError(Exception): class FilePermissionError(Exception):
"""The key file permissions are insecure.""" """The key file permissions are insecure."""