MCPcopy Create free account
hub / github.com/nodejs/node / _RegistryGetValue

Function _RegistryGetValue

tools/gyp/pylib/gyp/MSVSVersion.py:241–268  ·  view source on GitHub ↗

Use _winreg or reg.exe to obtain the value of a registry key. Using _winreg is preferable because it solves an issue on some corporate environments where access to reg.exe is locked down. However, we still need to fallback to reg.exe for the case where the _winreg module is not availabl

(key, value)

Source from the content-addressed store, hash-verified

239
240
241def _RegistryGetValue(key, value):
242 """Use _winreg or reg.exe to obtain the value of a registry key.
243
244 Using _winreg is preferable because it solves an issue on some corporate
245 environments where access to reg.exe is locked down. However, we still need
246 to fallback to reg.exe for the case where the _winreg module is not available
247 (for example in cygwin python).
248
249 Args:
250 key: The registry key.
251 value: The particular registry value to read.
252 Return:
253 contents of the registry key's value, or None on failure.
254 """
255 try:
256 return _RegistryGetValueUsingWinReg(key, value)
257 except ImportError:
258 pass
259
260 # Fallback to reg.exe if we fail to import _winreg.
261 text = _RegistryQuery(key, value)
262 if not text:
263 return None
264 # Extract value.
265 match = re.search(r"REG_\w+\s+([^\r]+)\r\n", text)
266 if not match:
267 return None
268 return match.group(1)
269
270
271def _CreateVersion(name, path, sdk_based=False):

Callers 1

Calls 3

_RegistryQueryFunction · 0.85
searchMethod · 0.45

Tested by

no test coverage detected