Thu, 22 Apr 2021 18:02:47 +0200
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
--- a/eric6/QScintilla/Lexers/LexerPython.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/QScintilla/Lexers/LexerPython.py Thu Apr 22 18:02:47 2021 +0200 @@ -186,7 +186,7 @@ if (lead_spaces % indent_width != 0 or lead_spaces == 0 or self.lastIndented != line) else - -indent_width + -indent_width # __IGNORE_WARNING_W503__ ) return indentDifference
--- a/eric6/QScintilla/MiniEditor.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/QScintilla/MiniEditor.py Thu Apr 22 18:02:47 2021 +0200 @@ -2748,10 +2748,11 @@ """ self.__curFile = fileName - if not self.__curFile: - shownName = self.tr("Untitled") - else: - shownName = self.__strippedName(self.__curFile) + shownName = ( + self.tr("Untitled") + if not self.__curFile else + self.__strippedName(self.__curFile) + ) self.setWindowTitle(self.tr("{0}[*] - {1}") .format(shownName, self.tr("Mini Editor"))) @@ -3395,10 +3396,11 @@ self.__textEdit.SCN_STYLENEEDED.connect(self.__styleNeeded) # get the font for style 0 and set it as the default font - if pyname and pyname.startswith("Pygments|"): - key = 'Scintilla/Guessed/style0/font' - else: - key = 'Scintilla/{0}/style0/font'.format(self.lexer_.language()) + key = ( + 'Scintilla/Guessed/style0/font' + if pyname and pyname.startswith("Pygments|") else + 'Scintilla/{0}/style0/font'.format(self.lexer_.language()) + ) fdesc = Preferences.Prefs.settings.value(key) if fdesc is not None: font = QFont(fdesc[0], int(fdesc[1])) @@ -3545,10 +3547,11 @@ else: wc = re.sub(r'\w', "", wc) pattern = r"\b[\w{0}]+\b".format(re.escape(wc)) - if self.__textEdit.caseSensitive(): - rx = re.compile(pattern) - else: - rx = re.compile(pattern, re.IGNORECASE) + rx = ( + re.compile(pattern) + if self.__textEdit.caseSensitive() else + re.compile(pattern, re.IGNORECASE) + ) text = self.text(line) for match in rx.finditer(text):
--- a/eric6/QScintilla/QsciScintillaCompat.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/QScintilla/QsciScintillaCompat.py Thu Apr 22 18:02:47 2021 +0200 @@ -180,13 +180,12 @@ @return linenumber at position or -1, if there is no line at pos (integer, zero based) """ - if isinstance(pos, int): - scipos = pos - else: - scipos = self.SendScintilla( - QsciScintilla.SCI_POSITIONFROMPOINT, - pos.x(), pos.y() - ) + scipos = ( + pos + if isinstance(pos, int) else + self.SendScintilla(QsciScintilla.SCI_POSITIONFROMPOINT, + pos.x(), pos.y()) + ) line = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, scipos) if line >= self.lines(): line = -1 @@ -958,10 +957,11 @@ if not self.__targetSearchActive: return - if self.__targetSearchFlags & QsciScintilla.SCFIND_REGEXP: - cmd = QsciScintilla.SCI_REPLACETARGETRE - else: - cmd = QsciScintilla.SCI_REPLACETARGET + cmd = ( + QsciScintilla.SCI_REPLACETARGETRE + if self.__targetSearchFlags & QsciScintilla.SCFIND_REGEXP else + QsciScintilla.SCI_REPLACETARGET + ) r = self._encodeString(replaceStr) start = self.SendScintilla(QsciScintilla.SCI_GETTARGETSTART)
--- a/eric6/Snapshot/SnapshotPreview.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/Snapshot/SnapshotPreview.py Thu Apr 22 18:02:47 2021 +0200 @@ -39,13 +39,14 @@ @param preview preview picture to be shown (QPixmap) """ - if not preview.isNull(): - pixmap = preview.scaled( + pixmap = ( + preview.scaled( self.width(), self.height(), Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation) - else: - pixmap = preview + if not preview.isNull() else + preview + ) self.setPixmap(pixmap) def mousePressEvent(self, evt):
--- a/eric6/Templates/TemplateViewer.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/Templates/TemplateViewer.py Thu Apr 22 18:02:47 2021 +0200 @@ -212,10 +212,11 @@ @return display text (string) """ - if self.description: - txt = "{0} - {1}".format(self.name, self.description) - else: - txt = self.name + txt = ( + "{0} - {1}".format(self.name, self.description) + if self.description else + self.name + ) return txt def setName(self, name): @@ -292,10 +293,11 @@ """ txt = self.template for var, val in list(varDict.items()): - if var in self.formatedVariables: - txt = self.__expandFormattedVariable(var, val, txt) - else: - txt = txt.replace(var, val) + txt = ( + self.__expandFormattedVariable(var, val, txt) + if var in self.formatedVariables else + txt.replace(var, val) + ) sepchar = Preferences.getTemplates("SeparatorChar") txt = txt.replace("{0}{1}".format(sepchar, sepchar), sepchar) prefix = "{0}{1}".format(os.linesep, indent) @@ -335,10 +337,11 @@ prefix = line[:ind] postfix = line[ind + len(var):] for count, v in enumerate(val.splitlines()): - if count: - t = "{0}{1}{2}{3}".format(t, os.linesep, indent, v) - else: - t = "{0}{1}{2}{3}".format(t, os.linesep, prefix, v) + t = ( + "{0}{1}{2}{3}".format(t, os.linesep, indent, v) + if count else + "{0}{1}{2}{3}".format(t, os.linesep, prefix, v) + ) t = "{0}{1}".format(t, postfix) else: t = "{0}{1}{2}".format(t, os.linesep, line) @@ -484,10 +487,11 @@ Private slot to handle the Add Entry context menu action. """ itm = self.currentItem() - if isinstance(itm, TemplateGroup): - groupName = itm.getName() - else: - groupName = itm.getGroupName() + groupName = ( + itm.getName() + if isinstance(itm, TemplateGroup) else + itm.getGroupName() + ) from .TemplatePropertiesDialog import TemplatePropertiesDialog dlg = TemplatePropertiesDialog(self)
--- a/eric6/UI/Browser.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/UI/Browser.py Thu Apr 22 18:02:47 2021 +0200 @@ -799,10 +799,11 @@ if self.model().rowCount() == 0: return - if self.currentIndex().isValid(): - startIndex = self.currentIndex() - else: - startIndex = self.model().index(0, 0) + startIndex = ( + self.currentIndex() + if self.currentIndex().isValid() else + self.model().index(0, 0) + ) keyboardSearchTimeWasValid = self._keyboardSearchTimer.isValid() keyboardSearchTimeElapsed = self._keyboardSearchTimer.restart()
--- a/eric6/UI/BrowserModel.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/UI/BrowserModel.py Thu Apr 22 18:02:47 2021 +0200 @@ -172,10 +172,11 @@ ): return QModelIndex() - if not parent.isValid(): - parentItem = self.rootItem - else: - parentItem = parent.internalPointer() + parentItem = ( + parent.internalPointer() + if parent.isValid() else + self.rootItem + ) try: if not parentItem.isPopulated(): @@ -346,15 +347,16 @@ cnt = itm.childCount() self.beginInsertRows( self.createIndex(itm.row(), 0, itm), cnt, cnt) - if f.isDir(): - node = BrowserDirectoryItem( + node = ( + BrowserDirectoryItem( itm, Utilities.toNativeSeparators(f.absoluteFilePath()), False) - else: - node = BrowserFileItem( + if f.isDir() else + BrowserFileItem( itm, Utilities.toNativeSeparators(f.absoluteFilePath())) + ) self._addItem(node, itm) self.endInsertRows() @@ -510,10 +512,11 @@ if parent is None: parent = QModelIndex() - if not parent.isValid(): - parentItem = self.rootItem - else: - parentItem = parent.internalPointer() + parentItem = ( + parent.internalPointer() + if parent.isValid() else + self.rootItem + ) cnt = parentItem.childCount() self.beginInsertRows(parent, cnt, cnt) @@ -604,10 +607,11 @@ self.createIndex(parentItem.row(), 0, parentItem), 0, len(syspath) - 1) for p in syspath: - if os.path.isdir(p): - node = BrowserDirectoryItem(parentItem, p) - else: - node = BrowserFileItem(parentItem, p) + node = ( + BrowserDirectoryItem(parentItem, p) + if os.path.isdir(p) else + BrowserFileItem(parentItem, p) + ) self._addItem(node, parentItem) if repopulate: self.endInsertRows()
--- a/eric6/UI/EmailDialog.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/UI/EmailDialog.py Thu Apr 22 18:02:47 2021 +0200 @@ -167,10 +167,11 @@ """ Private slot to send the email message. """ - if self.attachments.topLevelItemCount(): - msg = self.__createMultipartMail() - else: - msg = self.__createSimpleMail() + msg = ( + self.__createMultipartMail() + if self.attachments.topLevelItemCount() else + self.__createSimpleMail() + ) if Preferences.getUser("UseGoogleMailOAuth2"): self.__sendmailGoogle(msg)
--- a/eric6/UI/FindFileDialog.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/UI/FindFileDialog.py Thu Apr 22 18:02:47 2021 +0200 @@ -510,10 +510,11 @@ self.findProgressLabel.setPath(file) - if self.projectButton.isChecked(): - fn = os.path.join(self.project.ppath, file) - else: - fn = file + fn = ( + os.path.join(self.project.ppath, file) + if self.projectButton.isChecked() else + file + ) # read the file and split it into textlines try: text, encoding, hashStr = Utilities.readEncodedFileWithHash(fn)
--- a/eric6/UI/LogView.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/UI/LogView.py Thu Apr 22 18:02:47 2021 +0200 @@ -173,10 +173,11 @@ """ message = Utilities.filterAnsiSequences(message) - if isErrorMessage: - filters = self.__stderrFilter + self.__stdxxxFilter - else: - filters = self.__stdoutFilter + self.__stdxxxFilter + filters = ( + self.__stderrFilter + self.__stdxxxFilter + if isErrorMessage else + self.__stdoutFilter + self.__stdxxxFilter + ) return any(msgFilter in message for msgFilter in filters) @@ -253,16 +254,17 @@ flags |= QTextDocument.FindFlag.FindCaseSensitively if wholeWord: flags |= QTextDocument.FindFlag.FindWholeWords - if regexp: - ok = self.find(QRegularExpression( + ok = ( + self.find(QRegularExpression( txt, QRegularExpression.PatternOption.NoPatternOption if caseSensitive else QRegularExpression.PatternOption.CaseInsensitiveOption), flags ) - else: - ok = self.find(txt, flags) + if regexp else + self.find(txt, flags) + ) self.searchStringFound.emit(ok) def searchPrev(self, txt, caseSensitive, wholeWord, regexp): @@ -286,16 +288,17 @@ flags |= QTextDocument.FindFlag.FindCaseSensitively if wholeWord: flags |= QTextDocument.FindFlag.FindWholeWords - if regexp: - ok = self.find(QRegularExpression( + ok = ( + self.find(QRegularExpression( txt, QRegularExpression.PatternOption.NoPatternOption if caseSensitive else QRegularExpression.PatternOption.CaseInsensitiveOption), flags ) - else: - ok = self.find(txt, flags) + if regexp else + self.find(txt, flags) + ) self.searchStringFound.emit(ok) def keyPressEvent(self, evt):
--- a/eric6/UI/Previewers/PreviewerHTML.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/UI/Previewers/PreviewerHTML.py Thu Apr 22 18:02:47 2021 +0200 @@ -238,10 +238,11 @@ self.__restoreScrollBarPositions) if not filePath: filePath = "/" - if rootPath: - baseUrl = QUrl.fromLocalFile(rootPath + "/index.html") - else: - baseUrl = QUrl.fromLocalFile(filePath) + baseUrl = ( + QUrl.fromLocalFile(rootPath + "/index.html") + if rootPath else + QUrl.fromLocalFile(filePath) + ) self.previewView.setHtml(html, baseUrl=baseUrl) if self.__previewedEditor: self.__previewedEditor.setFocus() @@ -766,16 +767,13 @@ htmlFormat = Preferences.getEditor("PreviewMarkdownHTMLFormat").lower() body = markdown.markdown(text, extensions=extensions, output_format=htmlFormat.lower()) - if e5App().usesDarkPalette(): - style = ( - PreviewerHTMLStyles.css_markdown_dark + - PreviewerHTMLStyles.css_pygments_dark - ) - else: - style = ( - PreviewerHTMLStyles.css_markdown_light + - PreviewerHTMLStyles.css_pygments_light - ) + style = ( + (PreviewerHTMLStyles.css_markdown_dark + + PreviewerHTMLStyles.css_pygments_dark) + if e5App().usesDarkPalette() else + (PreviewerHTMLStyles.css_markdown_light + + PreviewerHTMLStyles.css_pygments_light) + ) if htmlFormat == "xhtml1": head = (
--- a/eric6/UI/PythonDisViewer.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/UI/PythonDisViewer.py Thu Apr 22 18:02:47 2021 +0200 @@ -399,13 +399,12 @@ @param itm reference to the item to be updated @type QTreeWidgetItem """ - if itm.childCount(): - endLine = max( - itm.child(index).data(0, self.EndLineRole) - for index in range(itm.childCount()) - ) - else: - endLine = itm.data(0, self.StartLineRole) + endLine = ( + max(itm.child(index).data(0, self.EndLineRole) + for index in range(itm.childCount())) + if itm.childCount() else + itm.data(0, self.StartLineRole) + ) itm.setData(0, self.EndLineRole, endLine) def __createCodeInfo(self, co):
--- a/eric6/UI/UserInterface.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/UI/UserInterface.py Thu Apr 22 18:02:47 2021 +0200 @@ -4121,15 +4121,16 @@ @param ask flag indicating to ask the user for permission @type bool """ - if ask: - res = E5MessageBox.yesNo( + res = ( + E5MessageBox.yesNo( self, self.tr("Restart application"), self.tr( """The application needs to be restarted. Do it now?"""), yesDefault=True) - else: - res = True + if ask else + True + ) if res and self.__shutdown(): e5App().closeAllWindows() @@ -6304,14 +6305,15 @@ if ex: fn += ex - if os.path.exists(fn): - ok = E5MessageBox.yesNo( + ok = ( + E5MessageBox.yesNo( self, self.tr("Export Keyboard Shortcuts"), self.tr("""<p>The keyboard shortcuts file <b>{0}</b> exists""" """ already. Overwrite it?</p>""").format(fn)) - else: - ok = True + if os.path.exists(fn) else + True + ) if ok: from Preferences import Shortcuts
--- a/eric6/Utilities/ModuleParser.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/Utilities/ModuleParser.py Thu Apr 22 18:02:47 2021 +0200 @@ -1540,10 +1540,11 @@ """ global _modules - if extensions is None: - _extensions = ['.py', '.pyw', '.ptl', '.rb'] - else: - _extensions = extensions[:] + _extensions = ( + ['.py', '.pyw', '.ptl', '.rb'] + if extensions is None else + extensions[:] + ) with contextlib.suppress(ValueError): _extensions.remove('.py')
--- a/eric6/Utilities/__init__.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/Utilities/__init__.py Thu Apr 22 18:02:47 2021 +0200 @@ -1613,10 +1613,11 @@ found (string or None) """ pattern = "^{0}[ \t]*=".format(key) - if isWindowsPlatform(): - filterRe = re.compile(pattern, re.IGNORECASE) - else: - filterRe = re.compile(pattern) + filterRe = ( + re.compile(pattern, re.IGNORECASE) + if isWindowsPlatform() else + re.compile(pattern) + ) entries = [e for e in QProcess.systemEnvironment() if filterRe.search(e) is not None] @@ -1638,10 +1639,11 @@ @rtype bool """ pattern = "^{0}[ \t]*=".format(key) - if isWindowsPlatform(): - filterRe = re.compile(pattern, re.IGNORECASE) - else: - filterRe = re.compile(pattern) + filterRe = ( + re.compile(pattern, re.IGNORECASE) + if isWindowsPlatform() else + re.compile(pattern) + ) entries = [e for e in QProcess.systemEnvironment() if filterRe.search(e) is not None]
--- a/eric6/VCS/StatusMonitorLed.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/VCS/StatusMonitorLed.py Thu Apr 22 18:02:47 2021 +0200 @@ -83,12 +83,11 @@ """ Private method to set the enabled status of the context menu actions. """ - if self.project.pudata["VCSSTATUSMONITORINTERVAL"]: - vcsStatusMonitorInterval = self.project.pudata[ - "VCSSTATUSMONITORINTERVAL"] - else: - vcsStatusMonitorInterval = Preferences.getVCS( - "StatusMonitorInterval") + vcsStatusMonitorInterval = ( + self.project.pudata["VCSSTATUSMONITORINTERVAL"] + if self.project.pudata["VCSSTATUSMONITORINTERVAL"] else + Preferences.getVCS("StatusMonitorInterval") + ) self.__checkAct.setEnabled(self.__on) self.__intervalAct.setEnabled(self.__on) self.__onAct.setEnabled(
--- a/eric6/VCS/VersionControl.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/VCS/VersionControl.py Thu Apr 22 18:02:47 2021 +0200 @@ -714,12 +714,11 @@ @param project reference to the project object @return reference to the monitor thread (QThread) """ - if project.pudata["VCSSTATUSMONITORINTERVAL"]: - vcsStatusMonitorInterval = project.pudata[ - "VCSSTATUSMONITORINTERVAL"] - else: - vcsStatusMonitorInterval = Preferences.getVCS( - "StatusMonitorInterval") + vcsStatusMonitorInterval = ( + project.pudata["VCSSTATUSMONITORINTERVAL"] + if project.pudata["VCSSTATUSMONITORINTERVAL"] else + Preferences.getVCS("StatusMonitorInterval") + ) if vcsStatusMonitorInterval > 0: self.statusMonitorThread = self._createStatusMonitorThread( vcsStatusMonitorInterval, project)
--- a/eric6/ViewManager/ViewManager.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/ViewManager/ViewManager.py Thu Apr 22 18:02:47 2021 +0200 @@ -5717,10 +5717,11 @@ """ Private method to handle the zoom action. """ - if QApplication.focusWidget() == e5App().getObject("Shell"): - aw = e5App().getObject("Shell") - else: - aw = self.activeWindow() + aw = ( + e5App().getObject("Shell") + if QApplication.focusWidget() == e5App().getObject("Shell") else + self.activeWindow() + ) if aw: from QScintilla.ZoomDialog import ZoomDialog dlg = ZoomDialog(aw.getZoom(), self.ui, None, True) @@ -5734,10 +5735,11 @@ @param value zoom value to be set (integer) """ - if QApplication.focusWidget() == e5App().getObject("Shell"): - aw = e5App().getObject("Shell") - else: - aw = self.activeWindow() + aw = ( + e5App().getObject("Shell") + if QApplication.focusWidget() == e5App().getObject("Shell") else + self.activeWindow() + ) if aw: aw.zoomTo(value) self.sbZoom.setValue(aw.getZoom()) @@ -5751,10 +5753,11 @@ @param zoomingWidget reference to the widget triggering the slot @type Editor or Shell """ - if QApplication.focusWidget() == e5App().getObject("Shell"): - aw = e5App().getObject("Shell") - else: - aw = self.activeWindow() + aw = ( + e5App().getObject("Shell") + if QApplication.focusWidget() == e5App().getObject("Shell") else + self.activeWindow() + ) if aw and aw == zoomingWidget: self.sbZoom.setValue(value)
--- a/eric6/VirtualEnv/VirtualenvAddEditDialog.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/VirtualEnv/VirtualenvAddEditDialog.py Thu Apr 22 18:02:47 2021 +0200 @@ -107,17 +107,14 @@ """ Private slot to update the state of the OK button. """ - if self.__editMode: - enable = ( - bool(self.nameEdit.text()) and - (self.nameEdit.text() == self.__venvName or - self.__manager.isUnique(self.nameEdit.text())) - ) - else: - enable = ( - bool(self.nameEdit.text()) and - self.__manager.isUnique(self.nameEdit.text()) - ) + enable = ( + (bool(self.nameEdit.text()) and + (self.nameEdit.text() == self.__venvName or + self.__manager.isUnique(self.nameEdit.text()))) + if self.__editMode else + (bool(self.nameEdit.text()) and + self.__manager.isUnique(self.nameEdit.text())) + ) if not self.globalCheckBox.isChecked(): enable &= (
--- a/eric6/VirtualEnv/VirtualenvExecDialog.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/VirtualEnv/VirtualenvExecDialog.py Thu Apr 22 18:02:47 2021 +0200 @@ -261,10 +261,11 @@ Private method to write a log file to the virtualenv directory. """ outtxt = self.contents.toPlainText() - if self.__pyvenv: - logFile = os.path.join(self.__targetDir, "pyvenv.log") - else: - logFile = os.path.join(self.__targetDir, "virtualenv.log") + logFile = ( + os.path.join(self.__targetDir, "pyvenv.log") + if self.__pyvenv else + os.path.join(self.__targetDir, "virtualenv.log") + ) self.__logOutput(self.tr("\nWriting log file '{0}'.\n") .format(logFile))
--- a/eric6/WebBrowser/AdBlock/AdBlockDialog.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/AdBlock/AdBlockDialog.py Thu Apr 22 18:02:47 2021 +0200 @@ -84,10 +84,11 @@ from .AdBlockTreeWidget import AdBlockTreeWidget for subscription in self.__manager.subscriptions(): tree = AdBlockTreeWidget(subscription, self.subscriptionsTabWidget) - if subscription.isEnabled(): - icon = UI.PixmapCache.getIcon("adBlockPlus") - else: - icon = UI.PixmapCache.getIcon("adBlockPlusDisabled") + icon = ( + UI.PixmapCache.getIcon("adBlockPlus") + if subscription.isEnabled() else + UI.PixmapCache.getIcon("adBlockPlusDisabled") + ) self.subscriptionsTabWidget.addTab( tree, icon, subscription.title()) @@ -230,17 +231,18 @@ ) for subscription in requiresSubscriptions: requiresTitles.append(subscription.title()) - if requiresTitles: - message = self.tr( + message = ( + self.tr( "<p>Do you really want to remove subscription" " <b>{0}</b> and all subscriptions requiring it?</p>" "<ul><li>{1}</li></ul>").format( self.__currentSubscription.title(), "</li><li>".join(requiresTitles)) - else: - message = self.tr( + if requiresTitles else + self.tr( "<p>Do you really want to remove subscription" " <b>{0}</b>?</p>").format(self.__currentSubscription.title()) + ) res = E5MessageBox.yesNo( self, self.tr("Remove Subscription"),
--- a/eric6/WebBrowser/AdBlock/AdBlockSubscription.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/AdBlock/AdBlockSubscription.py Thu Apr 22 18:02:47 2021 +0200 @@ -345,12 +345,11 @@ """ Public method to check for an update. """ - if self.__updatePeriod: - updatePeriod = self.__updatePeriod - else: - updatePeriod = ( - Preferences.getWebBrowser("AdBlockUpdatePeriod") * 24 - ) + updatePeriod = ( + self.__updatePeriod + if self.__updatePeriod else + Preferences.getWebBrowser("AdBlockUpdatePeriod") * 24 + ) if ( not self.__lastUpdate.isValid() or (self.__remoteModified.isValid() and
--- a/eric6/WebBrowser/Bookmarks/BookmarksImporters/FirefoxImporter.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Bookmarks/BookmarksImporters/FirefoxImporter.py Thu Apr 22 18:02:47 2021 +0200 @@ -125,10 +125,11 @@ id_ = row[0] parent = row[1] title = row[2] - if parent in folders: - folder = BookmarkNode(BookmarkNode.Folder, folders[parent]) - else: - folder = BookmarkNode(BookmarkNode.Folder, importRootNode) + folder = ( + BookmarkNode(BookmarkNode.Folder, folders[parent]) + if parent in folders else + BookmarkNode(BookmarkNode.Folder, importRootNode) + ) folder.title = title.replace("&", "&&") folders[id_] = folder except sqlite3.DatabaseError as err:
--- a/eric6/WebBrowser/Bookmarks/BookmarksImporters/IExplorerImporter.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Bookmarks/BookmarksImporters/IExplorerImporter.py Thu Apr 22 18:02:47 2021 +0200 @@ -32,11 +32,11 @@ raise ValueError( "Unsupported browser ID given ({0}).".format(sourceId)) - if Globals.isWindowsPlatform(): - standardDir = os.path.expandvars( - "%USERPROFILE%\\Favorites") - else: - standardDir = "" + standardDir = ( + os.path.expandvars("%USERPROFILE%\\Favorites") + if Globals.isWindowsPlatform() else + "" + ) return ( UI.PixmapCache.getPixmap("internet_explorer"), "Internet Explorer", @@ -111,11 +111,11 @@ for directory, subdirs, files in os.walk(self.__fileName): for subdir in subdirs: path = os.path.join(directory, subdir) - if directory in folders: - folder = BookmarkNode(BookmarkNode.Folder, - folders[directory]) - else: - folder = BookmarkNode(BookmarkNode.Folder, importRootNode) + folder = ( + BookmarkNode(BookmarkNode.Folder, folders[directory]) + if directory in folders else + BookmarkNode(BookmarkNode.Folder, importRootNode) + ) folder.title = subdir.replace("&", "&&") folders[path] = folder
--- a/eric6/WebBrowser/Bookmarks/NsHtmlWriter.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Bookmarks/NsHtmlWriter.py Thu Apr 22 18:02:47 2021 +0200 @@ -102,19 +102,21 @@ @param node reference to the node to be written (BookmarkNode) @param indent size of the indentation (integer) """ - if node.added.isValid(): - added = " ADD_DATE=\"{0}\"".format(node.added.toTime_t()) - else: - added = "" - if node.modified.isValid(): - modified = " LAST_MODIFIED=\"{0}\"".format( - node.modified.toTime_t()) - else: - modified = "" - if node.visited.isValid(): - visited = " LAST_VISIT=\"{0}\"".format(node.visited.toTime_t()) - else: - visited = "" + added = ( + " ADD_DATE=\"{0}\"".format(node.added.toTime_t()) + if node.added.isValid() else + "" + ) + modified = ( + " LAST_MODIFIED=\"{0}\"".format(node.modified.toTime_t()) + if node.modified.isValid() else + "" + ) + visited = ( + " LAST_VISIT=\"{0}\"".format(node.visited.toTime_t()) + if node.visited.isValid() else + "" + ) self.__dev.write(" " * indent) self.__dev.write("<DT><A HREF=\"{0}\"{1}{2}{3}>{4}</A>\n".format( @@ -136,10 +138,11 @@ """ folded = "" if node.expanded else " FOLDED" - if node.added.isValid(): - added = " ADD_DATE=\"{0}\"".format(node.added.toTime_t()) - else: - added = "" + added = ( + " ADD_DATE=\"{0}\"".format(node.added.toTime_t()) + if node.added.isValid() else + "" + ) self.__dev.write(" " * indent) self.__dev.write("<DT><H3{0}{1}>{2}</H3>\n".format(
--- a/eric6/WebBrowser/ClosedTabsManager.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/ClosedTabsManager.py Thu Apr 22 18:02:47 2021 +0200 @@ -84,10 +84,12 @@ @param index index of the tab to return (integer) @return requested tab (ClosedTab) """ - if len(self.__closedTabs) > 0 and len(self.__closedTabs) > index: - tab = self.__closedTabs.pop(index) - else: - tab = ClosedTab() + tab = ( + self.__closedTabs.pop(index) + if (len(self.__closedTabs) > 0 and + len(self.__closedTabs) > index) else + ClosedTab() + ) self.closedTabAvailable.emit(len(self.__closedTabs) > 0) return tab
--- a/eric6/WebBrowser/Download/DownloadItem.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Download/DownloadItem.py Thu Apr 22 18:02:47 2021 +0200 @@ -400,10 +400,11 @@ return -1.0 cSpeed = self.currentSpeed() - if cSpeed != 0: - timeRemaining = (self.bytesTotal() - self.bytesReceived()) / cSpeed - else: - timeRemaining = 1 + timeRemaining = ( + (self.bytesTotal() - self.bytesReceived()) / cSpeed + if cSpeed != 0 else + 1 + ) # ETA should never be 0 if timeRemaining == 0:
--- a/eric6/WebBrowser/Feeds/FeedsManager.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Feeds/FeedsManager.py Thu Apr 22 18:02:47 2021 +0200 @@ -236,13 +236,8 @@ Private slot to disable/enable various buttons. """ selItems = self.feedsTree.selectedItems() - if ( - len(selItems) == 1 and - self.feedsTree.indexOfTopLevelItem(selItems[0]) != -1 - ): - enable = True - else: - enable = False + enable = (len(selItems) == 1 and + self.feedsTree.indexOfTopLevelItem(selItems[0]) != -1) self.reloadButton.setEnabled(enable) self.editButton.setEnabled(enable)
--- a/eric6/WebBrowser/GreaseMonkey/GreaseMonkeyConfiguration/GreaseMonkeyConfigurationListDelegate.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/GreaseMonkey/GreaseMonkeyConfiguration/GreaseMonkeyConfigurationListDelegate.py Thu Apr 22 18:02:47 2021 +0200 @@ -72,14 +72,13 @@ titleFont.setPointSize(titleFont.pointSize() + 1) titleMetrics = QFontMetrics(titleFont) - if Globals.isWindowsPlatform(): - colorRole = QPalette.ColorRole.Text - else: - colorRole = ( - QPalette.ColorRole.HighlightedText - if opt.state & QStyle.StateFlag.State_Selected else - QPalette.ColorRole.Text - ) + colorRole = ( + QPalette.ColorRole.Text + if Globals.isWindowsPlatform() else + (QPalette.ColorRole.HighlightedText + if opt.state & QStyle.StateFlag.State_Selected else + QPalette.ColorRole.Text) + ) leftPos = self.__padding rightPos = (
--- a/eric6/WebBrowser/History/HistoryManager.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/History/HistoryManager.py Thu Apr 22 18:02:47 2021 +0200 @@ -360,10 +360,11 @@ checkForExpired = QDateTime(self.__history[-1].dateTime) checkForExpired.setDate( checkForExpired.date().addDays(self.__daysToExpire)) - if now.daysTo(checkForExpired) > 7: - nextTimeout = 7 * 86400 - else: - nextTimeout = now.secsTo(checkForExpired) + nextTimeout = ( + 7 * 86400 + if now.daysTo(checkForExpired) > 7 else + now.secsTo(checkForExpired) + ) if nextTimeout > 0: break
--- a/eric6/WebBrowser/Network/NetworkManager.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Network/NetworkManager.py Thu Apr 22 18:02:47 2021 +0200 @@ -278,14 +278,13 @@ realm = auth.realm() if not realm and 'realm' in auth.options(): realm = auth.option("realm") - if realm: - info = self.tr( - "<b>Enter username and password for '{0}', realm '{1}'</b>" - ).format(urlRoot, realm) - else: - info = self.tr( - "<b>Enter username and password for '{0}'</b>" - ).format(urlRoot) + info = ( + self.tr("<b>Enter username and password for '{0}', realm '{1}'</b>" + ).format(urlRoot, realm) + if realm else + self.tr("<b>Enter username and password for '{0}'</b>" + ).format(urlRoot) + ) from UI.AuthenticationDialog import AuthenticationDialog import WebBrowser.WebBrowserWindow
--- a/eric6/WebBrowser/Network/QtHelpSchemeHandler.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Network/QtHelpSchemeHandler.py Thu Apr 22 18:02:47 2021 +0200 @@ -160,10 +160,10 @@ @param url URL of the requested page @type QUrl """ - if self.__engine.findFile(url).isValid(): - data = self.__engine.fileData(url) - else: - data = QByteArray(self.tr( + data = ( + self.__engine.fileData(url) + if self.__engine.findFile(url).isValid() else + QByteArray(self.tr( """<html>""" """<head><title>Error 404...</title></head>""" """<body><div align="center"><br><br>""" @@ -171,6 +171,7 @@ """<h3>'{0}'</h3></div></body>""" """</html>""").format(url.toString()) .encode("utf-8")) + ) with E5MutexLocker(self.__mutex): self.__buffer.setData(data)
--- a/eric6/WebBrowser/OpenSearch/OpenSearchDialog.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/OpenSearch/OpenSearchDialog.py Thu Apr 22 18:02:47 2021 +0200 @@ -96,10 +96,11 @@ from .OpenSearchEditDialog import OpenSearchEditDialog rows = self.enginesTable.selectionModel().selectedRows() - if len(rows) == 0: - row = self.enginesTable.selectionModel().currentIndex().row() - else: - row = rows[0].row() + row = ( + self.enginesTable.selectionModel().currentIndex().row() + if len(rows) == 0 else + rows[0].row() + ) osm = self.__mw.openSearchManager() engineName = osm.allEnginesNames()[row]
--- a/eric6/WebBrowser/Passwords/PasswordManager.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Passwords/PasswordManager.py Thu Apr 22 18:02:47 2021 +0200 @@ -127,11 +127,11 @@ authority = url.authority() if authority.startswith("@"): authority = authority[1:] - if realm: - key = "{0}://{1} ({2})".format( - url.scheme(), authority, realm) - else: - key = "{0}://{1}".format(url.scheme(), authority) + key = ( + "{0}://{1} ({2})".format(url.scheme(), authority, realm) + if realm else + "{0}://{1}".format(url.scheme(), authority) + ) return key def getFileName(self):
--- a/eric6/WebBrowser/QtHelp/HelpIndexWidget.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/QtHelp/HelpIndexWidget.py Thu Apr 22 18:02:47 2021 +0200 @@ -112,10 +112,11 @@ @type str """ modifiers = QApplication.keyboardModifiers() - if len(links) == 1: - url = QUrl(links[list(links.keys())[0]]) - else: - url = self.__selectLink(links, keyword) + url = ( + QUrl(links[list(links.keys())[0]]) + if len(links) == 1 else + self.__selectLink(links, keyword) + ) self.__linkActivated(url, keyword, modifiers) def __selectLink(self, links, keyword):
--- a/eric6/WebBrowser/SafeBrowsing/SafeBrowsingDialog.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/SafeBrowsing/SafeBrowsingDialog.py Thu Apr 22 18:02:47 2021 +0200 @@ -334,16 +334,14 @@ """ nextUpdateDateTime = Preferences.getWebBrowser( "SafeBrowsingUpdateDateTime") - if ( - not nextUpdateDateTime.isValid() or - nextUpdateDateTime <= QDateTime.currentDateTime() - ): - message = self.tr("The next automatic threat list update will be" - " done now.") - else: - message = self.tr("<p>The next automatic threat list update will" - " be done at <b>{0}</b>.</p>").format( + message = ( + self.tr("The next automatic threat list update will be done now.") + if (not nextUpdateDateTime.isValid() or + nextUpdateDateTime <= QDateTime.currentDateTime()) else + self.tr("<p>The next automatic threat list update will be done at" + " <b>{0}</b>.</p>").format( nextUpdateDateTime.toString("yyyy-MM-dd, HH:mm:ss")) + ) E5MessageBox.information( self,
--- a/eric6/WebBrowser/SafeBrowsing/SafeBrowsingManager.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/SafeBrowsing/SafeBrowsingManager.py Thu Apr 22 18:02:47 2021 +0200 @@ -158,10 +158,11 @@ """ from WebBrowser.WebBrowserWindow import WebBrowserWindow - if timeout == 0: - kind = NotificationTypes.Critical - else: - kind = NotificationTypes.Information + kind = ( + NotificationTypes.Critical + if timeout == 0 else + NotificationTypes.Information + ) WebBrowserWindow.showNotification( UI.PixmapCache.getPixmap("safeBrowsing48"), @@ -551,10 +552,11 @@ @return threat message @rtype str """ - if self.__apiClient: - msg = self.__apiClient.getThreatMessage(threatType) - else: - msg = "" + msg = ( + self.__apiClient.getThreatMessage(threatType) + if self.__apiClient else + "" + ) return msg
--- a/eric6/WebBrowser/StatusBar/JavaScriptIcon.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/StatusBar/JavaScriptIcon.py Thu Apr 22 18:02:47 2021 +0200 @@ -67,13 +67,14 @@ menu = QMenu() menu.addAction(self.tr("Current Page Settings")).setFont(boldFont) - if self._testCurrentPageWebAttribute( - QWebEngineSettings.WebAttribute.JavascriptEnabled): - act = menu.addAction(self.tr("Disable JavaScript (temporarily)"), - self.__toggleJavaScript) - else: - act = menu.addAction(self.tr("Enable JavaScript (temporarily)"), - self.__toggleJavaScript) + act = ( + menu.addAction(self.tr("Disable JavaScript (temporarily)"), + self.__toggleJavaScript) + if self._testCurrentPageWebAttribute( + QWebEngineSettings.WebAttribute.JavascriptEnabled) else + menu.addAction(self.tr("Enable JavaScript (temporarily)"), + self.__toggleJavaScript) + ) if ( self._currentPage() is not None and self._currentPage().url().scheme() == "eric"
--- a/eric6/WebBrowser/Sync/FtpSyncHandler.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Sync/FtpSyncHandler.py Thu Apr 22 18:02:47 2021 +0200 @@ -84,10 +84,11 @@ self.__ftp = E5Ftp() # do proxy setup - if not Preferences.getUI("UseProxy"): - proxyType = E5FtpProxyType.NoProxy - else: - proxyType = Preferences.getUI("ProxyType/Ftp") + proxyType = ( + E5FtpProxyType.NoProxy + if not Preferences.getUI("UseProxy") else + Preferences.getUI("ProxyType/Ftp") + ) if proxyType != E5FtpProxyType.NoProxy: self.__ftp.setProxy( proxyType,
--- a/eric6/WebBrowser/Tools/PrintToPdfDialog.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Tools/PrintToPdfDialog.py Thu Apr 22 18:02:47 2021 +0200 @@ -73,13 +73,12 @@ """ Private method to update the page layout label. """ - if ( - self.__currentPageLayout.orientation() == - QPageLayout.Orientation.Portrait - ): - orientation = self.tr("Portrait") - else: - orientation = self.tr("Landscape") + orientation = ( + self.tr("Portrait") + if (self.__currentPageLayout.orientation() == + QPageLayout.Orientation.Portrait) else + self.tr("Landscape") + ) self.pageLayoutLabel.setText( self.tr("{0}, {1}", "page size, page orientation").format( self.__currentPageLayout.pageSize().name(),
--- a/eric6/WebBrowser/Tools/Scripts.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Tools/Scripts.py Thu Apr 22 18:02:47 2021 +0200 @@ -76,10 +76,11 @@ }})()""" from WebBrowser.WebBrowserPage import WebBrowserPage - if worldId == WebBrowserPage.SafeJsWorld: - match = "// @exclude eric:*" - else: - match = "// @include eric:*" + match = ( + "// @exclude eric:*" + if worldId == WebBrowserPage.SafeJsWorld else + "// @include eric:*" + ) return source.format(match, getJavascript("qwebchannel.js"))
--- a/eric6/WebBrowser/Tools/WebBrowserTools.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/Tools/WebBrowserTools.py Thu Apr 22 18:02:47 2021 +0200 @@ -238,17 +238,17 @@ useragent = QWebEngineProfile.defaultProfile().httpUserAgent() match = re.search(r"""Chrome/([\d.]+)""", useragent) - if match: - chromeVersion = match.group(1) - else: - chromeVersion = QCoreApplication.translate( - "WebBrowserTools", "<unknown>") + chromeVersion = ( + match.group(1) + if match else + QCoreApplication.translate("WebBrowserTools", "<unknown>") + ) match = re.search(r"""QtWebEngine/([\d.]+)""", useragent) - if match: - webengineVersion = match.group(1) - else: - webengineVersion = QCoreApplication.translate( - "WebBrowserTools", "<unknown>") + webengineVersion = ( + match.group(1) + if match else + QCoreApplication.translate("WebBrowserTools", "<unknown>") + ) return (chromeVersion, webengineVersion)
--- a/eric6/WebBrowser/UrlBar/UrlBar.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/UrlBar/UrlBar.py Thu Apr 22 18:02:47 2021 +0200 @@ -237,11 +237,11 @@ """ foregroundColor = QApplication.palette().color(QPalette.ColorRole.Text) - if self.__privateMode: - backgroundColor = Preferences.getWebBrowser("PrivateModeUrlColor") - else: - backgroundColor = QApplication.palette().color( - QPalette.ColorRole.Base) + backgroundColor = ( + Preferences.getWebBrowser("PrivateModeUrlColor") + if self.__privateMode else + QApplication.palette().color(QPalette.ColorRole.Base) + ) if self.__browser is not None: p = self.palette()
--- a/eric6/WebBrowser/VirusTotal/VirusTotalApi.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/VirusTotal/VirusTotalApi.py Thu Apr 22 18:02:47 2021 +0200 @@ -79,10 +79,11 @@ """ Private method to load the settings. """ - if Preferences.getWebBrowser("VirusTotalSecure"): - protocol = "https" - else: - protocol = "http" + protocol = ( + "https" + if Preferences.getWebBrowser("VirusTotalSecure") else + "http" + ) self.GetFileReportUrl = self.GetFileReportPattern.format(protocol) self.ScanUrlUrl = self.ScanUrlPattern.format(protocol) self.GetUrlReportUrl = self.GetUrlReportPattern.format(protocol) @@ -109,10 +110,11 @@ @param key service key (string) @param protocol protocol used to access VirusTotal (string) """ - if protocol == "": - urlStr = self.GetFileReportUrl - else: - urlStr = self.GetFileReportPattern.format(protocol) + urlStr = ( + self.GetFileReportUrl + if protocol == "" else + self.GetFileReportPattern.format(protocol) + ) request = QNetworkRequest(QUrl(urlStr)) request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, "application/x-www-form-urlencoded")
--- a/eric6/WebBrowser/WebBrowserPage.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/WebBrowserPage.py Thu Apr 22 18:02:47 2021 +0200 @@ -419,10 +419,11 @@ ExternalJsObject.setupWebChannel(channel, self) worldId = -1 - if url.scheme() in ("eric", "qthelp"): - worldId = self.UnsafeJsWorld - else: - worldId = self.SafeJsWorld + worldId = ( + self.UnsafeJsWorld + if url.scheme() in ("eric", "qthelp") else + self.SafeJsWorld + ) if worldId != self.__channelWorldId: self.__channelWorldId = worldId try:
--- a/eric6/WebBrowser/WebBrowserTabWidget.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/WebBrowserTabWidget.py Thu Apr 22 18:02:47 2021 +0200 @@ -449,10 +449,11 @@ lambda: self.printBrowser(browser)) browser.showMessage.connect(self.showMessage) - if position == -1: - index = self.addTab(browser, self.tr("...")) - else: - index = self.insertTab(position, browser, self.tr("...")) + index = ( + self.addTab(browser, self.tr("...")) + if position == -1 else + self.insertTab(position, browser, self.tr("...")) + ) if not background: self.setCurrentIndex(index)
--- a/eric6/WebBrowser/WebBrowserView.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/WebBrowserView.py Thu Apr 22 18:02:47 2021 +0200 @@ -1255,10 +1255,11 @@ return engineName = act.data() - if engineName: - engine = self.__mw.openSearchManager().engine(engineName) - else: - engine = self.__mw.openSearchManager().currentEngine() + engine = ( + self.__mw.openSearchManager().engine(engineName) + if engineName else + self.__mw.openSearchManager().currentEngine() + ) if engine: self.search.emit(engine.searchUrl(searchText))
--- a/eric6/WebBrowser/WebBrowserWindow.py Wed Apr 21 19:40:50 2021 +0200 +++ b/eric6/WebBrowser/WebBrowserWindow.py Thu Apr 22 18:02:47 2021 +0200 @@ -296,10 +296,11 @@ self.addDockWidget(Qt.DockWidgetArea.BottomDockWidgetArea, self.__javascriptConsoleDock) - if Preferences.getWebBrowser("SaveGeometry"): - g = Preferences.getGeometry("WebBrowserGeometry") - else: - g = QByteArray() + g = ( + Preferences.getGeometry("WebBrowserGeometry") + if Preferences.getWebBrowser("SaveGeometry") else + QByteArray() + ) if g.isEmpty(): s = QSize(800, 800) self.resize(s) @@ -4114,10 +4115,11 @@ self.__textEncodingMenu.clear() defaultTextEncoding = self.webSettings().defaultTextEncoding().lower() - if defaultTextEncoding in Utilities.supportedCodecs: - currentCodec = defaultTextEncoding - else: - currentCodec = "" + currentCodec = ( + defaultTextEncoding + if defaultTextEncoding in Utilities.supportedCodecs else + "" + ) isoCodecs = [] winCodecs = [] @@ -4997,14 +4999,15 @@ if ex: fn += ex - if os.path.exists(fn): - ok = E5MessageBox.yesNo( + ok = ( + E5MessageBox.yesNo( self, self.tr("Export Keyboard Shortcuts"), self.tr("""<p>The keyboard shortcuts file <b>{0}</b> exists""" """ already. Overwrite it?</p>""").format(fn)) - else: - ok = True + if os.path.exists(fn) else + True + ) if ok: from Preferences import Shortcuts
--- a/scripts/install-debugclients.py Wed Apr 21 19:40:50 2021 +0200 +++ b/scripts/install-debugclients.py Thu Apr 22 18:02:47 2021 +0200 @@ -202,10 +202,11 @@ global distDir, doCleanup, sourceDir, modDir # set install prefix, if not None - if distDir: - targetDir = os.path.normpath(os.path.join(distDir, installPackage)) - else: - targetDir = os.path.join(modDir, installPackage) + targetDir = ( + os.path.normpath(os.path.join(distDir, installPackage)) + if distDir else + os.path.join(modDir, installPackage) + ) try: # Install the files
--- a/scripts/install.py Wed Apr 21 19:40:50 2021 +0200 +++ b/scripts/install.py Thu Apr 22 18:02:47 2021 +0200 @@ -308,11 +308,11 @@ @param wfile basename (without extension) of the wrapper script @return the names of the wrapper scripts """ - if sys.platform.startswith(("win", "cygwin")): - wnames = (dname + "\\" + wfile + ".cmd", - dname + "\\" + wfile + ".bat") - else: - wnames = (dname + "/" + wfile, ) + wnames = ( + (dname + "\\" + wfile + ".cmd", dname + "\\" + wfile + ".bat") + if sys.platform.startswith(("win", "cygwin")) else + (dname + "/" + wfile, ) + ) return wnames @@ -1238,13 +1238,13 @@ "MicroPython", "*.api"))): apis.append(os.path.basename(apiName)) - if sys.platform == "darwin": - macConfig = ( - """ 'macAppBundlePath': r'{0}',\n""" - """ 'macAppBundleName': r'{1}',\n""" - ).format(macAppBundlePath, macAppBundleName) - else: - macConfig = "" + macConfig = ( + (""" 'macAppBundlePath': r'{0}',\n""" + """ 'macAppBundleName': r'{1}',\n""").format(macAppBundlePath, + macAppBundleName) + if sys.platform == "darwin" else + "" + ) config = ( """# -*- coding: utf-8 -*-\n""" """#\n"""
--- a/scripts/uninstall.py Wed Apr 21 19:40:50 2021 +0200 +++ b/scripts/uninstall.py Thu Apr 22 18:02:47 2021 +0200 @@ -97,11 +97,11 @@ @param wfile basename (without extension) of the wrapper script @return the names of the wrapper scripts """ - if sys.platform.startswith(("win", "cygwin")): - wnames = (dname + "\\" + wfile + ".cmd", - dname + "\\" + wfile + ".bat") - else: - wnames = (dname + "/" + wfile, ) + wnames = ( + (dname + "\\" + wfile + ".cmd", dname + "\\" + wfile + ".bat") + if sys.platform.startswith(("win", "cygwin")) else + (dname + "/" + wfile, ) + ) return wnames