MCPcopy Index your code
hub / github.com/nodejs/node / _NormalizeEnvVarReferences

Function _NormalizeEnvVarReferences

tools/gyp/pylib/gyp/xcode_emulation.py:1817–1831  ·  view source on GitHub ↗

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}.

(str)

Source from the content-addressed store, hash-verified

1815
1816
1817def _NormalizeEnvVarReferences(str):
1818 """Takes a string containing variable references in the form ${FOO}, $(FOO),
1819 or $FOO, and returns a string with all variable references in the form ${FOO}.
1820 """
1821 # $FOO -> ${FOO}
1822 str = re.sub(r"\$([a-zA-Z_][a-zA-Z0-9_]*)", r"${\1}", str)
1823
1824 # $(FOO) -> ${FOO}
1825 matches = re.findall(r"(\$\(([a-zA-Z0-9\-_]+)\))", str)
1826 for match in matches:
1827 to_replace, variable = match
1828 assert "$(" not in match, "$($(FOO)) variables not supported: " + match
1829 str = str.replace(to_replace, "${" + variable + "}")
1830
1831 return str
1832
1833
1834def ExpandEnvVars(string, expansions):

Callers 2

_GetStripPostbuildsMethod · 0.85
_GetXcodeEnvFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected