(self, variable, name, policy)
return policy.format_string.format(**expansions)
Applies the format of a naming policy to a string.

    Args:
      variable: (CodeObject) The template variable this string came from. This
          is used to extract details about the variable which may be useful in
          building a name, such as the module it belongs to.
      name: (str) A name to transform.
      policy: (NamingPolicy) The naming policy to use for the transform.
    Returns:
      Transformed string.
Applies the format of a naming policy to a string.
Applies the format of a naming policy to a string .
def ApplyFormat(self, variable, name, policy):
    """Applies the format of a naming policy to a string.

    Args:
      variable: (CodeObject) The template variable this string came from. This
          is used to extract details about the variable which may be useful in
          building a name, such as the module it belongs to.
      name: (str) A name to transform.
      policy: (NamingPolicy) The naming policy to use for the transform.
    Returns:
      Transformed string.
    """
    expansions = dict(name=name)
    # The variable should always be present in normal execution. We allow
    # it to be None solely for testing.
    # TODO(user): Figure out a way to fail hard if not present during
    # execution, even though django catches the error and siliently ignores it.
    # OR... maybe just fix the tests to always pass in the complete kind of
    # object we need.
    parent_name = 'global'
    if variable:
      if hasattr(variable, 'module'):
        expansions['module'] = variable.module.name
      if hasattr(variable, 'api'):
        api = variable.api
        if api:
          api_name = api.GetTemplateValue('wireName') or parent_name
        expansions['api_name'] = self.ApplyCaseTransform(api_name, policy)
      if hasattr(variable, 'parent'):
        parent = variable.parent
        if parent:
          parent_name = parent.GetTemplateValue('wireName') or parent_name
      if hasattr(variable, 'schema'):
        # This lets the format string access all template values on schema,
        # which is powerful but potentially flaky if the schema changes.
        expansions['schema'] = variable.schema
      expansions['variable_name'] = self.ApplyCaseTransform(
          variable.GetTemplateValue('wireName') or '', policy)
    expansions['parent_name'] = self.ApplyCaseTransform(parent_name,
                                                        policy)
    # TODO(user): Expand the range of things available.
    return policy.format_string.format(**expansions)
def ApplyFormat ( self , variable , name , policy ) : expansions = dict ( name = name ) # The variable should always be present in normal execution. We allow # it to be None solely for testing. # TODO(user): Figure out a way to fail hard if not present during # execution, even though django catches the error and siliently ignores it. # OR... maybe just fix the tests to always pass in the complete kind of # object we need. parent_name = 'global' if variable : if hasattr ( variable , 'module' ) : expansions [ 'module' ] = variable . module . name if hasattr ( variable , 'api' ) : api = variable . api if api : api_name = api . GetTemplateValue ( 'wireName' ) or parent_name expansions [ 'api_name' ] = self . ApplyCaseTransform ( api_name , policy ) if hasattr ( variable , 'parent' ) : parent = variable . parent if parent : parent_name = parent . GetTemplateValue ( 'wireName' ) or parent_name if hasattr ( variable , 'schema' ) : # This lets the format string access all template values on schema, # which is powerful but potentially flaky if the schema changes. expansions [ 'schema' ] = variable . schema expansions [ 'variable_name' ] = self . ApplyCaseTransform ( variable . GetTemplateValue ( 'wireName' ) or '' , policy ) expansions [ 'parent_name' ] = self . ApplyCaseTransform ( parent_name , policy ) # TODO(user): Expand the range of things available. return policy . format_string . format ( * * expansions )