From b07ca6d4d1349bc6ae398b1373907bcbb02b6e29 Mon Sep 17 00:00:00 2001 From: Peter Razumovsky Date: Fri, 18 Sep 2015 10:20:15 +0300 Subject: [PATCH] Fix [H405] pep rule in heat/engine/cfn Implements bp docstring-improvements Change-Id: Icacc8b590437f29abb9be9af7c6c8a62667d687a --- heat/engine/cfn/functions.py | 66 +++++++++++++++--------------------- heat/engine/cfn/template.py | 4 +-- 2 files changed, 29 insertions(+), 41 deletions(-) diff --git a/heat/engine/cfn/functions.py b/heat/engine/cfn/functions.py index b13eb510f7..5302b04063 100644 --- a/heat/engine/cfn/functions.py +++ b/heat/engine/cfn/functions.py @@ -24,15 +24,14 @@ from heat.engine import 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:: { "Fn::FindInMap" : [ "mapping", "key", "value" ] } - ''' + """ def __init__(self, stack, fn_name, args): super(FindInMap, self).__init__(stack, fn_name, args) @@ -50,13 +49,12 @@ class FindInMap(function.Function): class GetAZs(function.Function): - ''' - A function for retrieving the availability zones. + """A function for retrieving the availability zones. Takes the form:: { "Fn::GetAZs" : "" } - ''' + """ def result(self): # TODO(therve): Implement region scoping @@ -69,13 +67,12 @@ class GetAZs(function.Function): class ParamRef(function.Function): - ''' - A function for resolving parameter references. + """A function for resolving parameter references. Takes the form:: { "Ref" : "" } - ''' + """ def __init__(self, stack, fn_name, args): super(ParamRef, self).__init__(stack, fn_name, args) @@ -93,13 +90,12 @@ class ParamRef(function.Function): class ResourceRef(function.Function): - ''' - A function for resolving resource references. + """A function for resolving resource references. Takes the form:: { "Ref" : "" } - ''' + """ def _resource(self, path='unknown'): resource_name = function.resolve(self.args) @@ -119,8 +115,7 @@ class ResourceRef(function.Function): 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:: @@ -129,7 +124,7 @@ def Ref(stack, fn_name, args): or:: { "Ref" : "" } - ''' + """ if args in stack: RefClass = ResourceRef else: @@ -138,14 +133,13 @@ def Ref(stack, fn_name, args): class GetAtt(function.Function): - ''' - A function for resolving resource attributes. + """A function for resolving resource attributes. Takes the form:: { "Fn::GetAtt" : [ "", "..." - ''' + """ def __init__(self, stack, fn_name, args): super(Join, self).__init__(stack, fn_name, args) @@ -336,8 +328,7 @@ class Join(function.Function): class Split(function.Function): - ''' - A function for splitting strings. + """A function for splitting strings. Takes the form:: @@ -346,7 +337,7 @@ class Split(function.Function): And resolves to:: [ "", "", ... ] - ''' + """ def __init__(self, stack, fn_name, args): super(Split, self).__init__(stack, fn_name, args) @@ -379,8 +370,7 @@ class Split(function.Function): class Replace(function.Function): - ''' - A function for performing string substitutions. + """A function for performing string substitutions. Takes the form:: @@ -395,7 +385,7 @@ class Replace(function.Function): This is implemented using python str.replace on each key. The order in which replacements are performed is undefined. - ''' + """ def __init__(self, stack, fn_name, args): super(Replace, self).__init__(stack, fn_name, args) @@ -458,8 +448,7 @@ class Replace(function.Function): class Base64(function.Function): - ''' - A placeholder function for converting to base64. + """A placeholder function for converting to base64. Takes the form:: @@ -468,7 +457,7 @@ class Base64(function.Function): This function actually performs no conversion. It is included for the benefit of templates that convert UserData to Base64. Heat accepts UserData in plain text. - ''' + """ def result(self): resolved = function.resolve(self.args) @@ -478,9 +467,7 @@ class Base64(function.Function): class MemberListToMap(function.Function): - ''' - A function for converting lists containing enumerated keys and values to - a mapping. + """A function to convert lists with enumerated keys and values to mapping. Takes the form:: @@ -495,7 +482,7 @@ class MemberListToMap(function.Function): { "" : "", ... } The first two arguments are the names of the key and value. - ''' + """ def __init__(self, stack, fn_name, args): super(MemberListToMap, self).__init__(stack, fn_name, args) @@ -535,7 +522,8 @@ class MemberListToMap(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 corresponding provider template. @@ -545,7 +533,7 @@ class ResourceFacade(function.Function): where the valid attribute types are "Metadata", "DeletionPolicy" and "UpdatePolicy". - ''' + """ _RESOURCE_ATTRIBUTES = ( METADATA, DELETION_POLICY, UPDATE_POLICY, diff --git a/heat/engine/cfn/template.py b/heat/engine/cfn/template.py index 34ad025725..d249a6f325 100644 --- a/heat/engine/cfn/template.py +++ b/heat/engine/cfn/template.py @@ -34,7 +34,7 @@ _RESOURCE_KEYS = ( class CfnTemplate(template.Template): - '''A stack template.''' + """A stack template.""" SECTIONS = ( VERSION, ALTERNATE_VERSION, @@ -63,7 +63,7 @@ class CfnTemplate(template.Template): } def __getitem__(self, section): - '''Get the relevant section in the template.''' + """Get the relevant section in the template.""" if section not in self.SECTIONS: raise KeyError(_('"%s" is not a valid template section') % section) if section in self.SECTIONS_NO_DIRECT_ACCESS: