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):
tables = super(ResourceBrowserView, self).get_tables()
# Tells the navigation table what is selected.
navigation_table = tables[self.browser_class.navigation_table_class._meta.name]
navigation_item = self.kwargs.get(self.browser_class.navigation_kwarg_name)
navigation_table = tables[
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
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 url # noqa
from django.views.generic import TemplateView # noqa
from horizon.test.jasmine import jasmine
urlpatterns = patterns('horizon.views',

View File

@ -14,7 +14,7 @@
from collections import defaultdict
import logging
import new
import types
from django.conf import settings
from django.core import urlresolvers
@ -293,12 +293,12 @@ class Action(BaseAction):
if not has_single:
def single(self, 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:
def multiple(self, 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):
"""Returns the full POST parameter name for this action.

View File

@ -1,9 +1,20 @@
from django import forms
from django.template import Context
from django.template.loader import get_template
from django import template
# 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 import forms
from django import template as django_template
register = django_template.Library()
register = template.Library()
@register.filter
def bootstrap_form_field(element):
@ -12,8 +23,10 @@ def bootstrap_form_field(element):
def add_input_classes(field):
if not is_checkbox(field) and not is_multiple_checkbox(field) and not is_radio(field) \
and not is_file(field):
if (not is_checkbox(field) and
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 += ' form-control'
field.field.widget.attrs['class'] = field_classes
@ -21,8 +34,10 @@ def add_input_classes(field):
def render(element, markup_classes):
add_input_classes(element)
template = get_template("horizon/common/_bootstrap_form_field.html")
context = Context({'field': element, 'classes': markup_classes})
template = django_template.loader.get_template(
"horizon/common/_bootstrap_form_field.html")
context = django_template.Context({'field': element,
'classes': markup_classes})
return template.render(context)

View File

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

View File

@ -37,9 +37,10 @@ LOG = logging.getLogger(__name__)
try:
from horizon.test.webdriver import WebDriver # noqa
from selenium.webdriver.support import ui as selenium_ui
import xvfbwrapper # Only needed when running the Selenium tests headless
from horizon.test.webdriver import WebDriver # noqa
except ImportError as e:
# 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

View File

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

View File

@ -22,10 +22,11 @@ import sys
import django
from django.utils import html_parser
from horizon.test import patches
import xstatic.main
import xstatic.pkg.jquery
from horizon.test import patches
# 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):

View File

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