#NEWLINE# def ApplyFormat( self , variable , name , policy ) : #NEWLINE# #INDENT# 'Applies the format of a naming policy to a string.\n\n    Args:\n      variable: (CodeObject) The template variable this string came from. This\n          is used to extract details about the variable which may be useful in\n          building a name, such as the module it belongs to.\n      name: (str) A name to transform.\n      policy: (NamingPolicy) The naming policy to use for the transform.\n    Returns:\n      Transformed string.\n    ' #NEWLINE# expansions = dict ( name = name ) #NEWLINE# parent_name = 'global' #NEWLINE# if variable : #NEWLINE# #INDENT# if hasattr ( variable , 'module' ) : #NEWLINE# #INDENT# expansions [ 'module' ] = variable . module . name #NEWLINE# #UNINDENT# if hasattr ( variable , 'api' ) : #NEWLINE# #INDENT# api = variable . api #NEWLINE# if api : #NEWLINE# #INDENT# api_name = ( api . GetTemplateValue ( 'wireName' ) or parent_name ) #NEWLINE# #UNINDENT# expansions [ 'api_name' ] = self . ApplyCaseTransform ( api_name , policy ) #NEWLINE# #UNINDENT# if hasattr ( variable , 'parent' ) : #NEWLINE# #INDENT# parent = variable . parent #NEWLINE# if parent : #NEWLINE# #INDENT# parent_name = ( parent . GetTemplateValue ( 'wireName' ) or parent_name ) #NEWLINE# #UNINDENT# #UNINDENT# if hasattr ( variable , 'schema' ) : #NEWLINE# #INDENT# expansions [ 'schema' ] = variable . schema #NEWLINE# #UNINDENT# expansions [ 'variable_name' ] = self . ApplyCaseTransform ( ( variable . GetTemplateValue ( 'wireName' ) or '' ) , policy ) #NEWLINE# #UNINDENT# expansions [ 'parent_name' ] = self . ApplyCaseTransform ( parent_name , policy ) #NEWLINE# return policy . format_string . format ( ** expansions )