From 85ffc01eee00dab0a076ee367dbe04b131653423 Mon Sep 17 00:00:00 2001 From: Sergey Skripnick Date: Fri, 26 Apr 2013 11:41:38 +0300 Subject: [PATCH] Docstrings formatted according to pep257 Bug #1020184 quantum/agent/* quantum/api/* Change-Id: I206206b66b4adf5cda73a6bb709a0935d7efa821 --- quantum/agent/dhcp_agent.py | 1 - quantum/agent/l3_agent.py | 2 -- quantum/agent/linux/daemon.py | 3 +-- quantum/agent/linux/interface.py | 3 ++- quantum/agent/linux/ip_lib.py | 3 +-- quantum/agent/metadata/namespace_proxy.py | 4 ++-- quantum/agent/securitygroups_rpc.py | 3 +-- quantum/api/api_common.py | 13 +++++++------ quantum/api/extensions.py | 11 ++++++----- quantum/api/v2/attributes.py | 4 ++-- quantum/api/v2/base.py | 13 +++++++------ quantum/api/views/versions.py | 3 ++- 12 files changed, 31 insertions(+), 32 deletions(-) diff --git a/quantum/agent/dhcp_agent.py b/quantum/agent/dhcp_agent.py index 804983a6eb3..66f03f06232 100644 --- a/quantum/agent/dhcp_agent.py +++ b/quantum/agent/dhcp_agent.py @@ -201,7 +201,6 @@ class DhcpAgent(manager.Manager): def refresh_dhcp_helper(self, network_id): """Refresh or disable DHCP for a network depending on the current state of the network. - """ old_network = self.cache.get_network_by_id(network_id) if not old_network: diff --git a/quantum/agent/l3_agent.py b/quantum/agent/l3_agent.py index b1dcc442851..368cfb5c6ee 100644 --- a/quantum/agent/l3_agent.py +++ b/quantum/agent/l3_agent.py @@ -1,4 +1,3 @@ -""" # vim: tabstop=4 shiftwidth=4 softtabstop=4 # # Copyright 2012 Nicira Networks, Inc. All rights reserved. @@ -17,7 +16,6 @@ # # @author: Dan Wendlandt, Nicira, Inc # -""" import eventlet from eventlet import semaphore diff --git a/quantum/agent/linux/daemon.py b/quantum/agent/linux/daemon.py index 7902868dbdc..cf45fd6f4c7 100644 --- a/quantum/agent/linux/daemon.py +++ b/quantum/agent/linux/daemon.py @@ -73,8 +73,7 @@ class Pidfile(object): class Daemon(object): - """ - A generic daemon class. + """A generic daemon class. Usage: subclass the Daemon class and override the run() method """ diff --git a/quantum/agent/linux/interface.py b/quantum/agent/linux/interface.py index c0305a26f6a..e7bd103e240 100644 --- a/quantum/agent/linux/interface.py +++ b/quantum/agent/linux/interface.py @@ -72,7 +72,8 @@ class LinuxInterfaceDriver(object): def init_l3(self, device_name, ip_cidrs, namespace=None): """Set the L3 settings for the interface using data from the port. - ip_cidrs: list of 'X.X.X.X/YY' strings + + ip_cidrs: list of 'X.X.X.X/YY' strings """ device = ip_lib.IPDevice(device_name, self.root_helper, diff --git a/quantum/agent/linux/ip_lib.py b/quantum/agent/linux/ip_lib.py index ed110556f92..0aba9243268 100644 --- a/quantum/agent/linux/ip_lib.py +++ b/quantum/agent/linux/ip_lib.py @@ -351,8 +351,7 @@ class IpRouteCommand(IpDeviceCommandBase): return retval def pullup_route(self, interface_name): - """ - Ensures that the route entry for the interface is before all + """Ensures that the route entry for the interface is before all others on the same subnet. """ device_list = [] diff --git a/quantum/agent/metadata/namespace_proxy.py b/quantum/agent/metadata/namespace_proxy.py index 86d608410a7..0a9a317bed7 100644 --- a/quantum/agent/metadata/namespace_proxy.py +++ b/quantum/agent/metadata/namespace_proxy.py @@ -58,8 +58,8 @@ class UnixDomainHTTPConnection(httplib.HTTPConnection): class NetworkMetadataProxyHandler(object): """Proxy AF_INET metadata request through Unix Domain socket. - The Unix domain socket allows the proxy access resource that are not - accessible within the isolated tenant context. + The Unix domain socket allows the proxy access resource that are not + accessible within the isolated tenant context. """ def __init__(self, network_id=None, router_id=None): diff --git a/quantum/agent/securitygroups_rpc.py b/quantum/agent/securitygroups_rpc.py index 2ca2c41979d..6ff36da36a4 100644 --- a/quantum/agent/securitygroups_rpc.py +++ b/quantum/agent/securitygroups_rpc.py @@ -46,8 +46,7 @@ def disable_security_group_extension_if_noop_driver( class SecurityGroupServerRpcApiMixin(object): - """A mix-in that enable SecurityGroup support in plugin rpc - """ + """A mix-in that enable SecurityGroup support in plugin rpc.""" def security_group_rules_for_devices(self, context, devices): LOG.debug(_("Get security group rules " "for devices via rpc %r"), devices) diff --git a/quantum/api/api_common.py b/quantum/api/api_common.py index d408182b47b..f7ce4562851 100644 --- a/quantum/api/api_common.py +++ b/quantum/api/api_common.py @@ -29,8 +29,8 @@ LOG = logging.getLogger(__name__) def get_filters(request, attr_info, skips=[]): - """ - Extracts the filters from the request string + """Extracts the filters from the request string. + Returns a dict of lists for the filters: check=a&check=b&name=Bob& becomes: @@ -124,8 +124,9 @@ def list_args(request, arg): def get_sorts(request, attr_info): - """Extract sort_key and sort_dir from request, return as: - [(key1, value1), (key2, value2)] + """Extract sort_key and sort_dir from request. + + Return as: [(key1, value1), (key2, value2)] """ sort_keys = list_args(request, "sort_key") sort_dirs = list_args(request, "sort_dir") @@ -302,9 +303,9 @@ class QuantumController(object): def _prepare_request_body(self, body, params): """Verifies required parameters are in request body. - sets default value for missing optional parameters. - body argument must be the deserialized body + Sets default value for missing optional parameters. + Body argument must be the deserialized body. """ try: if body is None: diff --git a/quantum/api/extensions.py b/quantum/api/extensions.py index ac2d1c3a85d..e1316c0f1a5 100644 --- a/quantum/api/extensions.py +++ b/quantum/api/extensions.py @@ -42,7 +42,8 @@ class PluginInterface(object): @classmethod def __subclasshook__(cls, klass): - """ + """Checking plugin class. + The __subclasshook__ method is a class method that will be called everytime a class is tested using issubclass(klass, PluginInterface). @@ -134,7 +135,7 @@ class ExtensionDescriptor(object): return request_exts def get_extended_resources(self, version): - """retrieve extended resources or attributes for core resources. + """Retrieve extended resources or attributes for core resources. Extended attributes are implemented by a core plugin similarly to the attributes defined in the core, and can appear in @@ -151,8 +152,8 @@ class ExtensionDescriptor(object): return {} def get_plugin_interface(self): - """ - Returns an abstract class which defines contract for the plugin. + """Returns an abstract class which defines contract for the plugin. + The abstract class should inherit from extesnions.PluginInterface, Methods in this abstract class should be decorated as abstractmethod """ @@ -160,7 +161,7 @@ class ExtensionDescriptor(object): def update_attributes_map(self, extended_attributes, extension_attrs_map=None): - """Update attributes map for this extension + """Update attributes map for this extension. This is default method for extending an extension's attributes map. An extension can use this method and supplying its own resource diff --git a/quantum/api/v2/attributes.py b/quantum/api/v2/attributes.py index aea6094ed5c..1eb6df1aa79 100644 --- a/quantum/api/v2/attributes.py +++ b/quantum/api/v2/attributes.py @@ -33,6 +33,7 @@ SHARED = 'shared' def _verify_dict_keys(expected_keys, target_dict, strict=True): """Allows to verify keys in a dictionary. + :param expected_keys: A list of keys expected to be present. :param target_dict: The dictionary which should be verified. :param strict: Specifies whether additional keys are allowed to be present. @@ -114,10 +115,9 @@ def _validate_ip_address(data, valid_values=None): def _validate_ip_pools(data, valid_values=None): - """Validate that start and end IP addresses are present + """Validate that start and end IP addresses are present. In addition to this the IP addresses will also be validated - """ if not isinstance(data, list): msg = _("Invalid data format for IP pool: '%s'") % data diff --git a/quantum/api/v2/base.py b/quantum/api/v2/base.py index 33b16973b45..4772af6249e 100644 --- a/quantum/api/v2/base.py +++ b/quantum/api/v2/base.py @@ -492,13 +492,14 @@ class Controller(object): @staticmethod def prepare_request_body(context, body, is_create, resource, attr_info, allow_bulk=False): - """Verifies required attributes are in request body, and that - an attribute is only specified if it is allowed for the given - operation (create/update). - Attribute with default values are considered to be - optional. + """Verifies required attributes are in request body. - body argument must be the deserialized body + Also checking that an attribute is only specified if it is allowed + for the given operation (create/update). + + Attribute with default values are considered to be optional. + + body argument must be the deserialized body. """ collection = resource + "s" if not body: diff --git a/quantum/api/views/versions.py b/quantum/api/views/versions.py index 441989c6de0..79f83ef5d46 100644 --- a/quantum/api/views/versions.py +++ b/quantum/api/views/versions.py @@ -26,7 +26,8 @@ def get_view_builder(req): class ViewBuilder(object): def __init__(self, base_url): - """ + """Object initialization. + :param base_url: url of the root wsgi application """ self.base_url = base_url