Merge "Fix [H405] pep rule in heat/engine/cfn"

This commit is contained in:
Jenkins 2015-09-22 09:57:45 +00:00 committed by Gerrit Code Review
commit a2cd6aa1ff
2 changed files with 29 additions and 41 deletions

View File

@ -24,15 +24,14 @@ from heat.engine import function
class FindInMap(function.Function): class FindInMap(function.Function):
''' """A function for resolving keys in the template mappings.
A function for resolving keys in the template mappings.
Takes the form:: Takes the form::
{ "Fn::FindInMap" : [ "mapping", { "Fn::FindInMap" : [ "mapping",
"key", "key",
"value" ] } "value" ] }
''' """
def __init__(self, stack, fn_name, args): def __init__(self, stack, fn_name, args):
super(FindInMap, self).__init__(stack, fn_name, args) super(FindInMap, self).__init__(stack, fn_name, args)
@ -50,13 +49,12 @@ class FindInMap(function.Function):
class GetAZs(function.Function): class GetAZs(function.Function):
''' """A function for retrieving the availability zones.
A function for retrieving the availability zones.
Takes the form:: Takes the form::
{ "Fn::GetAZs" : "<region>" } { "Fn::GetAZs" : "<region>" }
''' """
def result(self): def result(self):
# TODO(therve): Implement region scoping # TODO(therve): Implement region scoping
@ -69,13 +67,12 @@ class GetAZs(function.Function):
class ParamRef(function.Function): class ParamRef(function.Function):
''' """A function for resolving parameter references.
A function for resolving parameter references.
Takes the form:: Takes the form::
{ "Ref" : "<param_name>" } { "Ref" : "<param_name>" }
''' """
def __init__(self, stack, fn_name, args): def __init__(self, stack, fn_name, args):
super(ParamRef, self).__init__(stack, fn_name, args) super(ParamRef, self).__init__(stack, fn_name, args)
@ -93,13 +90,12 @@ class ParamRef(function.Function):
class ResourceRef(function.Function): class ResourceRef(function.Function):
''' """A function for resolving resource references.
A function for resolving resource references.
Takes the form:: Takes the form::
{ "Ref" : "<resource_name>" } { "Ref" : "<resource_name>" }
''' """
def _resource(self, path='unknown'): def _resource(self, path='unknown'):
resource_name = function.resolve(self.args) resource_name = function.resolve(self.args)
@ -119,8 +115,7 @@ class ResourceRef(function.Function):
def Ref(stack, fn_name, args): def Ref(stack, fn_name, args):
''' """A function for resolving parameters or resource references.
A function for resolving parameters or resource references.
Takes the form:: Takes the form::
@ -129,7 +124,7 @@ def Ref(stack, fn_name, args):
or:: or::
{ "Ref" : "<resource_name>" } { "Ref" : "<resource_name>" }
''' """
if args in stack: if args in stack:
RefClass = ResourceRef RefClass = ResourceRef
else: else:
@ -138,14 +133,13 @@ def Ref(stack, fn_name, args):
class GetAtt(function.Function): class GetAtt(function.Function):
''' """A function for resolving resource attributes.
A function for resolving resource attributes.
Takes the form:: Takes the form::
{ "Fn::GetAtt" : [ "<resource_name>", { "Fn::GetAtt" : [ "<resource_name>",
"<attribute_name" ] } "<attribute_name" ] }
''' """
def __init__(self, stack, fn_name, args): def __init__(self, stack, fn_name, args):
super(GetAtt, self).__init__(stack, fn_name, args) super(GetAtt, self).__init__(stack, fn_name, args)
@ -208,8 +202,7 @@ class GetAtt(function.Function):
class Select(function.Function): class Select(function.Function):
''' """A function for selecting an item from a list or map.
A function for selecting an item from a list or map.
Takes the form (for a list lookup):: Takes the form (for a list lookup)::
@ -221,7 +214,7 @@ class Select(function.Function):
If the selected index is not found, this function resolves to an empty If the selected index is not found, this function resolves to an empty
string. string.
''' """
def __init__(self, stack, fn_name, args): def __init__(self, stack, fn_name, args):
super(Select, self).__init__(stack, fn_name, args) super(Select, self).__init__(stack, fn_name, args)
@ -282,8 +275,7 @@ class Select(function.Function):
class Join(function.Function): class Join(function.Function):
''' """A function for joining strings.
A function for joining strings.
Takes the form:: Takes the form::
@ -292,7 +284,7 @@ class Join(function.Function):
And resolves to:: And resolves to::
"<string_1><delim><string_2><delim>..." "<string_1><delim><string_2><delim>..."
''' """
def __init__(self, stack, fn_name, args): def __init__(self, stack, fn_name, args):
super(Join, self).__init__(stack, fn_name, args) super(Join, self).__init__(stack, fn_name, args)
@ -336,8 +328,7 @@ class Join(function.Function):
class Split(function.Function): class Split(function.Function):
''' """A function for splitting strings.
A function for splitting strings.
Takes the form:: Takes the form::
@ -346,7 +337,7 @@ class Split(function.Function):
And resolves to:: And resolves to::
[ "<string_1>", "<string_2>", ... ] [ "<string_1>", "<string_2>", ... ]
''' """
def __init__(self, stack, fn_name, args): def __init__(self, stack, fn_name, args):
super(Split, self).__init__(stack, fn_name, args) super(Split, self).__init__(stack, fn_name, args)
@ -379,8 +370,7 @@ class Split(function.Function):
class Replace(function.Function): class Replace(function.Function):
''' """A function for performing string substitutions.
A function for performing string substitutions.
Takes the form:: Takes the form::
@ -395,7 +385,7 @@ class Replace(function.Function):
This is implemented using python str.replace on each key. The order in This is implemented using python str.replace on each key. The order in
which replacements are performed is undefined. which replacements are performed is undefined.
''' """
def __init__(self, stack, fn_name, args): def __init__(self, stack, fn_name, args):
super(Replace, self).__init__(stack, fn_name, args) super(Replace, self).__init__(stack, fn_name, args)
@ -458,8 +448,7 @@ class Replace(function.Function):
class Base64(function.Function): class Base64(function.Function):
''' """A placeholder function for converting to base64.
A placeholder function for converting to base64.
Takes the form:: Takes the form::
@ -468,7 +457,7 @@ class Base64(function.Function):
This function actually performs no conversion. It is included for the This function actually performs no conversion. It is included for the
benefit of templates that convert UserData to Base64. Heat accepts UserData benefit of templates that convert UserData to Base64. Heat accepts UserData
in plain text. in plain text.
''' """
def result(self): def result(self):
resolved = function.resolve(self.args) resolved = function.resolve(self.args)
@ -478,9 +467,7 @@ class Base64(function.Function):
class MemberListToMap(function.Function): class MemberListToMap(function.Function):
''' """A function to convert lists with enumerated keys and values to mapping.
A function for converting lists containing enumerated keys and values to
a mapping.
Takes the form:: Takes the form::
@ -495,7 +482,7 @@ class MemberListToMap(function.Function):
{ "<key_0>" : "<value_0>", ... } { "<key_0>" : "<value_0>", ... }
The first two arguments are the names of the key and value. The first two arguments are the names of the key and value.
''' """
def __init__(self, stack, fn_name, args): def __init__(self, stack, fn_name, args):
super(MemberListToMap, self).__init__(stack, fn_name, args) super(MemberListToMap, self).__init__(stack, fn_name, args)
@ -535,7 +522,8 @@ class MemberListToMap(function.Function):
class ResourceFacade(function.Function): class ResourceFacade(function.Function):
''' """A function for retrieving data in a parent provider template.
A function for obtaining data from the facade resource from within the A function for obtaining data from the facade resource from within the
corresponding provider template. corresponding provider template.
@ -545,7 +533,7 @@ class ResourceFacade(function.Function):
where the valid attribute types are "Metadata", "DeletionPolicy" and where the valid attribute types are "Metadata", "DeletionPolicy" and
"UpdatePolicy". "UpdatePolicy".
''' """
_RESOURCE_ATTRIBUTES = ( _RESOURCE_ATTRIBUTES = (
METADATA, DELETION_POLICY, UPDATE_POLICY, METADATA, DELETION_POLICY, UPDATE_POLICY,

View File

@ -34,7 +34,7 @@ _RESOURCE_KEYS = (
class CfnTemplate(template.Template): class CfnTemplate(template.Template):
'''A stack template.''' """A stack template."""
SECTIONS = ( SECTIONS = (
VERSION, ALTERNATE_VERSION, VERSION, ALTERNATE_VERSION,
@ -63,7 +63,7 @@ class CfnTemplate(template.Template):
} }
def __getitem__(self, section): def __getitem__(self, section):
'''Get the relevant section in the template.''' """Get the relevant section in the template."""
if section not in self.SECTIONS: if section not in self.SECTIONS:
raise KeyError(_('"%s" is not a valid template section') % section) raise KeyError(_('"%s" is not a valid template section') % section)
if section in self.SECTIONS_NO_DIRECT_ACCESS: if section in self.SECTIONS_NO_DIRECT_ACCESS: