Docstring formatting

Fix docstrings fromatting and enable the flake8 tests.

Change-Id: Ica91c03140c7e0ac66fd29e743e2a38a7e08dded
This commit is contained in:
Radomir Dopieralski 2013-10-31 15:20:27 +01:00
parent 7d58afaa9a
commit ce790a4f3b
11 changed files with 37 additions and 49 deletions

View File

@ -34,7 +34,6 @@ builtins = _
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py
# F403 'from <smth> import *' used; unable to detect undefined names
# F999 syntax error in doctest
# H4xx docstrings
# H701 empty localization string
# H702 Formatting operation should be outside of localization method call
ignore = F403,F999,H4,H701,H702
ignore = F403,F999,H701,H702

View File

@ -472,9 +472,10 @@ class Rack(StringIdAPIResourceWrapper):
@cached_property
def vm_capacity(self):
"""
Rack VM Capacity is maximum value from its Resource Class's
Flavors max_vms (considering flavor sizes are multiples).
"""Calculate Rack VM Capacity.
Rack VM Capacity is maximum value from its Resource Class's Flavors
max_vms (considering flavor sizes are multiples).
"""
try:
value = max([flavor.max_vms for flavor in
@ -620,7 +621,8 @@ class ResourceClass(StringIdAPIResourceWrapper):
@cached_property
def all_racks(self):
"""
"""List all racks suitable for the add/remove dialog.
List of racks added to ResourceClass + list of free racks,
meaning racks that don't belong to any ResourceClass.
"""
@ -689,9 +691,11 @@ class ResourceClass(StringIdAPIResourceWrapper):
@cached_property
def vm_capacity(self):
""" Resource Class VM Capacity is maximum value from It's Flavors
max_vms (considering flavor sizes are multiples), multipled by
number of Racks in Resource Class.
"""Calculate Class VM Capacity.
Resource Class VM Capacity is maximum value from its Flavors max_vms
(considering flavor sizes are multiples), multipled by number of Racks
in Resource Class.
"""
try:
value = self.racks_count * max([flavor.max_vms

View File

@ -49,10 +49,10 @@
# So we have a copy of it here, with the bug fixed.
# FIXME: Use django's version when the bug is fixed there.
class cached_property(object):
"""Decorator that creates converts a method with a single self argument
into a property cached on the instance.
"""
Decorator that creates converts a method with a single
self argument into a property cached on the instance.
"""
def __init__(self, func):
self.func = func

View File

@ -38,7 +38,7 @@ class DeleteNodes(tables.DeleteAction):
class NodesFilterAction(tables.FilterAction):
def filter(self, table, nodes, filter_string):
""" Naive case-insensitive search. """
"""Naive case-insensitive search."""
q = filter_string.lower()
# This is used both for Tuskar and Baremetal nodes.
return [node for node in nodes if q in node.name.lower()]

View File

@ -56,7 +56,7 @@ class EditRack(tables.LinkAction):
class RacksFilterAction(tables.FilterAction):
def filter(self, table, racks, filter_string):
""" Naive case-insensitive search. """
"""Naive case-insensitive search."""
q = filter_string.lower()
return [rack for rack in racks
if q in rack.name.lower()]

View File

@ -154,7 +154,7 @@ class CreateRack(workflows.Workflow):
# tab it should redirect after action, until the coflict will
# be fixed in Horizon.
def get_index_url(self):
"""This url is used both as success and failure url"""
"""This URL is used both as success and failure URL."""
return "%s?tab=resource_management_tabs__racks_tab" %\
urlresolvers.reverse('horizon:infrastructure:resource_management:'
'index')

View File

@ -129,9 +129,7 @@ class DetailActionView(horizon_forms.ModalFormView):
'resource_classes/action.html')
def get_form(self, form_class):
"""
Returns an instance of the form to be used in this view.
"""
"""Returns an instance of the form to be used in this view."""
try:
action = self.request.GET.get('action')
if action == "delete":

View File

