From 48da7226c01e3b69e8a53f9b1e42597c56d15483 Mon Sep 17 00:00:00 2001 From: Stanislav Kudriashev Date: Thu, 21 Aug 2014 15:45:10 +0300 Subject: [PATCH] Unify doc-strings format Change-Id: If6cf2caeae294db30a8988ab861441211b651580 --- neutronclient/client.py | 2 +- neutronclient/common/clientmanager.py | 6 ++---- neutronclient/common/command.py | 7 +----- neutronclient/common/exceptions.py | 7 +++--- neutronclient/common/serializer.py | 1 - neutronclient/common/utils.py | 4 ++-- neutronclient/neutron/client.py | 4 ++-- neutronclient/neutron/v2_0/__init__.py | 30 +++++++++----------------- neutronclient/v2_0/client.py | 21 ++++++++---------- 9 files changed, 30 insertions(+), 52 deletions(-) diff --git a/neutronclient/client.py b/neutronclient/client.py index 8720f1fbf..1f66ec149 100644 --- a/neutronclient/client.py +++ b/neutronclient/client.py @@ -59,7 +59,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, diff --git a/neutronclient/common/clientmanager.py b/neutronclient/common/clientmanager.py index 283bc77bf..e9cc88574 100644 --- a/neutronclient/common/clientmanager.py +++ b/neutronclient/common/clientmanager.py @@ -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) diff --git a/neutronclient/common/command.py b/neutronclient/common/command.py index 2cd32935a..3d0540744 100644 --- a/neutronclient/common/command.py +++ b/neutronclient/common/command.py @@ -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 diff --git a/neutronclient/common/exceptions.py b/neutronclient/common/exceptions.py index 4c21e62b6..2fed2ca2f 100644 --- a/neutronclient/common/exceptions.py +++ b/neutronclient/common/exceptions.py @@ -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 diff --git a/neutronclient/common/serializer.py b/neutronclient/common/serializer.py index e2cd7641b..73f0bec2e 100644 --- a/neutronclient/common/serializer.py +++ b/neutronclient/common/serializer.py @@ -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) diff --git a/neutronclient/common/utils.py b/neutronclient/common/utils.py index 87dec4c53..577e963cb 100644 --- a/neutronclient/common/utils.py +++ b/neutronclient/common/utils.py @@ -33,7 +33,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) @@ -87,7 +87,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 diff --git a/neutronclient/neutron/client.py b/neutronclient/neutron/client.py index df7ef2996..40eb9382a 100644 --- a/neutronclient/neutron/client.py +++ b/neutronclient/neutron/client.py @@ -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( diff --git a/neutronclient/neutron/v2_0/__init__.py b/neutronclient/neutron/v2_0/__init__.py index 20bbbff27..39a566040 100644 --- a/neutronclient/neutron/v2_0/__init__.py +++ b/neutronclient/neutron/v2_0/__init__.py @@ -198,7 +198,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, @@ -210,8 +210,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 @@ -295,7 +294,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) @@ -334,7 +333,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 @@ -434,9 +433,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 @@ -478,8 +475,7 @@ class CreateCommand(NeutronCommand, show.ShowOne): class UpdateCommand(NeutronCommand): - """Update resource's information - """ + """Update resource's information.""" api = 'network' log = None @@ -530,9 +526,7 @@ class UpdateCommand(NeutronCommand): class DeleteCommand(NeutronCommand): - """Delete a given resource - - """ + """Delete a given resource.""" api = 'network' log = None @@ -577,9 +571,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 @@ -618,7 +610,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) @@ -679,9 +671,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 diff --git a/neutronclient/v2_0/client.py b/neutronclient/v2_0/client.py index 49a49f2ad..56185c027 100644 --- a/neutronclient/v2_0/client.py +++ b/neutronclient/v2_0/client.py @@ -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) @@ -1268,8 +1265,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