diff --git a/horizon/base.py b/horizon/base.py index e1f4f5e71d..ab696a683f 100644 --- a/horizon/base.py +++ b/horizon/base.py @@ -552,7 +552,7 @@ class Workflow(object): try: from django.utils.functional import empty # noqa except ImportError: - #Django 1.3 fallback + # Django 1.3 fallback empty = None diff --git a/horizon/browsers/views.py b/horizon/browsers/views.py index 46c0b92731..351f48338d 100644 --- a/horizon/browsers/views.py +++ b/horizon/browsers/views.py @@ -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 diff --git a/horizon/site_urls.py b/horizon/site_urls.py index 171c0eecba..a2f4ed6402 100644 --- a/horizon/site_urls.py +++ b/horizon/site_urls.py @@ -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', diff --git a/horizon/tables/actions.py b/horizon/tables/actions.py index 9e54850904..47d467e040 100644 --- a/horizon/tables/actions.py +++ b/horizon/tables/actions.py @@ -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. @@ -669,7 +669,7 @@ class BatchAction(Action): continue try: self.action(request, datum_id) - #Call update to invoke changes if needed + # Call update to invoke changes if needed self.update(request, datum) action_success.append(datum_display) self.success_ids.append(datum_id) diff --git a/horizon/tables/base.py b/horizon/tables/base.py index 32bd6d3b63..c7b24cead5 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -323,7 +323,7 @@ class Column(html.HTMLElement): self.transform in datum: data = datum.get(self.transform) else: - # Basic object lookups + # Basic object lookups try: data = getattr(datum, self.transform) except AttributeError: @@ -715,7 +715,7 @@ class Cell(html.HTMLElement): if self.column.status or \ self.column.name in self.column.table._meta.status_columns: - #returns the first matching status found + # returns the first matching status found data_status_lower = unicode( self.column.get_raw_data(self.datum)).lower() for status_name, status_value in self.column.status_choices: @@ -1289,8 +1289,8 @@ class DataTable(object): if not self.multi_select: return select_column = self.columns.values()[0] - #Try to find if the hidden class need to be - #removed or added based on visible flag. + # Try to find if the hidden class need to be + # removed or added based on visible flag. hidden_found = 'hidden' in select_column.classes if hidden_found and visible: select_column.classes.remove('hidden') diff --git a/horizon/templatetags/bootstrap_form_field.py b/horizon/templatetags/bootstrap_form_field.py index fec7fcce68..aa5b85ee01 100644 --- a/horizon/templatetags/bootstrap_form_field.py +++ b/horizon/templatetags/bootstrap_form_field.py @@ -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) diff --git a/horizon/templatetags/parse_date.py b/horizon/templatetags/parse_date.py index 3c168c4bbe..c40f79877d 100644 --- a/horizon/templatetags/parse_date.py +++ b/horizon/templatetags/parse_date.py @@ -21,6 +21,7 @@ Template tags for parsing date strings. """ from datetime import datetime # noqa + from django import template from django.utils import timezone diff --git a/horizon/test/helpers.py b/horizon/test/helpers.py index c5a1213760..205dadb184 100644 --- a/horizon/test/helpers.py +++ b/horizon/test/helpers.py @@ -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 @@ -170,7 +171,7 @@ class SeleniumTestCase(django_test.LiveServerTestCase): socket.setdefaulttimeout(60) if os.environ.get('WITH_SELENIUM', False): time.sleep(1) - # Start a virtual display server for running the tests headless. + # Start a virtual display server for running the tests headless. if os.environ.get('SELENIUM_HEADLESS', False): cls.vdisplay = xvfbwrapper.Xvfb(width=1280, height=720) cls.vdisplay.start() diff --git a/horizon/test/jasmine/jasmine.py b/horizon/test/jasmine/jasmine.py index 43cecd9a8e..492bceb087 100644 --- a/horizon/test/jasmine/jasmine.py +++ b/horizon/test/jasmine/jasmine.py @@ -10,15 +10,16 @@ # 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 - #problems importing mox. See bug/1288245 + # import is included in this non-standard location to avoid + # problems importing mox. See bug/1288245 from horizon.test.jasmine import jasmine_tests as tests classes = inspect.getmembers(sys.modules[tests.__name__], inspect.isclass) diff --git a/horizon/test/settings.py b/horizon/test/settings.py index 4fa176dd48..cc0133bd12 100644 --- a/horizon/test/settings.py +++ b/horizon/test/settings.py @@ -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): diff --git a/horizon/test/tests/tables.py b/horizon/test/tests/tables.py index 668e546289..df7a23a135 100644 --- a/horizon/test/tests/tables.py +++ b/horizon/test/tests/tables.py @@ -147,7 +147,7 @@ class MyToggleAction(tables.BatchAction): def action(self, request, object_ids): if self.down: - #up it + # up it self.current_past_action = 1 @@ -1102,9 +1102,9 @@ class DataTableTests(test.TestCase): def test_table_column_can_be_selected(self): self.table = MyTableSelectable(self.request, TEST_DATA_6) - #non selectable row + # non selectable row row = self.table.get_rows()[0] - #selectable + # selectable row1 = self.table.get_rows()[1] id_col = self.table.columns['id'] @@ -1139,11 +1139,11 @@ class DataTableTests(test.TestCase): '', '', ]) - #can_be_selected = False + # can_be_selected = False self.assertTrue(row.get_cells()[0].data == "") - #can_be_selected = True + # can_be_selected = True self.assertIn('checkbox', row1.get_cells()[0].data) - #status + # status cell_status = row.cells['status'].status self.assertEqual(row.cells['status'].get_status_class(cell_status), 'status_down') diff --git a/horizon/utils/secret_key.py b/horizon/utils/secret_key.py index 8dd86baa9a..1fb69c03ec 100644 --- a/horizon/utils/secret_key.py +++ b/horizon/utils/secret_key.py @@ -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."""