def on_serversButton_clicked(self): """ Private slot to edit the Subversion servers file. """ from QScintilla.MiniEditor import MiniEditor serversFile = self.__plugin.getServersPath() editor = MiniEditor(serversFile, "Properties", self) editor.show()
def on_configButton_clicked(self): """ Private slot to edit the Subversion config file. """ from QScintilla.MiniEditor import MiniEditor cfgFile = self.__plugin.getConfigPath() editor = MiniEditor(cfgFile, "Properties", self) editor.show()
def on_showScriptSourceButton_clicked(self): """ Private slot to show an editor window with the source code. """ from Helpviewer import HelpUtilities tmpFileName = HelpUtilities.ensureUniqueFilename( os.path.join(QDir.tempPath(), "tmp-userscript.js")) if QFile.copy(self.__script.fileName(), tmpFileName): from QScintilla.MiniEditor import MiniEditor editor = MiniEditor(tmpFileName, "JavaScript", self) editor.show()
def __editConfiguration(self, venvName=""): """ Private method to edit a configuration. @param venvName name of the environment to act upon @type str """ from QScintilla.MiniEditor import MiniEditor if venvName: cfgFile = self.__pip.getVirtualenvConfig(venvName) if not cfgFile: return else: cfgFile = self.__pip.getUserConfig() cfgDir = os.path.dirname(cfgFile) if not cfgDir: E5MessageBox.critical( None, self.tr("Edit Configuration"), self.tr("""No valid configuration path determined.""" """ Aborting""")) return try: if not os.path.isdir(cfgDir): os.makedirs(cfgDir) except OSError: E5MessageBox.critical( None, self.tr("Edit Configuration"), self.tr("""No valid configuration path determined.""" """ Aborting""")) return if not os.path.exists(cfgFile): try: f = open(cfgFile, "w") f.write("[global]\n") f.close() except (IOError, OSError): # ignore these pass # check, if the destination is writeable if not os.access(cfgFile, os.W_OK): E5MessageBox.critical( None, self.tr("Edit Configuration"), self.tr("""No valid configuration path determined.""" """ Aborting""")) return self.__editor = MiniEditor(cfgFile, "Properties") self.__editor.show()
def __editConfiguration(self, virtualenv=False): """ Private method to edit a configuration. @param virtualenv flag indicating to edit the current virtualenv configuration file (boolean) """ from QScintilla.MiniEditor import MiniEditor if virtualenv: cfgFile = self.__getVirtualenvConfig() else: cfgFile = self.__getUserConfig() cfgDir = os.path.dirname(cfgFile) if not cfgDir: E5MessageBox.critical( None, self.tr("Edit Configuration"), self.tr("""No valid configuartion path determined.""" """ Is a virtual environment selected? Aborting""")) return try: if not os.path.isdir(cfgDir): os.makedirs(cfgDir) except OSError: E5MessageBox.critical( None, self.tr("Edit Configuration"), self.tr("""No valid configuartion path determined.""" """ Is a virtual environment selected? Aborting""")) return if not os.path.exists(cfgFile): try: f = open(cfgFile, "w") f.write("[global]\n") f.close() except (IOError, OSError): # ignore these pass # check, if the destination is writeable if not os.access(cfgFile, os.W_OK): E5MessageBox.critical( None, self.tr("Edit Configuration"), self.tr("""No valid configuartion path determined.""" """ Is a virtual environment selected? Aborting""")) return self.__editor = MiniEditor(cfgFile, "Properties") self.__editor.show()
def on_editorButton_clicked(self): """ Private slot to open the user configuration file in a text editor. """ from QScintilla.MiniEditor import MiniEditor cfgFile = getConfigPath() yes = E5MessageBox.yesNo( self, self.tr("Edit User Configuration"), self.tr("""You will loose all changes made in this dialog.""" """ Shall the data be saved first?"""), icon=E5MessageBox.Warning, yesDefault=True) if yes: self.writeUserConfig() self.__editor = MiniEditor(cfgFile, "Properties", self) self.__editor.setWindowModality(Qt.WindowModal) self.__editor.installEventFilter(self) self.__editor.show()
def on_configButton_clicked(self): """ Private slot to edit the (per user) Mercurial configuration file. """ from QScintilla.MiniEditor import MiniEditor cfgFile = self.__plugin.getConfigPath() if not os.path.exists(cfgFile): from ..HgUserConfigDataDialog import HgUserConfigDataDialog dlg = HgUserConfigDataDialog() if dlg.exec_() == QDialog.Accepted: firstName, lastName, email, extensions, extensionsData = \ dlg.getData() else: firstName, lastName, email, extensions, extensionsData = ( "Firstname", "Lastname", "email_address", [], {}) try: f = open(cfgFile, "w") f.write("[ui]\n") f.write("username = {0} {1} <{2}>\n".format( firstName, lastName, email)) if extensions: f.write("\n[extensions]\n") f.write(" =\n".join(extensions)) f.write(" =\n") # complete the last line if "largefiles" in extensionsData: dataDict = extensionsData["largefiles"] f.write("\n[largefiles]\n") if "minsize" in dataDict: f.write("minsize = {0}\n".format(dataDict["minsize"])) if "patterns" in dataDict: f.write("patterns =\n") f.write(" {0}\n".format("\n ".join( dataDict["patterns"]))) f.close() except (IOError, OSError): # ignore these pass editor = MiniEditor(cfgFile, "Properties", self) editor.show()
def __editUserConfiguration(self): """ Private slot to edit the user configuration. """ from QScintilla.MiniEditor import MiniEditor cfgFile = CondaInterface.userConfiguration() if not cfgFile: return if not os.path.exists(cfgFile): self.__conda.writeDefaultConfiguration() # check, if the destination is writeable if not os.access(cfgFile, os.W_OK): E5MessageBox.critical( None, self.tr("Edit Configuration"), self.tr("""The configuration file "{0}" does not exist""" """ or is not writable.""")) return self.__editor = MiniEditor(cfgFile, "YAML") self.__editor.show()