refactor: simplify registry reads with setuphelpers
This commit is contained in:
1 parent
86224e8840
commit
ca21b0fb3a
1 file changed
+4
-3
@@ -63,10 +63,11 @@ def _read_value(path, name):
|
|||||||
subkey = _registry_path(path)
|
subkey = _registry_path(path)
|
||||||
if not reg_key_exists(HKEY_LOCAL_MACHINE, subkey):
|
if not reg_key_exists(HKEY_LOCAL_MACHINE, subkey):
|
||||||
return {'Exists': False, 'Value': None}
|
return {'Exists': False, 'Value': None}
|
||||||
if not reg_value_exists(HKEY_LOCAL_MACHINE, subkey, name):
|
missing = object()
|
||||||
return {'Exists': False, 'Value': None}
|
|
||||||
with reg_openkey_noredir(HKEY_LOCAL_MACHINE, subkey) as key:
|
with reg_openkey_noredir(HKEY_LOCAL_MACHINE, subkey) as key:
|
||||||
value = reg_getvalue(key, name)
|
value = reg_getvalue(key, name, default=missing)
|
||||||
|
if value is missing:
|
||||||
|
return {'Exists': False, 'Value': None}
|
||||||
if value is None:
|
if value is None:
|
||||||
raise RuntimeError('Registry value disappeared while it was being read: %s' % name)
|
raise RuntimeError('Registry value disappeared while it was being read: %s' % name)
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in new issue
Block a user