Sun, 04 Dec 2022 11:58:37 +0100
Project Viewer
- removed the CORBA and Protobuf viewers to make them available as plugins
# -*- coding: utf-8 -*- # Copyright (c) 2014 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing mimetype dependent functions. """ import mimetypes from eric7 import Preferences def isTextFile(filename): """ Function to test, if the given file is a text (i.e. editable) file. @param filename name of the file to be checked @type str @return flag indicating an editable file @rtype bool """ mimetype = mimetypes.guess_type(filename)[0] # TODO: add a dialog to ask if the file is a text file in case mimetype is None # and option is not set # TODO: add capability to define additional text file patterns for fnmatch test return (mimetype is None and Preferences.getUI("LoadUnknownMimeTypeFiles")) or ( mimetype is not None and ( mimetype.split("/")[0] == "text" or mimetype in Preferences.getUI("TextMimeTypes") ) ) def mimeType(filename): """ Function to get the mime type of a file. @param filename name of the file to be checked @type str @return mime type of the file @rtype str """ return mimetypes.guess_type(filename)[0]