--- a/eric7/Utilities/__init__.py Mon May 23 16:50:04 2022 +0200 +++ b/eric7/Utilities/__init__.py Mon May 23 16:50:39 2022 +0200 @@ -1323,6 +1323,86 @@ ] +def getCoverageFileNames(fn): + """ + Function to build a list of coverage data file names. + + @param fn file name basis to be used for the coverage data file + @type str + @return list of existing coverage data files + @rtype list of str + """ + files = [] + for filename in [fn, os.path.dirname(fn) + os.sep] + getTestFileNames(fn): + f = getCoverageFileName(filename) + if f: + files.append(f) + return files + + +def getCoverageFileName(fn, mustExist=True): + """ + Function to build a file name for a coverage data file. + + @param fn file name basis to be used for the coverage data file name + @type str + @param mustExist flag indicating to check that the file exists (defaults + to True) + @type bool (optional) + @return coverage data file name + @rtype str + """ + basename = os.path.splitext(fn)[0] + filename = "{0}.coverage".format(basename) + if mustExist: + if os.path.isfile(filename): + return filename + else: + return "" + else: + return filename + + +def getProfileFileNames(fn): + """ + Function to build a list of profile data file names. + + @param fn file name basis to be used for the profile data file + @type str + @return list of existing profile data files + @rtype list of str + """ + files = [] + for filename in [fn, os.path.dirname(fn) + os.sep] + getTestFileNames(fn): + f = getProfileFileName(filename) + if f: + files.append(f) + return files + + +def getProfileFileName(fn, mustExist=True): + """ + Function to build a file name for a profile data file. + + @param fn file name basis to be used for the profile data file name + @type str + @param mustExist flag indicating to check that the file exists (defaults + to True) + @type bool (optional) + @return profile data file name + @rtype str + """ + basename = os.path.splitext(fn)[0] + filename = "{0}.profile".format(basename) + if mustExist: + if os.path.isfile(filename): + return filename + else: + return "" + else: + return filename + + def parseOptionString(s): """ Function used to convert an option string into a list of options.