Example #1
0
 def __guardar_como(self):
     """Abre un diálogo pidiendo el nombre de archivo y guarda en dicho archivo"""
     filtro = ""
     for fmt in SL.extensiones_fichero:
         filtro = filtro+ "%s files (*.%s);;" % (fmt, fmt.lower())
     filename = QFileDialog.getSaveFileName(QString.null, filtro, self)
     filename = str(filename)
     if filename:
         from Driza.excepciones import FicheroExisteException, FicheroTipoDesconocidoException
         import re
         extension = re.compile('.*\..*')
         if not extension.match(filename):
             filename += ".driza"
         try:
             self.__gestorproyectos.guardar(filename)
         except FicheroExisteException, fichero:
             returncode = QMessageBox.information(self, 'Atencion:', 'El fichero' + fichero.fichero + ' ya existe' , 'Sobreescribir', 'Otro nombre', 'Cancelar', 0, 1)
             if returncode == 0:
                 self.__gestorproyectos.guardar(filename, True)
                 self.__idu.establecer_original()
                 self.__myUpdate()
             elif returncode == 1:
                 self.__guardarcomo()
         except FicheroTipoDesconocidoException:
             QMessageBox.warning(self, u'Atención', u'La extensión del fichero es incorrecta.\nPruebe con otra extensión')
             self.__gestorproyectos.fichero = None
Example #2
0
 def __dexportar(self):
     """Pregunta al usuario en que fichero exportar"""
     filterlist = ""
     for fmt in ["html"]: #Candidata al fichero de listas
         filterlist = filterlist + "%s files (*.%s);;" % (fmt, fmt.lower())
     nombrefichero = QFileDialog.getSaveFileName(QString.null, filterlist, self)
     filename = str(nombrefichero)
     if filename:
         self.__exportar(filename)
Example #3
0
    def getFileHandleFromDialog(self):
        """ Returns a file handle to the selected file. """

        fileName = unicode(
            QFileDialog.getSaveFileName("", "All Files (*)", self.wizardView,
                                        "Save file dialog",
                                        "Choose a file name"))
        fileHandle = None
        if fileName:
            try:
                fileHandle = open(fileName, "rb")
            except IOError:
                fileHandle = None
        return fileHandle
Example #4
0
    def exportDatamodelSlot(self):
        """ Exports the current data model to the local file system. """

        proposedName = "datamodel.xml"
        targetFilePath = unicode(QFileDialog.getSaveFileName(os.path.join(self._lastUploadDirectory, proposedName),
                                                              "*.xml", self, "Export data model...", "Choose a file" ))
        if len(targetFilePath) > 0:
            self._lastUploadDirectory = os.path.dirname(targetFilePath)
            try:
                self.repositoryConfiguration.exportDatamodel(targetFilePath)
            except ConfigurationError, error:
                self.__showErrorMessage("Cannot export data model to '%s'. Reason: '%s'" % (targetFilePath, error.message))
            else:
                self.__logger.info("Successfully exported the current data model to '%s'." % targetFilePath)
Example #5
0
    def exportDataStoresSlot(self):
        """ Exports the current data model to the local file system. """

        proposedName = "datastores.xml"
        targetFilePath = unicode(
            QFileDialog.getSaveFileName(
                os.path.join(self._lastUploadDirectory, proposedName), "*.xml",
                self, "Export data store configuration...", "Choose a file"))
        if len(targetFilePath) > 0:
            self._lastUploadDirectory = os.path.dirname(targetFilePath)
            try:
                self.repositoryConfiguration.exportDataStores(targetFilePath)
            except ConfigurationError, error:
                self.__showErrorMessage("Cannot export data store configuration to '%s'. \nReason: '%s'" \
                                        % (targetFilePath, error.message))
            else:
                self.__logger.info(
                    "Successfully exported the current data store configurations to '%s'."
                    % targetFilePath)
Example #6
0
 def __dguardarfichero(self):
     """Pregunta al usuario en que fichero guardar"""
     filterlist = ""
     for fmt in ["dro"]: #Candidata al fichero de listas
         filterlist = filterlist + "%s files (*.%s);;" % (fmt, fmt.lower())
     nombrefichero = QFileDialog.getSaveFileName(QString.null, filterlist, self)
     filename = str(nombrefichero)
     if filename:
         from Driza.excepciones import FicheroExisteException, \
                 FicheroTipoDesconocidoException
         try:
             self.__gestorsalida.guardar(self.__contenido, filename)
         except FicheroExisteException,fichero:
             codigoretorno = QMessageBox.information(self, 'Atencion:', 'El fichero' +\
                     fichero.fichero + ' ya existe' , 'Sobreescribir', \
                     'Otro nombre', 'Cancelar', 0, 1)
             if codigoretorno == 0:
                 self.__gestorsalida.guardar(self.__contenido, filename, True)
             elif codigoretorno == 1:
                 self.__dguardarfichero()
         except FicheroTipoDesconocidoException:
             QMessageBox.warning(self, u'Atención', \
                     u'La extensión del fichero es incorrecta.\nPruebe con otra extensión')
Example #7
0
 def process_save(self):
     file_name, _ = QFileDialog.getSaveFileName(dir='boards')
     with open(file_name, 'w') as f:
         f.write(save_board(self.window.board_widget.board))
Example #8
0
 def getSaveFileName(self, caption, path, filter):
     """
     :rtype: str
     """
     return qt.toUnicode(QFileDialog.getSaveFileName(self, caption, path, filter))