Merge "Unify doc-strings format"

This commit is contained in:
Jenkins 2014-09-12 05:41:57 +00:00 committed by Gerrit Code Review
commit a85773cf48
9 changed files with 30 additions and 52 deletions

@ -48,7 +48,7 @@ class NeutronClientMixin(object):
class HTTPClient(NeutronClientMixin):
"""Handles the REST calls and responses, include authn."""
"""Handles the REST calls and responses, include authentication."""
def __init__(self, username=None, user_id=None,
tenant_name=None, tenant_id=None,

@ -27,8 +27,7 @@ LOG = logging.getLogger(__name__)
class ClientCache(object):
"""Descriptor class for caching created client handles.
"""
"""Descriptor class for caching created client handles."""
def __init__(self, factory):
self.factory = factory
@ -42,8 +41,7 @@ class ClientCache(object):
class ClientManager(object):
"""Manages access to API clients, including authentication.
"""
"""Manages access to API clients, including authentication."""
neutron = ClientCache(neutron_client.make_client)
# Provide support for old quantum commands (for example
# in stable versions)

@ -14,16 +14,11 @@
# under the License.
#
"""
OpenStack base command
"""
from cliff import command
class OpenStackCommand(command.Command):
"""Base class for OpenStack commands
"""
"""Base class for OpenStack commands."""
api = None

@ -30,12 +30,11 @@ Exceptions are classified into three categories:
class NeutronException(Exception):
"""Base Neutron Exception
"""Base Neutron Exception.
To correctly use this class, inherit from it and define
a 'message' property. That message will get printf'd
with the keyword arguments provided to the constructor.
"""
message = _("An unknown exception occurred.")
@ -218,8 +217,8 @@ class CommandError(NeutronCLIError):
class UnsupportedVersion(NeutronCLIError):
"""Indicates that the user is trying to use an unsupported
version of the API
"""Indicates that the user is trying to use an unsupported version of
the API.
"""
pass

@ -393,7 +393,6 @@ class Serializer(object):
"""Deserialize a string to a dictionary.
The string must be in the format of a supported MIME type.
"""
return self.get_deserialize_handler(content_type).deserialize(
datastring)

@ -29,7 +29,7 @@ from neutronclient.openstack.common import strutils
def env(*vars, **kwargs):
"""Returns the first environment variable set.
if none are non-empty, defaults to '' or keyword arg default.
If none are non-empty, defaults to '' or keyword arg default.
"""
for v in vars:
value = os.environ.get(v)
@ -50,7 +50,7 @@ def import_class(import_str):
def get_client_class(api_name, version, version_map):
"""Returns the client class for the requested API version
"""Returns the client class for the requested API version.
:param api_name: the name of the API, e.g. 'compute', 'image', etc
:param version: the requested API version

@ -26,8 +26,7 @@ API_VERSIONS = {
def make_client(instance):
"""Returns an neutron client.
"""
"""Returns an neutron client."""
neutron_client = utils.get_client_class(
API_NAME,
instance._api_version[API_NAME],
@ -60,6 +59,7 @@ def make_client(instance):
def Client(api_version, *args, **kwargs):
"""Return an neutron client.
@param api_version: only 2.0 is supported now
"""
neutron_client = utils.get_client_class(

@ -199,7 +199,7 @@ def _process_previous_argument(current_arg, _value_number, current_type_str,
def parse_args_to_dict(values_specs):
'''It is used to analyze the extra command options to command.
"""It is used to analyze the extra command options to command.
Besides known options and arguments, our commands also support user to
put more options to the end of command line. For example,
@ -211,8 +211,7 @@ def parse_args_to_dict(values_specs):
value spec is: --key type=int|bool|... value. Type is one of Python
built-in types. By default, type is string. The key without value is
a bool option. Key with two values will be a list option.
'''
"""
# values_specs for example: '-- --tag x y --key1 type=int value1'
# -- is a pseudo argument
@ -296,7 +295,7 @@ def parse_args_to_dict(values_specs):
current_arg, _value_number, current_type_str,
_list_flag, _values_specs, _clear_flag, values_specs)
# populate the parser with arguments
# Populate the parser with arguments
_parser = argparse.ArgumentParser(add_help=False)
for opt, optspec in six.iteritems(_options):
_parser.add_argument(opt, **optspec)
@ -335,7 +334,7 @@ def _merge_args(qCmd, parsed_args, _extra_values, value_specs):
def update_dict(obj, dict, attributes):
"""Update dict with fields from obj.attributes
"""Update dict with fields from obj.attributes.
:param obj: the object updated into dict
:param dict: the result dictionary
@ -435,9 +434,7 @@ class NeutronCommand(command.OpenStackCommand):
class CreateCommand(NeutronCommand, show.ShowOne):
"""Create a resource for a given tenant
"""
"""Create a resource for a given tenant."""
api = 'network'
log = None
@ -479,8 +476,7 @@ class CreateCommand(NeutronCommand, show.ShowOne):
class UpdateCommand(NeutronCommand):
"""Update resource's information
"""
"""Update resource's information."""
api = 'network'
log = None
@ -531,9 +527,7 @@ class UpdateCommand(NeutronCommand):
class DeleteCommand(NeutronCommand):
"""Delete a given resource
"""
"""Delete a given resource."""
api = 'network'
log = None
@ -578,9 +572,7 @@ class DeleteCommand(NeutronCommand):
class ListCommand(NeutronCommand, lister.Lister):
"""List resources that belong to a given tenant
"""
"""List resources that belong to a given tenant."""
api = 'network'
log = None
@ -619,7 +611,7 @@ class ListCommand(NeutronCommand, lister.Lister):
return data
def retrieve_list(self, parsed_args):
"""Retrieve a list of resources from Neutron server"""
"""Retrieve a list of resources from Neutron server."""
neutron_client = self.get_client()
neutron_client.format = parsed_args.request_format
_extra_values = parse_args_to_dict(self.values_specs)
@ -680,9 +672,7 @@ class ListCommand(NeutronCommand, lister.Lister):
class ShowCommand(NeutronCommand, show.ShowOne):
"""Show information of a given resource
"""
"""Show information of a given resource."""
api = 'network'
log = None

@ -33,14 +33,13 @@ _logger = logging.getLogger(__name__)
def exception_handler_v20(status_code, error_content):
"""Exception handler for API v2.0 client
"""Exception handler for API v2.0 client.
This routine generates the appropriate
Neutron exception according to the contents of the
response body
This routine generates the appropriate Neutron exception according to
the contents of the response body.
:param status_code: HTTP error status code
:param error_content: deserialized body of error response
:param status_code: HTTP error status code
:param error_content: deserialized body of error response
"""
error_dict = None
if isinstance(error_content, dict):
@ -87,8 +86,7 @@ def exception_handler_v20(status_code, error_content):
class APIParamsCall(object):
"""A Decorator to add support for format and tenant overriding
and filters
"""A Decorator to add support for format and tenant overriding and filters.
"""
def __init__(self, function):
self.function = function
@ -273,8 +271,7 @@ class Client(object):
@APIParamsCall
def get_quotas_tenant(self, **_params):
"""Fetch tenant info in server's context for
following quota operation.
"""Fetch tenant info in server's context for following quota operation.
"""
return self.get(self.quota_path % 'tenant', params=_params)
@ -1257,8 +1254,8 @@ class Client(object):
def serialize(self, data):
"""Serializes a dictionary into either XML or JSON.
A dictionary with a single key can be passed and
it can contain any structure.
A dictionary with a single key can be passed and it can contain any
structure.
"""
if data is None:
return None