refactor: simplify registry reads with setuphelpers

This commit is contained in:
PierreCsn committed 2026-10-30 11:33:39 +01:00
1 parent 86224e8840
commit ca21b0fb3a
1 file changed
+4 -3
+4 -3
View File
@@ -63,10 +63,11 @@ def _read_value(path, name):
subkey = _registry_path(path)
if not reg_key_exists(HKEY_LOCAL_MACHINE, subkey):
return {'Exists': False, 'Value': None}
if not reg_value_exists(HKEY_LOCAL_MACHINE, subkey, name):
return {'Exists': False, 'Value': None}
missing = object()
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:
raise RuntimeError('Registry value disappeared while it was being read: %s' % name)
try: