-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Description
Hi,
When requesting a (sub)key, Registry raises an exception if this key is not found. The same for values. Since actually the easiest way to check if a key exists (implicitly) to call key.subkey() and then the absence of the subkey is not really an exception in that sense.
Would you consider replacing the exception-raising with returning None? or maybe add functions with that return None instead of raise exception.
Like this:
def subkey(self, name):
"""
Return the subkey with a given name as a RegistryKey.
Return None if the subkey with the given name does not exist.
"""
if self._nkrecord.subkey_number() == 0:
return None
for k in self._nkrecord.subkey_list().keys():
if k.name().lower() == name.lower():
return RegistryKey(k)
return NoneMetadata
Metadata
Assignees
Labels
No labels