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
Takes a string containing variable references in the form ${FOO}, $(FOO),
dataset/ETHPy150Open adblockplus/gyp/pylib/gyp/xcode_emulation.py/_NormalizeEnvVarReferences