Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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