From 796fe8a213b34c289bc9f5a106b2a346a57660d4 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Mon, 20 May 2013 15:34:40 +1000 Subject: [PATCH] Fix PEP H402 "one line docstring needs punctuation." Change-Id: Id0aa43187f6d5e62308f4b329bc9458a512d808d --- heat/api/cfn/v1/stacks.py | 2 +- heat/api/cloudwatch/watch.py | 2 +- heat/cfn_client/client.py | 2 +- heat/common/client.py | 2 +- heat/common/context.py | 2 +- heat/common/identifier.py | 6 +++--- heat/common/plugin_loader.py | 2 +- heat/common/policy.py | 8 ++++---- heat/db/sqlalchemy/models.py | 2 +- heat/db/sqlalchemy/session.py | 2 +- heat/engine/dependencies.py | 32 ++++++++++++++++---------------- heat/engine/event.py | 6 +++--- heat/engine/parameters.py | 12 ++++++------ heat/engine/parser.py | 16 ++++++++-------- heat/engine/resource.py | 14 +++++++------- heat/engine/resources/s3.py | 2 +- heat/engine/resources/swift.py | 2 +- heat/engine/scheduler.py | 4 ++-- heat/engine/template.py | 10 +++++----- heat/tests/test_api_cfn_v1.py | 2 +- tox.ini | 2 +- 21 files changed, 66 insertions(+), 66 deletions(-) diff --git a/heat/api/cfn/v1/stacks.py b/heat/api/cfn/v1/stacks.py index 9a171991..959a756d 100644 --- a/heat/api/cfn/v1/stacks.py +++ b/heat/api/cfn/v1/stacks.py @@ -52,7 +52,7 @@ class StackController(object): self.policy = policy.Enforcer(scope='cloudformation') def _enforce(self, req, action): - """Authorize an action against the policy.json""" + """Authorize an action against the policy.json.""" try: self.policy.enforce(req.context, action, {}) except heat_exception.Forbidden: diff --git a/heat/api/cloudwatch/watch.py b/heat/api/cloudwatch/watch.py index 2e439dbe..9f402a74 100644 --- a/heat/api/cloudwatch/watch.py +++ b/heat/api/cloudwatch/watch.py @@ -43,7 +43,7 @@ class WatchController(object): self.policy = policy.Enforcer(scope='cloudwatch') def _enforce(self, req, action): - """Authorize an action against the policy.json""" + """Authorize an action against the policy.json.""" try: self.policy.enforce(req.context, action, {}) except heat_exception.Forbidden: diff --git a/heat/cfn_client/client.py b/heat/cfn_client/client.py index 25fbc521..000f7433 100644 --- a/heat/cfn_client/client.py +++ b/heat/cfn_client/client.py @@ -36,7 +36,7 @@ SUPPORTED_PARAMS = ('StackName', 'TemplateBody', 'TemplateUrl', class V1Client(base_client.BaseClient): - """Main client class for accessing heat resources""" + """Main client class for accessing heat resources.""" DEFAULT_DOC_ROOT = "/v1" diff --git a/heat/common/client.py b/heat/common/client.py index 5c772f1c..702b6131 100644 --- a/heat/common/client.py +++ b/heat/common/client.py @@ -145,7 +145,7 @@ class HTTPSClientAuthConnection(httplib.HTTPSConnection): class BaseClient(object): - """A base client class""" + """A base client class.""" DEFAULT_PORT = 80 DEFAULT_DOC_ROOT = None diff --git a/heat/common/context.py b/heat/common/context.py index 8797fb85..fe4bb03d 100644 --- a/heat/common/context.py +++ b/heat/common/context.py @@ -95,7 +95,7 @@ class RequestContext(object): @property def show_deleted(self): - """Admins can see deleted by default""" + """Admins can see deleted by default.""" if self._show_deleted or self.is_admin: return True return False diff --git a/heat/common/identifier.py b/heat/common/identifier.py index 9e6f0e11..9a44aaf3 100644 --- a/heat/common/identifier.py +++ b/heat/common/identifier.py @@ -120,7 +120,7 @@ class HeatIdentifier(collections.Mapping): urllib.quote(self.path)) def _path_components(self): - '''Return a list of the path components''' + '''Return a list of the path components.''' return self.path.lstrip('/').split('/') def __getattr__(self, attr): @@ -155,7 +155,7 @@ class HeatIdentifier(collections.Mapping): class ResourceIdentifier(HeatIdentifier): - '''An identifier for a resource''' + '''An identifier for a resource.''' RESOURCE_NAME = 'resource_name' @@ -194,7 +194,7 @@ class ResourceIdentifier(HeatIdentifier): class EventIdentifier(HeatIdentifier): - '''An identifier for an event''' + '''An identifier for an event.''' (RESOURCE_NAME, EVENT_ID) = (ResourceIdentifier.RESOURCE_NAME, 'event_id') diff --git a/heat/common/plugin_loader.py b/heat/common/plugin_loader.py index c68b310d..7db0af0e 100644 --- a/heat/common/plugin_loader.py +++ b/heat/common/plugin_loader.py @@ -32,7 +32,7 @@ logger = logging.getLogger(__name__) def _module_name(*components): - '''Assemble a fully-qualified module name from its components''' + '''Assemble a fully-qualified module name from its components.''' return '.'.join(components) diff --git a/heat/common/policy.py b/heat/common/policy.py index a2a400ee..9b8d564f 100644 --- a/heat/common/policy.py +++ b/heat/common/policy.py @@ -44,7 +44,7 @@ DEFAULT_RULES = { class Enforcer(object): - """Responsible for loading and enforcing rules""" + """Responsible for loading and enforcing rules.""" def __init__(self, scope='heat', exc=exception.Forbidden): self.scope = scope @@ -55,12 +55,12 @@ class Enforcer(object): self.policy_file_contents = None def set_rules(self, rules): - """Create a new Rules object based on the provided dict of rules""" + """Create a new Rules object based on the provided dict of rules.""" rules_obj = policy.Rules(rules, self.default_rule) policy.set_rules(rules_obj) def load_rules(self): - """Set the rules found in the json file on disk""" + """Set the rules found in the json file on disk.""" if self.policy_path: rules = self._read_policy_file() rule_type = "" @@ -74,7 +74,7 @@ class Enforcer(object): @staticmethod def _find_policy_file(): - """Locate the policy json data file""" + """Locate the policy json data file.""" policy_file = CONF.find_file(CONF.policy_file) if policy_file: return policy_file diff --git a/heat/db/sqlalchemy/models.py b/heat/db/sqlalchemy/models.py index a929604a..2e359d80 100644 --- a/heat/db/sqlalchemy/models.py +++ b/heat/db/sqlalchemy/models.py @@ -106,7 +106,7 @@ class HeatBase(object): return n, getattr(self, n) def update(self, values): - """Make the model object behave like a dict""" + """Make the model object behave like a dict.""" for k, v in values.iteritems(): setattr(self, k, v) diff --git a/heat/db/sqlalchemy/session.py b/heat/db/sqlalchemy/session.py index be1677bd..72daff47 100644 --- a/heat/db/sqlalchemy/session.py +++ b/heat/db/sqlalchemy/session.py @@ -39,7 +39,7 @@ def get_session(autocommit=True, expire_on_commit=False): class SynchronousSwitchListener(sqlalchemy.interfaces.PoolListener): - """Switch sqlite connections to non-synchronous mode""" + """Switch sqlite connections to non-synchronous mode.""" def connect(self, dbapi_con, con_record): dbapi_con.execute("PRAGMA synchronous = OFF") diff --git a/heat/engine/dependencies.py b/heat/engine/dependencies.py index 882158ee..63c7b4f8 100644 --- a/heat/engine/dependencies.py +++ b/heat/engine/dependencies.py @@ -24,7 +24,7 @@ class CircularDependencyException(exception.OpenstackException): class Dependencies(object): - '''Helper class for calculating a dependency graph''' + '''Helper class for calculating a dependency graph.''' class Node(object): def __init__(self, requires=None, required_by=None): @@ -36,11 +36,11 @@ class Dependencies(object): self.satisfy = required_by and required_by.copy() or set() def copy(self): - '''Make a copy of the node''' + '''Make a copy of the node.''' return Dependencies.Node(self.require, self.satisfy) def reverse_copy(self): - '''Make a copy of the node with the edge directions reversed''' + '''Make a copy of the node with the edge directions reversed.''' return Dependencies.Node(self.satisfy, self.require) def required_by(self, source=None): @@ -53,11 +53,11 @@ class Dependencies(object): return iter(self.satisfy) def requires(self, target): - '''Add a key that this node requires''' + '''Add a key that this node requires.''' self.require.add(target) def __isub__(self, target): - '''Remove a key that this node requires''' + '''Remove a key that this node requires.''' self.require.remove(target) return self @@ -68,27 +68,27 @@ class Dependencies(object): return bool(self.require) def stem(self): - '''Return True if this node is a stem (required by nothing)''' + '''Return True if this node is a stem (required by nothing).''' return not bool(self.satisfy) def disjoint(self): - '''Return True if this node is both a leaf and a stem''' + '''Return True if this node is both a leaf and a stem.''' return (not self) and self.stem() def __len__(self): - '''Count the number of keys required by this node''' + '''Count the number of keys required by this node.''' return len(self.require) def __iter__(self): - '''Iterate over the keys required by this node''' + '''Iterate over the keys required by this node.''' return iter(self.require) def __str__(self): - '''Return a human-readable string representation of the node''' + '''Return a human-readable string representation of the node.''' return '{%s}' % ', '.join(str(n) for n in self) def __repr__(self): - '''Return a string representation of the node''' + '''Return a string representation of the node.''' return repr(self.require) def __init__(self, edges=[]): @@ -101,7 +101,7 @@ class Dependencies(object): self += e def __iadd__(self, edge): - '''Add another edge, in the form of a (requirer, required) tuple''' + '''Add another edge, in the form of a (requirer, required) tuple.''' requirer, required = edge if required is None: @@ -143,7 +143,7 @@ class Dependencies(object): @staticmethod def _deps_to_str(deps): - '''Convert the given dependency graph to a human-readable string''' + '''Convert the given dependency graph to a human-readable string.''' pairs = ('%s: %s' % (str(k), str(v)) for k, v in deps.items()) return '{%s}' % ', '.join(pairs) @@ -154,7 +154,7 @@ class Dependencies(object): return self._deps_to_str(self.deps) def _edges(self): - '''Return an iterator over all of the edges in the graph''' + '''Return an iterator over all of the edges in the graph.''' def outgoing_edges(rqr, node): if node.disjoint(): yield (rqr, None) @@ -165,11 +165,11 @@ class Dependencies(object): for item in self.deps.iteritems()) def __repr__(self): - '''Return a string representation of the object''' + '''Return a string representation of the object.''' return 'Dependencies([%s])' % ', '.join(repr(e) for e in self._edges()) def _toposort(self, deps): - '''Generate a topological sort of a dependency graph''' + '''Generate a topological sort of a dependency graph.''' def next_leaf(): for leaf, node in deps.items(): if not node: diff --git a/heat/engine/event.py b/heat/engine/event.py index 3017a4f2..17de7ad0 100644 --- a/heat/engine/event.py +++ b/heat/engine/event.py @@ -48,7 +48,7 @@ class Event(object): @classmethod def load(cls, context, event_id): - '''Retrieve an Event from the database''' + '''Retrieve an Event from the database.''' from heat.engine import parser ev = db_api.event_get(context, event_id) @@ -67,7 +67,7 @@ class Event(object): return event def store(self): - '''Store the Event in the database''' + '''Store the Event in the database.''' ev = { 'logical_resource_id': self.resource.name, 'physical_resource_id': self.physical_resource_id, @@ -91,7 +91,7 @@ class Event(object): return self.id def identifier(self): - '''Return a unique identifier for the event''' + '''Return a unique identifier for the event.''' if self.id is None: return None diff --git a/heat/engine/parameters.py b/heat/engine/parameters.py index 3776e1af..6b5af4fa 100644 --- a/heat/engine/parameters.py +++ b/heat/engine/parameters.py @@ -158,7 +158,7 @@ class StringParam(Parameter): '''A template parameter of type "String".''' def _validate(self, value): - '''Check that the supplied value is compatible with the constraints''' + '''Check that the supplied value is compatible with the constraints.''' if not isinstance(value, basestring): raise ValueError(self._error_msg('value must be a string')) @@ -195,7 +195,7 @@ class CommaDelimitedListParam(Parameter, collections.Sequence): '''A template parameter of type "CommaDelimitedList".''' def _validate(self, value): - '''Check that the supplied value is compatible with the constraints''' + '''Check that the supplied value is compatible with the constraints.''' try: sp = value.split(',') except AttributeError: @@ -205,11 +205,11 @@ class CommaDelimitedListParam(Parameter, collections.Sequence): Parameter._validate(self, li) def __len__(self): - '''Return the length of the list''' + '''Return the length of the list.''' return len(self.value().split(',')) def __getitem__(self, index): - '''Return an item from the list''' + '''Return an item from the list.''' return self.value().split(',')[index] @@ -249,7 +249,7 @@ class Parameters(collections.Mapping): self.params = dict((p.name, p) for p in parameters()) def __contains__(self, key): - '''Return whether the specified parameter exists''' + '''Return whether the specified parameter exists.''' return key in self.params def __iter__(self): @@ -257,7 +257,7 @@ class Parameters(collections.Mapping): return iter(self.params) def __len__(self): - '''Return the number of parameters defined''' + '''Return the number of parameters defined.''' return len(self.params) def __getitem__(self, key): diff --git a/heat/engine/parser.py b/heat/engine/parser.py index 7e7089a2..a5cfd64e 100644 --- a/heat/engine/parser.py +++ b/heat/engine/parser.py @@ -124,7 +124,7 @@ class Stack(object): @staticmethod def _get_dependencies(resources): - '''Return the dependency graph for a list of resources''' + '''Return the dependency graph for a list of resources.''' deps = dependencies.Dependencies() for resource in resources: resource.add_dependencies(deps) @@ -133,7 +133,7 @@ class Stack(object): @classmethod def load(cls, context, stack_id=None, stack=None, resolve_data=True): - '''Retrieve a Stack from the database''' + '''Retrieve a Stack from the database.''' if stack is None: stack = db_api.stack_get(context, stack_id) if stack is None: @@ -200,7 +200,7 @@ class Stack(object): return reversed(self.dependencies) def __len__(self): - '''Return the number of resources''' + '''Return the number of resources.''' return len(self.resources) def __getitem__(self, key): @@ -208,19 +208,19 @@ class Stack(object): return self.resources[key] def __setitem__(self, key, value): - '''Set the resource with the specified name to a specific value''' + '''Set the resource with the specified name to a specific value.''' self.resources[key] = value def __contains__(self, key): - '''Determine whether the stack contains the specified resource''' + '''Determine whether the stack contains the specified resource.''' return key in self.resources def keys(self): - '''Return a list of resource keys for the stack''' + '''Return a list of resource keys for the stack.''' return self.resources.keys() def __str__(self): - '''Return a human-readable string representation of the stack''' + '''Return a human-readable string representation of the stack.''' return 'Stack "%s"' % self.name def resource_by_refid(self, refid): @@ -253,7 +253,7 @@ class Stack(object): raise StackValidationFailed(message=result) def state_set(self, new_status, reason): - '''Update the stack state in the database''' + '''Update the stack state in the database.''' self.state = new_status self.state_description = reason diff --git a/heat/engine/resource.py b/heat/engine/resource.py index b34a3c67..39165774 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -34,12 +34,12 @@ _resource_classes = {} def get_types(): - '''Return an iterator over the list of valid resource types''' + '''Return an iterator over the list of valid resource types.''' return iter(_resource_classes) def get_class(resource_type): - '''Return the Resource class for a given resource type''' + '''Return the Resource class for a given resource type.''' cls = _resource_classes.get(resource_type) if cls is None: msg = "Unknown resource Type : %s" % resource_type @@ -155,7 +155,7 @@ class Resource(object): self.id = None def __eq__(self, other): - '''Allow == comparison of two resources''' + '''Allow == comparison of two resources.''' # For the purposes of comparison, we declare two resource objects # equal if their names and parsed_templates are the same if isinstance(other, Resource): @@ -164,7 +164,7 @@ class Resource(object): return NotImplemented def __ne__(self, other): - '''Allow != comparison of two resources''' + '''Allow != comparison of two resources.''' result = self.__eq__(other) if result is NotImplemented: return result @@ -174,7 +174,7 @@ class Resource(object): return self.t['Type'] def identifier(self): - '''Return an identifier for this resource''' + '''Return an identifier for this resource.''' return identifier.ResourceIdentifier(resource_name=self.name, **self.stack.identifier()) @@ -488,7 +488,7 @@ class Resource(object): logger.warn('db error %s' % str(ex)) def _store(self): - '''Create the resource in the database''' + '''Create the resource in the database.''' try: rs = {'state': self.state, 'stack_id': self.stack.id, @@ -506,7 +506,7 @@ class Resource(object): logger.error('DB error %s' % str(ex)) def _add_event(self, new_state, reason): - '''Add a state change event to the database''' + '''Add a state change event to the database.''' ev = event.Event(self.context, self.stack, self, new_state, reason, self.resource_id, self.properties) diff --git a/heat/engine/resources/s3.py b/heat/engine/resources/s3.py index df7f2697..86a0bcfd 100644 --- a/heat/engine/resources/s3.py +++ b/heat/engine/resources/s3.py @@ -89,7 +89,7 @@ class S3Bucket(resource.Resource): return self.UPDATE_REPLACE def handle_delete(self): - """Perform specified delete policy""" + """Perform specified delete policy.""" logger.debug('S3Bucket delete container %s' % self.resource_id) if self.resource_id is not None: try: diff --git a/heat/engine/resources/swift.py b/heat/engine/resources/swift.py index 219a9042..a55feac2 100644 --- a/heat/engine/resources/swift.py +++ b/heat/engine/resources/swift.py @@ -78,7 +78,7 @@ class SwiftContainer(resource.Resource): return self.UPDATE_REPLACE def handle_delete(self): - """Perform specified delete policy""" + """Perform specified delete policy.""" logger.debug('SwiftContainer delete container %s' % self.resource_id) if self.resource_id is not None: try: diff --git a/heat/engine/scheduler.py b/heat/engine/scheduler.py index d6a48c59..11bca52b 100644 --- a/heat/engine/scheduler.py +++ b/heat/engine/scheduler.py @@ -256,7 +256,7 @@ class PollingTaskGroup(object): """ def __init__(self, tasks, name=None): - """Initialise with a list of tasks""" + """Initialise with a list of tasks.""" self._tasks = list(tasks) if name is None: name = ', '.join(task_description(t) for t in self._tasks) @@ -321,7 +321,7 @@ class PollingTaskGroup(object): return '%s(%s)' % (type(self).__name__, self.name) def __call__(self): - """Return a co-routine which runs the task group""" + """Return a co-routine which runs the task group.""" runners = [TaskRunner(t) for t in self._tasks] try: diff --git a/heat/engine/template.py b/heat/engine/template.py index 6078fed2..b0714c1f 100644 --- a/heat/engine/template.py +++ b/heat/engine/template.py @@ -38,12 +38,12 @@ class Template(collections.Mapping): @classmethod def load(cls, context, template_id): - '''Retrieve a Template with the given ID from the database''' + '''Retrieve a Template with the given ID from the database.''' t = db_api.raw_template_get(context, template_id) return cls(t.template, template_id) def store(self, context=None): - '''Store the Template in the database and return its ID''' + '''Store the Template in the database and return its ID.''' if self.id is None: rt = {'template': self.t} new_rt = db_api.raw_template_create(context, rt) @@ -51,7 +51,7 @@ class Template(collections.Mapping): return self.id def __getitem__(self, section): - '''Get the relevant section in the template''' + '''Get the relevant section in the template.''' if section not in SECTIONS: raise KeyError('"%s" is not a valid template section' % section) if section == VERSION: @@ -65,11 +65,11 @@ class Template(collections.Mapping): return self.t.get(section, default) def __iter__(self): - '''Return an iterator over the section names''' + '''Return an iterator over the section names.''' return iter(SECTIONS) def __len__(self): - '''Return the number of sections''' + '''Return the number of sections.''' return len(SECTIONS) def resolve_find_in_map(self, s): diff --git a/heat/tests/test_api_cfn_v1.py b/heat/tests/test_api_cfn_v1.py index 6ec9c4a8..8ef8eabe 100644 --- a/heat/tests/test_api_cfn_v1.py +++ b/heat/tests/test_api_cfn_v1.py @@ -427,7 +427,7 @@ class CfnStackControllerTest(HeatTestCase): self.m.VerifyAll() def test_get_template_int_body(self): - ''' Test the internal _get_template function ''' + '''Test the internal _get_template function.''' params = {'TemplateBody': "abcdef"} dummy_req = self._dummy_GET_request(params) result = self.controller._get_template(dummy_req) diff --git a/tox.ini b/tox.ini index 14c607d5..e70c03eb 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ commands = python setup.py testr --coverage [flake8] -ignore = H302,H303,H304,H403,H404,F403,F841,H306,H902,H401,H402,H201,H101,H703,H301,H702 +ignore = H302,H303,H304,H403,H404,F403,F841,H306,H902,H201,H101,H703,H301,H702 show-source = true builtins = _ exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools,build -- 2.45.2