(str)
return str
Takes a string containing variable references in the form ${FOO}, $(FOO),
  or $FOO, and returns a string with all variable references in the form ${FOO}.
Takes a string containing variable references in the form ${FOO}, $(FOO),
  or $FOO, and returns a string with all variable references in the form ${FOO}.
Takes a string containing variable references in the form $ { FOO } $ ( FOO ) or $FOO and returns a string with all variable references in the form $ { FOO } .
def _NormalizeEnvVarReferences(str):
  """Takes a string containing variable references in the form ${FOO}, $(FOO),
  or $FOO, and returns a string with all variable references in the form ${FOO}.
  """
  # $FOO -> ${FOO}
  str = re.sub(r'\$([a-zA-Z_][a-zA-Z0-9_]*)', r'${\1}', str)

  # $(FOO) -> ${FOO}
  matches = re.findall(r'(\$\(([a-zA-Z0-9\-_]+)\))', str)
  for match in matches:
    to_replace, variable = match
    assert '$(' not in match, '$($(FOO)) variables not supported: ' + match
    str = str.replace(to_replace, '${' + variable + '}')

  return str
def _NormalizeEnvVarReferences ( str ) : # $FOO -> ${FOO} str = re . sub ( r'\$([a-zA-Z_][a-zA-Z0-9_]*)' , r'${\1}' , str ) # $(FOO) -> ${FOO} matches = re . findall ( r'(\$\(([a-zA-Z0-9\-_]+)\))' , str ) for match in matches : to_replace , variable = match assert '$(' not in match , '$($(FOO)) variables not supported: ' + match str = str . replace ( to_replace , '${' + variable + '}' ) return str