--- a/eric6/Templates/TemplateViewer.py Mon Sep 23 19:10:42 2019 +0200 +++ b/eric6/Templates/TemplateViewer.py Mon Sep 23 19:22:12 2019 +0200 @@ -13,8 +13,9 @@ import re from PyQt5.QtCore import QFile, QFileInfo, QIODevice, Qt, QCoreApplication -from PyQt5.QtWidgets import QTreeWidget, QDialog, QApplication, QMenu, \ - QTreeWidgetItem +from PyQt5.QtWidgets import ( + QTreeWidget, QDialog, QApplication, QMenu, QTreeWidgetItem +) from E5Gui.E5Application import e5App from E5Gui import E5MessageBox, E5FileDialog @@ -105,8 +106,10 @@ self.entries[name] = TemplateEntry(self, name, description, template) - if Preferences.getTemplates("AutoOpenGroups") and \ - not self.isExpanded(): + if ( + Preferences.getTemplates("AutoOpenGroups") and + not self.isExpanded() + ): self.setExpanded(True) def removeEntry(self, name): @@ -121,8 +124,10 @@ del self.entries[name] if len(self.entries) == 0: - if Preferences.getTemplates("AutoOpenGroups") and \ - self.isExpanded(): + if ( + Preferences.getTemplates("AutoOpenGroups") and + self.isExpanded() + ): self.setExpanded(False) def removeAllEntries(self): @@ -355,10 +360,10 @@ Private method to retrieve the list of variables. """ sepchar = Preferences.getTemplates("SeparatorChar") - variablesPattern = \ - re.compile( - r"""\{0}[a-zA-Z][a-zA-Z0-9_]*(?::(?:ml|rl))?\{1}""".format( - sepchar, sepchar)) + variablesPattern = re.compile( + r"""\{0}[a-zA-Z][a-zA-Z0-9_]*(?::(?:ml|rl))?\{1}""".format( + sepchar, sepchar) + ) variables = variablesPattern.findall(self.template) self.variables = [] self.formatedVariables = [] @@ -664,10 +669,10 @@ keyfmt.format('ext'): ext }) - varValues[keyfmt.format('clipboard:ml')] = \ + varValues[keyfmt.format('clipboard:ml')] = ( QApplication.clipboard().text() - varValues[keyfmt.format('clipboard')] = \ - QApplication.clipboard().text() + ) + varValues[keyfmt.format('clipboard')] = QApplication.clipboard().text() if editor.hasSelectedText(): varValues[keyfmt.format('cur_select:ml')] = editor.selectedText() @@ -705,15 +710,17 @@ if variables: if Preferences.getTemplates("SingleDialog"): - from .TemplateMultipleVariablesDialog import \ + from .TemplateMultipleVariablesDialog import ( TemplateMultipleVariablesDialog + ) dlg = TemplateMultipleVariablesDialog(variables, self) if dlg.exec_() == QDialog.Accepted: varValues.update(dlg.getVariables()) ok = True else: - from .TemplateSingleVariableDialog import \ + from .TemplateSingleVariableDialog import ( TemplateSingleVariableDialog + ) for var in variables: dlg = TemplateSingleVariableDialog(var, self) if dlg.exec_() == QDialog.Accepted: @@ -726,8 +733,8 @@ ok = True if ok: - line = editor.text(editor.getCursorPosition()[0])\ - .replace(os.linesep, "") + line = editor.text( + editor.getCursorPosition()[0]).replace(os.linesep, "") indent = line.replace(line.lstrip(), "") txt, lines, count = itm.getExpandedText(varValues, indent) # It should be done in this way to allow undo @@ -745,8 +752,10 @@ count += len(indent) if "i_n_s_e_r_t_i_o_n" in txt and "s_e_l_e_c_t" in txt: - txt = "'Insertion and selection can not be in" \ + txt = ( + "'Insertion and selection can not be in" " template together'" + ) if "i_n_s_e_r_t_i_o_n" in txt: lines = 1