@ -32,14 +32,14 @@ STRING_SEPARATOR = "__"
# FIXME: Remove this class and use Row directly after it becomes easier to
# extend it, see bug #1229677
class BaseCell(horizon_tables.Cell):
""" Represents a single cell in the table. """
"""Represents a single cell in the table."""
def __init__(self, datum, column, row, attrs=None, classes=None):
super(BaseCell, self).__init__(datum, None, column, row, attrs,
classes)
self.data = self.get_data(datum, column, row)
def get_data(self, datum, column, row):
""" Fetches the data to be displayed in this cell. """
"""Fetches the data to be displayed in this cell."""
table = row.table
if column.auto == "multi_select":
widget = forms.CheckboxInput(check_test=lambda value: False)
@ -58,8 +58,7 @@ class BaseCell(horizon_tables.Cell):
# FIXME: Remove this class and use Row directly after it becomes easier to
# extend it, see bug #1229677
class BaseRow(horizon_tables.Row):
"""
A DataTable Row class that is easier to extend.
"""A DataTable Row class that is easier to extend.
All of this code is lifted from ``horizon_tables.Row`` and just split into
two separate methods, so that it is possible to override one of them
@ -141,8 +140,7 @@ class FormsetRow(BaseRow):
class FormsetDataTableMixin(object):
"""
A mixin for DataTable to support Django Formsets.
"""A mixin for DataTable to support Django Formsets.
This works the same as the ``FormsetDataTable`` below, but can be used
to add to existing DataTable subclasses.
@ -183,8 +181,7 @@ class FormsetDataTableMixin(object):
return data
def get_formset(self):
"""
Provide the formset corresponding to this DataTable.
"""Provide the formset corresponding to this DataTable.
Use this to validate the formset and to get the submitted data back.
"""
@ -200,8 +197,7 @@ class FormsetDataTableMixin(object):
return self._meta.row_class(self, None, self.get_formset().empty_form)
def get_rows(self):
"""
Return the row data for this table broken out by columns.
"""Return the row data for this table broken out by columns.
The row objects get an additional ``form`` parameter, with the
formset form corresponding to that row.
@ -236,8 +232,7 @@ class FormsetDataTableMixin(object):
class FormsetDataTable(FormsetDataTableMixin, horizon_tables.DataTable):
"""
A DataTable with support for Django Formsets.
"""A DataTable with support for Django Formsets.
Note that :attr:`~horizon.tables.DataTableOptions.row_class` and
:attr:`~horizon.tables.DataTaleOptions.cell_class` are overwritten in this

View File

@ -52,10 +52,9 @@ class TuskarApiTests(test.APITestCase):
self.assertIsInstance(ret_val, api.BaremetalNode)
def test_baremetal_node_create_with_empty_pm(self):
"""
Make sure that when pm_address, pm_user and terminal_port are not
provided (empty), their values are set to None, as this is required
by the baremetal VM.
"""Make sure that when pm_address, pm_user and terminal_port are not
provided (empty), their values are set to None, as this is required by
the baremetal VM.
"""
baremetal_node = self.baremetalclient_nodes.first()

View File

@ -36,8 +36,7 @@ def create_stubs(stubs_to_create={}):
@unittest.skipIf(os.environ.get('SKIP_UNITTESTS', False),
"The SKIP_UNITTESTS env variable is set.")
class TestCase(openstack_dashboard_helpers.TestCase):
"""
Specialized base test case class for Horizon which gives access to
"""Specialized base test case class for Horizon which gives access to
numerous additional features:
* A full suite of test data through various attached objects and
@ -60,8 +59,7 @@ class TestCase(openstack_dashboard_helpers.TestCase):
class BaseAdminViewTests(openstack_dashboard_helpers.BaseAdminViewTests):
"""
A ``TestCase`` subclass which sets an active user with the "admin" role
"""A ``TestCase`` subclass which sets an active user with the "admin" role
for testing admin-only views and functionality.
"""
def setUp(self):
@ -72,8 +70,7 @@ class BaseAdminViewTests(openstack_dashboard_helpers.BaseAdminViewTests):
class APITestCase(openstack_dashboard_helpers.APITestCase):
"""
The ``APITestCase`` class is for use with tests which deal with the
"""The ``APITestCase`` class is for use with tests which deal with the
underlying clients rather than stubbing out the
openstack_dashboard.api.* methods.
"""

View File

@ -30,8 +30,7 @@ class WorkflowView(horizon.workflows.WorkflowView):
# FIXME: TableStep
class TableStep(horizon.workflows.Step):
"""
A :class:`~horizon.workflows.Step` class which knows how to deal with
"""A :class:`~horizon.workflows.Step` class which knows how to deal with
:class:`~horizon.tables.DataTable` classes rendered inside of it.
This distinct class is required due to the complexity involved in handling
@ -64,15 +63,14 @@ class TableStep(horizon.workflows.Step):
self._table_data_loaded = False
def prepare_action_context(self, request, context):
"""
Passes the tables to the action for validation and data extraction.
"""Passes the tables to the action for validation and data extraction.
"""
self.load_table_data()
context['_tables'] = self._tables
return context
def render(self):
""" Renders the step. """
"""Renders the step."""
step_template = template.loader.get_template(self.template_name)
extra_context = {"form": self.action,
"step": self}
@ -85,8 +83,7 @@ class TableStep(horizon.workflows.Step):
return step_template.render(context)
def load_table_data(self):
"""
Calls the ``get_{{ table_name }}_data`` methods for each table class
"""Calls the ``get_{{ table_name }}_data`` methods for each table class
and sets the data on the tables.
"""
# We only want the data to be loaded once, so we track if we have...
@ -106,8 +103,7 @@ class TableStep(horizon.workflows.Step):
self._table_data_loaded = True
def get_context_data(self, request):
"""
Adds a ``{{ table_name }}_table`` item to the context for each table
"""Adds a ``{{ table_name }}_table`` item to the context for each table
in the :attr:`~horizon.tabs.TableTab.table_classes` attribute.
If only one table class is provided, a shortcut ``table`` context