(self, strict=True)
Load the MIME types database from Windows registry.

        If strict is true, information will be added to
        list of standard types, else to the list of non-standard
        types.
Load the MIME types database from Windows registry.
Load the MIME types database from Windows registry .
def read_windows_registry(self, strict=True):
        """
        Load the MIME types database from Windows registry.

        If strict is true, information will be added to
        list of standard types, else to the list of non-standard
        types.
        """

        # Windows only
        if not _winreg:
            return

        def enum_types(mimedb):
            i = 0
            while True:
                try:
                    ctype = _winreg.EnumKey(mimedb, i)
                except EnvironmentError:
                    break
                try:
                    ctype = ctype.encode(default_encoding) # omit in 3.x!
                except UnicodeEncodeError:
                    pass
                else:
                    yield ctype
                i += 1

        default_encoding = sys.getdefaultencoding()
        with _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT,
                             r'MIME\Database\Content Type') as mimedb:
            for ctype in enum_types(mimedb):
                try:
                    with _winreg.OpenKey(mimedb, ctype) as key:
                        suffix, datatype = _winreg.QueryValueEx(key,
                                                                'Extension')
                except EnvironmentError:
                    continue
                if datatype != _winreg.REG_SZ:
                    continue
                try:
                    suffix = suffix.encode(default_encoding) # omit in 3.x!
                except UnicodeEncodeError:
                    continue
                self.add_type(ctype, suffix, strict)
def read_windows_registry ( self , strict = True ) : # Windows only if not _winreg : return def enum_types ( mimedb ) : i = 0 while True : try : ctype = _winreg . EnumKey ( mimedb , i ) except EnvironmentError : break try : ctype = ctype . encode ( default_encoding ) # omit in 3.x! except UnicodeEncodeError : pass else : yield ctype i += 1 default_encoding = sys . getdefaultencoding ( ) with _winreg . OpenKey ( _winreg . HKEY_CLASSES_ROOT , r'MIME\Database\Content Type' ) as mimedb : for ctype in enum_types ( mimedb ) : try : with _winreg . OpenKey ( mimedb , ctype ) as key : suffix , datatype = _winreg . QueryValueEx ( key , 'Extension' ) except EnvironmentError : continue if datatype != _winreg . REG_SZ : continue try : suffix = suffix . encode ( default_encoding ) # omit in 3.x! except UnicodeEncodeError : continue self . add_type ( ctype , suffix , strict )