--- a/eric6/Project/Project.py Fri Apr 02 11:59:41 2021 +0200 +++ b/eric6/Project/Project.py Sat May 01 14:27:20 2021 +0200 @@ -14,6 +14,7 @@ import fnmatch import copy import zipfile +import contextlib from PyQt5.QtCore import ( pyqtSlot, QFile, QFileInfo, pyqtSignal, QCryptographicHash, QIODevice, @@ -168,7 +169,7 @@ @param parent parent widget (usually the ui object) (QWidget) @param filename optional filename of a project file to open (string) """ - super(Project, self).__init__(parent) + super().__init__(parent) self.ui = parent @@ -237,15 +238,14 @@ if ext not in extensions: extensions.append(ext) return extensions - elif language == "Ruby": - return ['.rb'] - elif language == "JavaScript": - return ['.js'] - elif language == "Mixed": - return (Preferences.getPython("Python3Extensions") + - ['.rb', '.js']) else: - return [""] + return { + "Ruby": [".rb"], + "JavaScript": [".js"], + "Mixed": ( + Preferences.getPython("Python3Extensions") + + ['.rb', '.js']), + }.get(language, "") def getProgrammingLanguages(self): """ @@ -607,10 +607,11 @@ } # Sources - if self.pdata["MIXEDLANGUAGE"]: - sourceKey = "Mixed" - else: - sourceKey = self.pdata["PROGLANGUAGE"] + sourceKey = ( + "Mixed" + if self.pdata["MIXEDLANGUAGE"] else + self.pdata["PROGLANGUAGE"] + ) for ext in self.__sourceExtensions(sourceKey): self.pdata["FILETYPES"]["*{0}".format(ext)] = "SOURCES" @@ -645,13 +646,11 @@ self.pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" # Project type specific ones - try: + with contextlib.suppress(KeyError): if self.__fileTypeCallbacks[ self.pdata["PROJECTTYPE"]] is not None: ftypes = self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"]]() self.pdata["FILETYPES"].update(ftypes) - except KeyError: - pass self.setDirty(True) @@ -669,7 +668,7 @@ self.pdata["FILETYPES"]["*.ts"] = "TRANSLATIONS" if "*.qm" not in self.pdata["FILETYPES"]: self.pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" - try: + with contextlib.suppress(KeyError): if self.__fileTypeCallbacks[ self.pdata["PROJECTTYPE"]] is not None: ftypes = self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"]]() @@ -677,8 +676,6 @@ if pattern not in self.pdata["FILETYPES"]: self.pdata["FILETYPES"][pattern] = ftype self.setDirty(True) - except KeyError: - pass def __loadRecent(self): """ @@ -1492,15 +1489,13 @@ self.pdata["TRANSLATIONS"].remove(langFile) self.__model.removeItem(langFile) if qmFile: - try: + with contextlib.suppress(ValueError): if self.pdata["TRANSLATIONSBINPATH"]: qmFile = self.getRelativePath( os.path.join(self.pdata["TRANSLATIONSBINPATH"], os.path.basename(qmFile))) self.pdata["TRANSLATIONS"].remove(qmFile) self.__model.removeItem(qmFile) - except ValueError: - pass self.setDirty(True) def deleteLanguageFile(self, langFile): @@ -1510,7 +1505,7 @@ @param langFile the translation file to be removed (string) """ try: - from ThirdParty.Send2Trash.send2trash import send2trash as s2t + from send2trash import send2trash as s2t except ImportError: s2t = os.remove @@ -1565,12 +1560,9 @@ """ dirty = False - if os.path.isabs(fn): - # make it relative to the project root, if it starts with that path - newfn = self.getRelativePath(fn) - else: - # assume relative paths are relative to the project root - newfn = fn + # make it relative to the project root, if it starts with that path + # assume relative paths are relative to the project root + newfn = self.getRelativePath(fn) if os.path.isabs(fn) else fn newdir = os.path.dirname(newfn) if isSourceFile: @@ -2218,10 +2210,7 @@ if entry.startswith(dn): self.pdata["OTHERS"].remove(entry) dirty = True - if not dn.endswith(os.sep): - dn2 = dn + os.sep - else: - dn2 = dn + dn2 = dn if dn.endswith(os.sep) else dn + os.sep for key in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES", "TRANSLATIONS", ]: for entry in self.pdata[key][:]: @@ -2241,7 +2230,7 @@ @return flag indicating success (boolean) """ try: - from ThirdParty.Send2Trash.send2trash import send2trash as s2t + from send2trash import send2trash as s2t except ImportError: s2t = os.remove @@ -2288,7 +2277,7 @@ dn = os.path.join(self.ppath, dn) try: try: - from ThirdParty.Send2Trash.send2trash import send2trash + from send2trash import send2trash send2trash(dn) except ImportError: shutil.rmtree(dn, True) @@ -2312,17 +2301,14 @@ @return flag indicating, if the project contains the file (boolean) """ fn = self.getRelativePath(fn) - if ( + return ( fn in self.pdata["SOURCES"] or fn in self.pdata["FORMS"] or fn in self.pdata["INTERFACES"] or fn in self.pdata["PROTOCOLS"] or fn in self.pdata["RESOURCES"] or fn in self.pdata["OTHERS"] - ): - return True - else: - return False + ) def createNewProject(self): """ @@ -2930,11 +2916,9 @@ # try project type specific defaults next projectType = self.pdata["PROJECTTYPE"] - try: + with contextlib.suppress(KeyError): if self.__lexerAssociationCallbacks[projectType] is not None: return self.__lexerAssociationCallbacks[projectType](filename) - except KeyError: - pass # return empty string to signal to use the global setting return "" @@ -2963,154 +2947,153 @@ QApplication.processEvents() - if fn: - if self.closeProject(): + if fn and self.closeProject(): + with E5OverrideCursor(): + ok = self.__readProject(fn) + if ok: + self.opened = True + if not self.pdata["FILETYPES"]: + self.initFileTypes() + else: + self.updateFileTypes() + + try: + # create management directory if not present + self.createProjectManagementDir() + except OSError: + E5MessageBox.critical( + self.ui, + self.tr("Create project management directory"), + self.tr( + "<p>The project directory <b>{0}</b> is not" + " writable.</p>") + .format(self.ppath)) + return + + # read a user specific project file + self.__readUserProperties() + with E5OverrideCursor(): - ok = self.__readProject(fn) - if ok: - self.opened = True - if not self.pdata["FILETYPES"]: - self.initFileTypes() - else: - self.updateFileTypes() - - try: - # create management directory if not present - self.createProjectManagementDir() - except OSError: - E5MessageBox.critical( - self.ui, - self.tr("Create project management directory"), - self.tr( - "<p>The project directory <b>{0}</b> is not" - " writable.</p>") - .format(self.ppath)) - return - - # read a user specific project file - self.__readUserProperties() - - with E5OverrideCursor(): - oldState = self.isDirty() - self.vcs = self.initVCS() - if self.vcs is None and self.isDirty() == oldState: - # check, if project is version controlled - pluginManager = e5App().getObject("PluginManager") - for indicator, vcsData in ( - pluginManager.getVcsSystemIndicators().items() - ): - if os.path.exists( - os.path.join(self.ppath, indicator)): - if len(vcsData) > 1: - vcsList = [] + oldState = self.isDirty() + self.vcs = self.initVCS() + if self.vcs is None and self.isDirty() == oldState: + # check, if project is version controlled + pluginManager = e5App().getObject("PluginManager") + for indicator, vcsData in ( + pluginManager.getVcsSystemIndicators().items() + ): + if os.path.exists( + os.path.join(self.ppath, indicator)): + if len(vcsData) > 1: + vcsList = [] + for ( + _vcsSystemStr, vcsSystemDisplay + ) in vcsData: + vcsList.append(vcsSystemDisplay) + with E5OverridenCursor(): + res, vcs_ok = QInputDialog.getItem( + None, + self.tr("New Project"), + self.tr( + "Select Version Control" + " System"), + vcsList, + 0, False) + if vcs_ok: for ( - _vcsSystemStr, vcsSystemDisplay + vcsSystemStr, vcsSystemDisplay ) in vcsData: - vcsList.append(vcsSystemDisplay) - with E5OverridenCursor(): - res, vcs_ok = QInputDialog.getItem( - None, - self.tr("New Project"), - self.tr( - "Select Version Control" - " System"), - vcsList, - 0, False) - if vcs_ok: - for ( - vcsSystemStr, vcsSystemDisplay - ) in vcsData: - if res == vcsSystemDisplay: - vcsSystem = vcsSystemStr - break - else: - vcsSystem = "None" + if res == vcsSystemDisplay: + vcsSystem = vcsSystemStr + break else: vcsSystem = "None" else: - vcsSystem = vcsData[0][0] - self.pdata["VCS"] = vcsSystem - self.vcs = self.initVCS() - self.setDirty(True) - if ( - self.vcs is not None and - (self.vcs.vcsRegisteredState(self.ppath) != - self.vcs.canBeCommitted) - ): - self.pdata["VCS"] = 'None' - self.vcs = self.initVCS() - self.closeAct.setEnabled(True) - self.saveasAct.setEnabled(True) - self.actGrp2.setEnabled(True) - self.propsAct.setEnabled(True) - self.userPropsAct.setEnabled(True) - self.filetypesAct.setEnabled(True) - self.lexersAct.setEnabled(True) - self.sessActGrp.setEnabled(True) - self.dbgActGrp.setEnabled(True) - self.menuDebuggerAct.setEnabled(True) - self.menuSessionAct.setEnabled(True) - self.menuCheckAct.setEnabled(True) - self.menuShowAct.setEnabled(True) - self.menuDiagramAct.setEnabled(True) - self.menuApidocAct.setEnabled(True) - self.menuPackagersAct.setEnabled(True) - self.pluginGrp.setEnabled( - self.pdata["PROJECTTYPE"] in ["E6Plugin"]) - self.addLanguageAct.setEnabled( - bool(self.pdata["TRANSLATIONPATTERN"])) - self.makeGrp.setEnabled( - self.pdata["MAKEPARAMS"]["MakeEnabled"]) - self.menuMakeAct.setEnabled( - self.pdata["MAKEPARAMS"]["MakeEnabled"]) - - # open a project debugger properties file being quiet - # about errors - if Preferences.getProject("AutoLoadDbgProperties"): - self.__readDebugProperties(True) - - self.__model.projectOpened() - self.projectOpenedHooks.emit() - self.projectOpened.emit() + vcsSystem = "None" + else: + vcsSystem = vcsData[0][0] + self.pdata["VCS"] = vcsSystem + self.vcs = self.initVCS() + self.setDirty(True) + if ( + self.vcs is not None and + (self.vcs.vcsRegisteredState(self.ppath) != + self.vcs.canBeCommitted) + ): + self.pdata["VCS"] = 'None' + self.vcs = self.initVCS() + self.closeAct.setEnabled(True) + self.saveasAct.setEnabled(True) + self.actGrp2.setEnabled(True) + self.propsAct.setEnabled(True) + self.userPropsAct.setEnabled(True) + self.filetypesAct.setEnabled(True) + self.lexersAct.setEnabled(True) + self.sessActGrp.setEnabled(True) + self.dbgActGrp.setEnabled(True) + self.menuDebuggerAct.setEnabled(True) + self.menuSessionAct.setEnabled(True) + self.menuCheckAct.setEnabled(True) + self.menuShowAct.setEnabled(True) + self.menuDiagramAct.setEnabled(True) + self.menuApidocAct.setEnabled(True) + self.menuPackagersAct.setEnabled(True) + self.pluginGrp.setEnabled( + self.pdata["PROJECTTYPE"] in ["E6Plugin"]) + self.addLanguageAct.setEnabled( + bool(self.pdata["TRANSLATIONPATTERN"])) + self.makeGrp.setEnabled( + self.pdata["MAKEPARAMS"]["MakeEnabled"]) + self.menuMakeAct.setEnabled( + self.pdata["MAKEPARAMS"]["MakeEnabled"]) + + # open a project debugger properties file being quiet + # about errors + if Preferences.getProject("AutoLoadDbgProperties"): + self.__readDebugProperties(True) - if Preferences.getProject("SearchNewFiles"): - self.__doSearchNewFiles() - - # read a project tasks file - self.__readTasks() - self.ui.taskViewer.setProjectOpen(True) - # rescan project tasks - if Preferences.getProject("TasksProjectRescanOnOpen"): - e5App().getObject("TaskViewer" - ).regenerateProjectTasks(quiet=True) + self.__model.projectOpened() + self.projectOpenedHooks.emit() + self.projectOpened.emit() + + if Preferences.getProject("SearchNewFiles"): + self.__doSearchNewFiles() + + # read a project tasks file + self.__readTasks() + self.ui.taskViewer.setProjectOpen(True) + # rescan project tasks + if Preferences.getProject("TasksProjectRescanOnOpen"): + e5App().getObject("TaskViewer" + ).regenerateProjectTasks(quiet=True) + + if restoreSession: + # open the main script + if self.pdata["MAINSCRIPT"]: + if not os.path.isabs(self.pdata["MAINSCRIPT"]): + ms = os.path.join( + self.ppath, self.pdata["MAINSCRIPT"]) + else: + ms = self.pdata["MAINSCRIPT"] + self.sourceFile.emit(ms) - if restoreSession: - # open the main script - if self.pdata["MAINSCRIPT"]: - if not os.path.isabs(self.pdata["MAINSCRIPT"]): - ms = os.path.join( - self.ppath, self.pdata["MAINSCRIPT"]) - else: - ms = self.pdata["MAINSCRIPT"] - self.sourceFile.emit(ms) - - # open a project session file being quiet about errors - if reopen: - self.__readSession(quiet=True, indicator="_tmp") - elif Preferences.getProject("AutoLoadSession"): - self.__readSession(quiet=True) - - # start the VCS monitor thread - if self.vcs is not None: - self.vcs.startStatusMonitor(self) - self.vcs.vcsStatusMonitorData.connect( - self.__model.changeVCSStates) - self.vcs.vcsStatusMonitorStatus.connect( - self.__statusMonitorStatus) - self.vcs.vcsStatusMonitorInfo.connect( - self.vcsStatusMonitorInfo) - self.vcs.vcsStatusChanged.connect( - self.__vcsStatusChanged) + # open a project session file being quiet about errors + if reopen: + self.__readSession(quiet=True, indicator="_tmp") + elif Preferences.getProject("AutoLoadSession"): + self.__readSession(quiet=True) + + # start the VCS monitor thread + if self.vcs is not None: + self.vcs.startStatusMonitor(self) + self.vcs.vcsStatusMonitorData.connect( + self.__model.changeVCSStates) + self.vcs.vcsStatusMonitorStatus.connect( + self.__statusMonitorStatus) + self.vcs.vcsStatusMonitorInfo.connect( + self.vcsStatusMonitorInfo) + self.vcs.vcsStatusChanged.connect( + self.__vcsStatusChanged) def reopenProject(self): """ @@ -3148,13 +3131,12 @@ @return flag indicating success (boolean) """ defaultFilter = self.tr("Project Files (*.epj)") - if self.ppath: - defaultPath = self.ppath - else: - defaultPath = ( - Preferences.getMultiProject("Workspace") or - Utilities.getHomeDir() - ) + defaultPath = ( + self.ppath + if self.ppath else + (Preferences.getMultiProject("Workspace") or + Utilities.getHomeDir()) + ) fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( self.parent(), self.tr("Save project as"), @@ -3544,9 +3526,7 @@ @return default extension (including the dot) (string) """ lang = self.pdata["PROGLANGUAGE"] - if lang == "": - lang = "Python3" - elif lang == "Python": + if lang in ("", "Python"): lang = "Python3" return self.__sourceExtensions(lang)[0] @@ -3562,24 +3542,20 @@ """ Public method to check, if a path starts with the project path. - @param path path to be checked (string) + @param path path to be checked + @type str @return flag indicating that the path starts with the project path - (boolean) - """ - if self.ppath: - if path == self.ppath: - return True - elif ( - Utilities.normcasepath(Utilities.toNativeSeparators(path)) - .startswith(Utilities.normcasepath( - Utilities.toNativeSeparators(self.ppath + "/"))) - ): - return True - else: - return False - else: - return False - + @rtype bool + """ + return ( + bool(self.ppath) and + (path == self.ppath or + Utilities.normcasepath(Utilities.toNativeSeparators(path)) + .startswith(Utilities.normcasepath( + Utilities.toNativeSeparators(self.ppath + "/"))) + ) + ) + def getProjectFile(self): """ Public method to get the path of the project file. @@ -3769,11 +3745,13 @@ """ newfn = os.path.abspath(fn) newfn = self.getRelativePath(newfn) - for group in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", - "RESOURCES", "TRANSLATIONS", "OTHERS"]: - if newfn in self.pdata[group]: - return True - return False + return any( + newfn in self.pdata[group] + for group in [ + "SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES", + "TRANSLATIONS", "OTHERS" + ] + ) def isProjectFile(self, fn): """ @@ -3783,12 +3761,13 @@ @param fn filename to be checked (string) @return flag indicating membership (boolean) """ - for group in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", - "RESOURCES", "TRANSLATIONS", "OTHERS"]: - if self.__checkProjectFileGroup(fn, group): - return True - - return False + return any( + self.__checkProjectFileGroup(fn, group) + for group in [ + "SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES", + "TRANSLATIONS", "OTHERS" + ] + ) def __checkProjectFileGroup(self, fn, group): """ @@ -3801,23 +3780,24 @@ """ newfn = os.path.abspath(fn) newfn = self.getRelativePath(newfn) - if newfn in self.pdata[group]: + if ( + newfn in self.pdata[group] or + (group == "OTHERS" and + any(newfn.startswith(entry) for entry in self.pdata[group])) + ): return True - elif group == "OTHERS": - for entry in self.pdata[group]: - if newfn.startswith(entry): - return True if Utilities.isWindowsPlatform(): # try the above case-insensitive newfn = newfn.lower() - for entry in self.pdata[group]: - if entry.lower() == newfn: - return True - elif group == "OTHERS": - for entry in self.pdata[group]: - if newfn.startswith(entry.lower()): - return True + if any(entry.lower() == newfn for entry in self.pdata[group]): + return True + elif ( + group == "OTHERS" and + any(newfn.startswith(entry.lower()) + for entry in self.pdata[group]) + ): + return True return False @@ -4566,19 +4546,14 @@ self.recentMenu.clear() - idx = 1 - for rp in self.recent: - if idx < 10: - formatStr = '&{0:d}. {1}' - else: - formatStr = '{0:d}. {1}' + for idx, rp in enumerate(self.recent, start=1): + formatStr = '&{0:d}. {1}' if idx < 10 else '{0:d}. {1}' act = self.recentMenu.addAction( formatStr.format( idx, Utilities.compactPath(rp, self.ui.maxMenuFilePathLen))) act.setData(rp) act.setEnabled(QFileInfo(rp).exists()) - idx += 1 self.recentMenu.addSeparator() self.recentMenu.addAction(self.tr('&Clear'), self.clearRecent) @@ -4671,13 +4646,11 @@ newSources = os.listdir(curpath) except OSError: newSources = [] - if self.pdata["TRANSLATIONPATTERN"]: - pattern = ( - self.pdata["TRANSLATIONPATTERN"] - .replace("%language%", "*") - ) - else: - pattern = "*.ts" + pattern = ( + self.pdata["TRANSLATIONPATTERN"].replace("%language%", "*") + if self.pdata["TRANSLATIONPATTERN"] else + "*.ts" + ) binpattern = self.__binaryTranslationFile(pattern) for ns in newSources: # ignore hidden files and directories @@ -4694,10 +4667,7 @@ # set fn to project relative name # then reset ns to fully qualified name for insertion, # possibly. - if directory == "": - fn = ns - else: - fn = os.path.join(directory, ns) + fn = os.path.join(directory, ns) if directory else ns ns = os.path.abspath(os.path.join(curpath, ns)) # do not bother with dirs here... @@ -4728,24 +4698,16 @@ (filetype == "RESOURCES" and fn not in self.pdata["RESOURCES"]) or (filetype == "OTHERS" and - fn not in self.pdata["OTHERS"]) + fn not in self.pdata["OTHERS"]) or + (filetype == "TRANSLATIONS" and + fn not in self.pdata["TRANSLATIONS"] and + (fnmatch.fnmatch(ns, pattern) or + fnmatch.fnmatch(ns, binpattern))) ): if autoInclude and AI: self.appendFile(ns) else: newFiles.append(ns) - elif ( - filetype == "TRANSLATIONS" and - fn not in self.pdata["TRANSLATIONS"] - ): - if ( - fnmatch.fnmatch(ns, pattern) or - fnmatch.fnmatch(ns, binpattern) - ): - if autoInclude and AI: - self.appendFile(ns) - else: - newFiles.append(ns) # if autoInclude is set there is no more work left if (autoInclude and AI): @@ -4811,10 +4773,8 @@ @param actions list of actions (list of E5Action) """ for act in actions: - try: + with contextlib.suppress(ValueError): self.actions.remove(act) - except ValueError: - pass def getMenu(self, menuName): """ @@ -4866,13 +4826,15 @@ else: forProject = False - if forProject and self.pdata["VCS"] and self.pdata["VCS"] != 'None': - if ( - self.pudata["VCSOVERRIDE"] and - not nooverride - ): - vcsSystem = self.pudata["VCSOVERRIDE"] - override = True + if ( + forProject and + self.pdata["VCS"] and + self.pdata["VCS"] != 'None' and + self.pudata["VCSOVERRIDE"] and + not nooverride + ): + vcsSystem = self.pudata["VCSOVERRIDE"] + override = True if vcsSystem is not None: import VCS @@ -4919,17 +4881,13 @@ if vcs and forProject: # set the vcs options if vcs.vcsSupportCommandOptions(): - try: + with contextlib.suppress(LookupError): vcsopt = copy.deepcopy(self.pdata["VCSOPTIONS"]) vcs.vcsSetOptions(vcsopt) - except LookupError: - pass # set vcs specific data - try: + with contextlib.suppress(LookupError): vcsother = copy.deepcopy(self.pdata["VCSOTHERDATA"]) vcs.vcsSetOtherData(vcsother) - except LookupError: - pass if forProject: if vcs is None: @@ -5341,10 +5299,7 @@ # write the file try: - if self.pdata["EOL"] == 0: - newline = None - else: - newline = self.getEolString() + newline = None if self.pdata["EOL"] == 0 else self.getEolString() with open(pkglist, "w", encoding="utf-8", newline=newline) as pkglistFile: pkglistFile.write("\n".join(header) + "\n") @@ -5410,9 +5365,8 @@ 0, len(selectedLists), self.tr("%v/%m Archives")) progress.setMinimumDuration(0) progress.setWindowTitle(self.tr("Create Plugin Archives")) - count = 0 errors = 0 - for pkglist in selectedLists: + for count, pkglist in enumerate(selectedLists): progress.setValue(count) if progress.wasCanceled(): break @@ -5429,7 +5383,6 @@ """<p>Reason: {1}</p>""").format( os.path.basename(pkglist), str(why))) errors += 1 - count += 1 continue lines = names.splitlines() @@ -5458,7 +5411,6 @@ """'; initial_list' line of the header.""" """</p>""").format(os.path.basename(pkglist))) errors += 1 - count += 1 listOK = False break elif line.strip(): @@ -5468,12 +5420,12 @@ continue names = sorted(names) - if archiveName: - archive = os.path.join(self.ppath, archiveName) - else: - archive = os.path.join( - self.ppath, - self.pdata["MAINSCRIPT"].replace(".py", ".zip")) + archive = ( + os.path.join(self.ppath, archiveName) + if archiveName else + os.path.join(self.ppath, + self.pdata["MAINSCRIPT"].replace(".py", ".zip")) + ) try: archiveFile = zipfile.ZipFile(archive, "w") except OSError as why: @@ -5485,7 +5437,6 @@ """ could not be created.</p>""" """<p>Reason: {1}</p>""").format(archive, str(why))) errors += 1 - count += 1 continue for name in names: @@ -5526,8 +5477,6 @@ if archive not in self.pdata["OTHERS"]: self.appendFile(archive) - - count += 1 progress.setValue(len(selectedLists)) @@ -5537,7 +5486,7 @@ self.tr("Create Plugin Archive"), self.tr("<p>The eric plugin archive files were " "created with some errors.</p>"), - kind=NotificationTypes.Critical, + kind=NotificationTypes.CRITICAL, timeout=0) else: self.ui.showNotification( @@ -5559,7 +5508,7 @@ @param path name of the directory entry to create (string) @param zipFile open ZipFile object (zipfile.ZipFile) """ - if path == "" or path == "/" or path == "\\": + if path in ("", "/", "\\"): return if not path.endswith("/") and not path.endswith("\\"): @@ -5707,10 +5656,11 @@ ): return - if self.pdata["MAKEPARAMS"]["MakeExecutable"]: - prog = self.pdata["MAKEPARAMS"]["MakeExecutable"] - else: - prog = Project.DefaultMake + prog = ( + self.pdata["MAKEPARAMS"]["MakeExecutable"] + if self.pdata["MAKEPARAMS"]["MakeExecutable"] else + Project.DefaultMake + ) args = [] if self.pdata["MAKEPARAMS"]["MakeParameters"]: @@ -5807,7 +5757,7 @@ UI.PixmapCache.getPixmap("makefile48"), title, message, - kind=NotificationTypes.Warning, + kind=NotificationTypes.WARNING, timeout=0) elif exitCode > 1: E5MessageBox.critical(