Fix PEP H402 "one line docstring needs punctuation."

Change-Id: Id0aa43187f6d5e62308f4b329bc9458a512d808d
This commit is contained in:
Angus Salkeld 2013-05-20 15:34:40 +10:00
parent f67dc437f3
commit 796fe8a213
21 changed files with 66 additions and 66 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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")

View File

@ -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:

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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):

View File

@ -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)

View File

@ -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