From 0edbcd5cc16d61774e0bedc379179eb1465f6207 Mon Sep 17 00:00:00 2001 From: zhangguoqing Date: Wed, 9 Dec 2015 10:28:50 +0800 Subject: [PATCH] Fix pep8 error about D300 This patch fix the pep8 error D300 about symbol that D300 Use """triple double quotes""" (found '''-quotes) when execute run_tests.sh. Change-Id: I79076b0d2a02eea59a47f263ad6bb30e48c6d1b7 --- senlinclient/client.py | 4 +- senlinclient/common/exc.py | 10 +-- senlinclient/common/i18n.py | 4 +- senlinclient/common/sdk.py | 4 +- senlinclient/common/utils.py | 2 +- senlinclient/shell.py | 6 +- senlinclient/tests/unit/fakes.py | 4 +- senlinclient/tests/unit/v1/test_shell.py | 2 +- senlinclient/v1/shell.py | 94 ++++++++++++------------ 9 files changed, 65 insertions(+), 65 deletions(-) diff --git a/senlinclient/client.py b/senlinclient/client.py index a0f584f5..52e2f138 100644 --- a/senlinclient/client.py +++ b/senlinclient/client.py @@ -14,11 +14,11 @@ from senlinclient.common import utils def Client(api_ver, *args, **kwargs): - '''Import versioned client module. + """Import versioned client module. :param api_ver: API version required. :param endpoint: endpoint URL requested. - ''' + """ module = utils.import_versioned_module(api_ver, 'client') cls = getattr(module, 'Client') return cls(*args, **kwargs) diff --git a/senlinclient/common/exc.py b/senlinclient/common/exc.py index 0ddb4782..dda727c5 100644 --- a/senlinclient/common/exc.py +++ b/senlinclient/common/exc.py @@ -24,7 +24,7 @@ verbose = False class BaseException(Exception): - '''An error occurred.''' + """An error occurred.""" def __init__(self, message=None): self.message = message @@ -33,11 +33,11 @@ class BaseException(Exception): class CommandError(BaseException): - '''Invalid usage of CLI.''' + """Invalid usage of CLI.""" class FileFormatError(BaseException): - '''Illegal file format detected.''' + """Illegal file format detected.""" class HTTPException(BaseException): @@ -228,10 +228,10 @@ _EXCEPTION_MAP = { def parse_exception(exc): - '''Parse exception code and yield useful information. + """Parse exception code and yield useful information. :param details: details of the exception. - ''' + """ if isinstance(exc, sdkexc.HttpException): try: record = jsonutils.loads(exc.details) diff --git a/senlinclient/common/i18n.py b/senlinclient/common/i18n.py index 2c378e2c..818114f8 100644 --- a/senlinclient/common/i18n.py +++ b/senlinclient/common/i18n.py @@ -10,10 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. -''' +""" oslo_i18n integration module. See http://docs.openstack.org/developer/oslo.i18n/usage.html -''' +""" import oslo_i18n diff --git a/senlinclient/common/sdk.py b/senlinclient/common/sdk.py index 641e959d..e8539267 100644 --- a/senlinclient/common/sdk.py +++ b/senlinclient/common/sdk.py @@ -75,11 +75,11 @@ class ProfileAction(argparse.Action): class Resource(base.Resource): - '''Senlin version of resource. + """Senlin version of resource. These classes are here because the OpenStack SDK base version is making some assumptions about operations that cannot be satisfied in Senlin. - ''' + """ def create(self, session, extra_attrs=False): """Create a remote resource from this instance. diff --git a/senlinclient/common/utils.py b/senlinclient/common/utils.py index d9c93345..c77e9f7a 100644 --- a/senlinclient/common/utils.py +++ b/senlinclient/common/utils.py @@ -106,7 +106,7 @@ def print_dict(d, formatters=None): def format_parameters(params, parse_semicolon=True): - '''Reformat parameters into dict of format expected by the API.''' + """Reformat parameters into dict of format expected by the API.""" if not params: return {} diff --git a/senlinclient/shell.py b/senlinclient/shell.py index efc62a15..08e802f5 100644 --- a/senlinclient/shell.py +++ b/senlinclient/shell.py @@ -82,10 +82,10 @@ class SenlinShell(object): self.subcommands[command] = subparser def do_bash_completion(self, args): - '''Prints all of the commands and options to stdout. + """Prints all of the commands and options to stdout. The senlin.bash_completion script doesn't have to hard code them. - ''' + """ commands = set() options = set() for sc_str, sc in self.subcommands.items(): @@ -214,7 +214,7 @@ class SenlinShell(object): raise exc.CommandError(msg) def _setup_senlin_client(self, api_ver, args): - '''Create senlin client using given args.''' + """Create senlin client using given args.""" kwargs = { 'auth_plugin': args.auth_plugin or 'password', 'auth_url': args.auth_url, diff --git a/senlinclient/tests/unit/fakes.py b/senlinclient/tests/unit/fakes.py index 9ef1173f..58d2035b 100644 --- a/senlinclient/tests/unit/fakes.py +++ b/senlinclient/tests/unit/fakes.py @@ -14,12 +14,12 @@ from senlinclient.common import utils def do_command_foo(sc, args): - '''Pydoc for command foo.''' + """Pydoc for command foo.""" return @utils.arg('-F', '--flag', metavar='', help='Flag desc.') @utils.arg('arg1', metavar='', help='Arg1 desc') def do_command_bar(sc, args): - '''This is the command doc.''' + """This is the command doc.""" return diff --git a/senlinclient/tests/unit/v1/test_shell.py b/senlinclient/tests/unit/v1/test_shell.py index 3bfe7e91..58b7cba4 100644 --- a/senlinclient/tests/unit/v1/test_shell.py +++ b/senlinclient/tests/unit/v1/test_shell.py @@ -41,7 +41,7 @@ class ShellTest(testtools.TestCase): } def _make_args(self, args): - '''Convert a dict to an object.''' + """Convert a dict to an object.""" class Args(object): def __init__(self, entries): self.__dict__.update(entries) diff --git a/senlinclient/v1/shell.py b/senlinclient/v1/shell.py index 9f7450fd..1c1bce30 100644 --- a/senlinclient/v1/shell.py +++ b/senlinclient/v1/shell.py @@ -54,7 +54,7 @@ def do_profile_type_list(sc, args=None): help=_("The template output format, one of: %s.") % ', '.join(utils.supported_formats.keys())) def do_profile_type_show(sc, args): - '''Get the details about a profile type.''' + """Get the details about a profile type.""" try: res = sc.get_profile_type(args.type_name) except exc.HTTPNotFound: @@ -85,7 +85,7 @@ def _short_id(obj): @utils.arg('-F', '--full-id', default=False, action="store_true", help=_('Print full IDs in list.')) def do_profile_list(sc, args=None): - '''List profiles that meet the criteria.''' + """List profiles that meet the criteria.""" fields = ['id', 'name', 'type', 'created_time'] queries = { 'show_deleted': args.show_deleted, @@ -131,7 +131,7 @@ def _show_profile(sc, profile_id): @utils.arg('name', metavar='', help=_('Name of the profile to create.')) def do_profile_create(sc, args): - '''Create a profile.''' + """Create a profile.""" spec = utils.get_spec_content(args.spec_file) type_name = spec.get('type', None) type_version = spec.get('version', None) @@ -161,7 +161,7 @@ def do_profile_create(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of profile to show.')) def do_profile_show(sc, args): - '''Show the profile details.''' + """Show the profile details.""" _show_profile(sc, args.id) @@ -177,7 +177,7 @@ def do_profile_show(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of the profile to update.')) def do_profile_update(sc, args): - '''Update a profile.''' + """Update a profile.""" params = { 'name': args.name, 'permission': args.permission, @@ -198,7 +198,7 @@ def do_profile_update(sc, args): @utils.arg('id', metavar='', nargs='+', help=_('Name or ID of profile(s) to delete.')) def do_profile_delete(sc, args): - '''Delete profile(s).''' + """Delete profile(s).""" failure_count = 0 for pid in args.id: @@ -217,7 +217,7 @@ def do_profile_delete(sc, args): def do_policy_type_list(sc, args): - '''List the available policy types.''' + """List the available policy types.""" types = sc.policy_types() utils.print_list(types, ['name'], sortby_index=0) @@ -229,7 +229,7 @@ def do_policy_type_list(sc, args): help=_("The template output format, one of: %s.") % ', '.join(utils.supported_formats.keys())) def do_policy_type_show(sc, args): - '''Get the details about a policy type.''' + """Get the details about a policy type.""" try: res = sc.get_policy_type(args.type_name) except exc.HTTPNotFound: @@ -255,7 +255,7 @@ def do_policy_type_show(sc, args): @utils.arg('-F', '--full-id', default=False, action="store_true", help=_('Print full IDs in list.')) def do_webhook_list(sc, args=None): - '''List webhooks that meet the criteria.''' + """List webhooks that meet the criteria.""" fields = ['id', 'name', 'obj_id', 'obj_type', 'action', 'created_time', 'deleted_time'] queries = { @@ -287,7 +287,7 @@ def _show_webhook(sc, webhook_id=None, webhook=None): @utils.arg('id', metavar='', help=_('Name or ID of the webhook to show.')) def do_webhook_show(sc, args): - '''Show the webhook details.''' + """Show the webhook details.""" _show_webhook(sc, webhook_id=args.id) @@ -307,7 +307,7 @@ def do_webhook_show(sc, args): @utils.arg('name', metavar='', help=_('Name of the webhook to create.')) def do_webhook_create(sc, args): - '''Create a webhook.''' + """Create a webhook.""" if args.cluster and args.node: msg = _("Only one of 'cluster' or 'node' can be specified, not both.") @@ -339,7 +339,7 @@ def do_webhook_create(sc, args): @utils.arg('id', metavar='', nargs='+', help=_('Name or ID of webhook(s) to delete.')) def do_webhook_delete(sc, args): - '''Delete webhook(s).''' + """Delete webhook(s).""" failure_count = 0 for wid in args.id: @@ -366,7 +366,7 @@ def do_webhook_delete(sc, args): @utils.arg('-F', '--full-id', default=False, action="store_true", help=_('Print full IDs in list.')) def do_policy_list(sc, args=None): - '''List policies that meet the criteria.''' + """List policies that meet the criteria.""" fields = ['id', 'name', 'type', 'level', 'cooldown', 'created_time'] queries = { 'show_deleted': args.show_deleted, @@ -408,7 +408,7 @@ def _show_policy(sc, policy_id=None, policy=None): @utils.arg('name', metavar='', help=_('Name of the policy to create.')) def do_policy_create(sc, args): - '''Create a policy.''' + """Create a policy.""" spec = utils.get_spec_content(args.spec_file) attrs = { 'name': args.name, @@ -424,7 +424,7 @@ def do_policy_create(sc, args): @utils.arg('id', metavar='', help=_('Name of the policy to be updated.')) def do_policy_show(sc, args): - '''Show the policy details.''' + """Show the policy details.""" _show_policy(sc, policy_id=args.id) @@ -439,7 +439,7 @@ def do_policy_show(sc, args): @utils.arg('id', metavar='', help=_('Name of the policy to be updated.')) def do_policy_update(sc, args): - '''Update a policy.''' + """Update a policy.""" params = { 'name': args.name, 'cooldown': args.cooldown, @@ -456,7 +456,7 @@ def do_policy_update(sc, args): @utils.arg('id', metavar='', nargs='+', help=_('Name or ID of policy(s) to delete.')) def do_policy_delete(sc, args): - '''Delete policy(s).''' + """Delete policy(s).""" failure_count = 0 for pid in args.id: @@ -499,7 +499,7 @@ def do_policy_delete(sc, args): @utils.arg('-F', '--full-id', default=False, action="store_true", help=_('Print full IDs in list.')) def do_cluster_list(sc, args=None): - '''List the user's clusters.''' + """List the user's clusters.""" fields = ['id', 'name', 'status', 'created_time', 'updated_time'] sort_keys = ['name', 'status', 'created_time', 'updated_time'] queries = { @@ -573,7 +573,7 @@ def _show_cluster(sc, cluster_id): @utils.arg('name', metavar='', help=_('Name of the cluster to create.')) def do_cluster_create(sc, args): - '''Create the cluster.''' + """Create the cluster.""" if args.min_size and not args.desired_capacity: args.desired_capacity = args.min_size attrs = { @@ -594,7 +594,7 @@ def do_cluster_create(sc, args): @utils.arg('id', metavar='', nargs='+', help=_('Name or ID of cluster(s) to delete.')) def do_cluster_delete(sc, args): - '''Delete the cluster(s).''' + """Delete the cluster(s).""" failure_count = 0 for cid in args.id: @@ -626,7 +626,7 @@ def do_cluster_delete(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to be updated.')) def do_cluster_update(sc, args): - '''Update the cluster.''' + """Update the cluster.""" cluster = sc.get_cluster(args.id) attrs = { 'name': args.name, @@ -643,7 +643,7 @@ def do_cluster_update(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to show.')) def do_cluster_show(sc, args): - '''Show details of the cluster.''' + """Show details of the cluster.""" _show_cluster(sc, args.id) @@ -663,7 +663,7 @@ def do_cluster_show(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to nodes from.')) def do_cluster_node_list(sc, args): - '''List nodes from cluster.''' + """List nodes from cluster.""" def _short_physical_id(obj): return obj.physical_id[:8] if obj.physical_id else '' @@ -700,7 +700,7 @@ def do_cluster_node_list(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) def do_cluster_node_add(sc, args): - '''Add specified nodes to cluster.''' + """Add specified nodes to cluster.""" node_ids = args.nodes.split(',') resp = sc.cluster_add_nodes(args.id, node_ids) print('Request accepted by action: %s' % resp['action']) @@ -712,7 +712,7 @@ def do_cluster_node_add(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) def do_cluster_node_del(sc, args): - '''Delete specified nodes from cluster.''' + """Delete specified nodes from cluster.""" node_ids = args.nodes.split(',') resp = sc.cluster_del_nodes(args.id, node_ids) print('Request accepted by action: %s' % resp['action']) @@ -742,7 +742,7 @@ def do_cluster_node_del(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) def do_cluster_resize(sc, args): - '''Resize a cluster.''' + """Resize a cluster.""" # validate parameters # NOTE: this will be much simpler if cliutils supports exclusive groups @@ -817,7 +817,7 @@ def do_cluster_resize(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) def do_cluster_scale_out(sc, args): - '''Scale out a cluster by the specified number of nodes.''' + """Scale out a cluster by the specified number of nodes.""" resp = sc.cluster_scale_out(args.id, args.count) print('Request accepted by action %s' % resp['action']) @@ -827,7 +827,7 @@ def do_cluster_scale_out(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) def do_cluster_scale_in(sc, args): - '''Scale in a cluster by the specified number of nodes.''' + """Scale in a cluster by the specified number of nodes.""" resp = sc.cluster_scale_in(args.id, args.count) print('Request accepted by action %s' % resp['action']) @@ -846,7 +846,7 @@ def do_cluster_scale_in(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to query on.')) def do_cluster_policy_list(sc, args): - '''List policies from cluster.''' + """List policies from cluster.""" fields = ['policy_id', 'policy', 'type', 'priority', 'level', 'cooldown', 'enabled'] sort_keys = ['priority', 'level', 'cooldown', 'enabled'] @@ -884,7 +884,7 @@ def do_cluster_policy_list(sc, args): @utils.arg('id', metavar='', help=_('ID or name of the cluster to query on.')) def do_cluster_policy_show(sc, args): - '''Show a specific policy that is bound to the specified cluster.''' + """Show a specific policy that is bound to the specified cluster.""" queries = { 'cluster_id': args.id, 'policy_id': args.policy @@ -911,7 +911,7 @@ def do_cluster_policy_show(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) def do_cluster_policy_attach(sc, args): - '''Attach policy to cluster.''' + """Attach policy to cluster.""" kwargs = { 'policy_id': args.policy, 'priority': args.priority, @@ -929,7 +929,7 @@ def do_cluster_policy_attach(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) def do_cluster_policy_detach(sc, args): - '''Detach policy from cluster.''' + """Detach policy from cluster.""" resp = sc.cluster_detach_policy(args.id, args.policy) print('Request accepted by action %s' % resp['action']) @@ -949,7 +949,7 @@ def do_cluster_policy_detach(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) def do_cluster_policy_update(sc, args): - '''Update a policy on cluster.''' + """Update a policy on cluster.""" kwargs = { 'policy_id': args.policy, 'priority': args.priority, @@ -967,7 +967,7 @@ def do_cluster_policy_update(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) def do_cluster_policy_enable(sc, args): - '''Enable a policy on cluster.''' + """Enable a policy on cluster.""" resp = sc.cluster_enable_policy(args.id, args.policy) print('Request accepted by action: %s' % resp['action']) @@ -977,7 +977,7 @@ def do_cluster_policy_enable(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) def do_cluster_policy_disable(sc, args): - '''Disable a policy on a cluster.''' + """Disable a policy on a cluster.""" resp = sc.cluster_disable_policy(args.id, args.policy) print('Request accepted by action: %s' % resp['action']) @@ -1009,7 +1009,7 @@ def do_cluster_policy_disable(sc, args): @utils.arg('-F', '--full-id', default=False, action="store_true", help=_('Print full IDs in list.')) def do_node_list(sc, args): - '''Show list of nodes.''' + """Show list of nodes.""" def _short_cluster_id(obj): return obj.cluster_id[:8] if obj.cluster_id else '' @@ -1061,7 +1061,7 @@ def do_node_list(sc, args): def _show_node(sc, node_id, show_details=False): - '''Show detailed info about the specified node.''' + """Show detailed info about the specified node.""" try: node = sc.get_node(node_id, show_details) except exc.HTTPNotFound: @@ -1094,7 +1094,7 @@ def _show_node(sc, node_id, show_details=False): @utils.arg('name', metavar='', help=_('Name of the node to create.')) def do_node_create(sc, args): - '''Create the node.''' + """Create the node.""" attrs = { 'name': args.name, 'cluster_id': args.cluster, @@ -1112,14 +1112,14 @@ def do_node_create(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of the node to show the details for.')) def do_node_show(sc, args): - '''Show detailed info about the specified node.''' + """Show detailed info about the specified node.""" _show_node(sc, args.id, args.details) @utils.arg('id', metavar='', nargs='+', help=_('Name or ID of node(s) to delete.')) def do_node_delete(sc, args): - '''Delete the node(s).''' + """Delete the node(s).""" failure_count = 0 for nid in args.id: @@ -1148,7 +1148,7 @@ def do_node_delete(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of node to update.')) def do_node_update(sc, args): - '''Update the node.''' + """Update the node.""" # Find the node first, we need its UUID try: node = sc.get_node(args.id) @@ -1171,7 +1171,7 @@ def do_node_update(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of node to operate on.')) def do_node_join(sc, args): - '''Make node join the specified cluster.''' + """Make node join the specified cluster.""" resp = sc.node_join(args.id, args.cluster) print('Request accepted by action: %s' % resp['action']) _show_node(sc, args.id) @@ -1180,7 +1180,7 @@ def do_node_join(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of node to operate on.')) def do_node_leave(sc, args): - '''Make node leave its current cluster.''' + """Make node leave its current cluster.""" resp = sc.node_leave(args.id) print('Request accepted by action: %s' % resp['action']) _show_node(sc, args.id) @@ -1212,7 +1212,7 @@ def do_node_leave(sc, args): @utils.arg('-F', '--full-id', default=False, action="store_true", help=_('Print full IDs in list.')) def do_event_list(sc, args): - '''List events.''' + """List events.""" def _short_obj_id(obj): return obj.obj_id[:8] if obj.obj_id else '' @@ -1253,7 +1253,7 @@ def do_event_list(sc, args): @utils.arg('id', metavar='', help=_('ID of event to display details for.')) def do_event_show(sc, args): - '''Describe the event.''' + """Describe the event.""" try: event = sc.get_event(args.id) except exc.HTTPNotFound as ex: @@ -1283,7 +1283,7 @@ def do_event_show(sc, args): @utils.arg('-F', '--full-id', default=False, action="store_true", help=_('Print full IDs in list.')) def do_action_list(sc, args): - '''List actions.''' + """List actions.""" def _short_target(obj): return obj.target[:8] if obj.target else '' @@ -1345,7 +1345,7 @@ def do_action_list(sc, args): @utils.arg('id', metavar='', help=_('Name or ID of the action to show the details for.')) def do_action_show(sc, args): - '''Show detailed info about the specified action.''' + """Show detailed info about the specified action.""" try: action = sc.get_action(args.id) except exc.HTTPNotFound: