def __contains__(self, path): hive, subpath = self._parse_path(path) try: with win32.RegOpenKey(hive, subpath): return True except WindowsError, e: if e.winerror == win32.ERROR_FILE_NOT_FOUND: return False raise
def __getitem__(self, path): path = self._sanitize_path(path) hive, subpath = self._parse_path(path) try: handle = win32.RegOpenKey(hive, subpath) except WindowsError, e: if e.winerror == win32.ERROR_FILE_NOT_FOUND: raise KeyError(path) raise
def child(self, subkey): """ Retrieves a subkey for this Registry key, given its name. @type subkey: str @param subkey: Name of the subkey. @rtype: L{RegistryKey} @return: Subkey. """ path = self._path + '\\' + subkey handle = win32.RegOpenKey(self.handle, subkey) return RegistryKey(path, handle)
def subkeys(self, path): """ Returns a list of subkeys for the given Registry key. @type path: str @param path: Registry key path. @rtype: list(str) @return: List of subkey names. """ result = list() hive, subpath = self._parse_path(path) with win32.RegOpenKey(hive, subpath) as handle: index = 0 while 1: name = win32.RegEnumKey(handle, index) if name is None: break result.append(name) index += 1 return result