Ejemplo n.º 1
0
    def saveFile(self,
                 fileName=None,
                 startDir=None,
                 suggestedFileName='flowchart.fc'):
        if fileName is None:
            if startDir is None:
                startDir = self.filePath
            if startDir is None:
                startDir = '.'
            fname = QtGui.QFileDialog.getSaveFileName(
                self.parent,
                caption="Save Flowchart As...",
                directory=startDir,
                filter="Flowchart (*.fc)")[0]
            if fname:
                fileName = fname
            else:
                return

        logger.info('saving file [{0}]'.format(fileName))

        fileName = unicode(fileName)
        if os.path.splitext(fileName)[1] != '.fc':
            fileName += u'.fc'
        try:
            configfile.writeConfigFile(self.saveState(), fileName)
        except Exception, err:
            logger.error('Failed to Save file [{0}]'.format(fileName),
                         exc_info=True)
            ErrorPopupMessagBox(
                self.parent, "Save Flowchart",
                'Cannot save flowchart to file <i>{0}</i>'.format(fileName))
            return
Ejemplo n.º 2
0
 def save(self):
     filename = pg.QtWidgets.QFileDialog.getSaveFileName(
         self, "Save State..", "untitled.cfg", "Config Files (*.cfg)")
     if isinstance(filename, tuple):
         filename = filename[0]  # Qt4/5 API difference
     if filename == '':
         return
     state = self.params.saveState()
     configfile.writeConfigFile(state, str(filename))
def test_longArrays(tmpdir):
    """
    Test config saving and loading of long arrays.
    """
    arr = np.arange(20)

    tf = tmpdir.join("config.cfg")
    configfile.writeConfigFile({'arr': arr}, tf)
    config = configfile.readConfigFile(tf)
    assert all(config['arr'] == arr)
Ejemplo n.º 4
0
def test_longArrays():
    """
    Test config saving and loading of long arrays.
    """
    tmp = tempfile.mktemp(".cfg")

    arr = np.arange(20)
    configfile.writeConfigFile({'arr': arr}, tmp)
    config = configfile.readConfigFile(tmp)

    assert all(config['arr'] == arr)

    os.remove(tmp)
Ejemplo n.º 5
0
 def saveFile(self, fileName=None, startDir=None, suggestedFileName='flowchart.fc'):
     """save the current prototxt file"""
     if fileName is None:
         if startDir is None:
             startDir = self.filePath
         if startDir is None:
             startDir = '.'
         self.fileDialog = FileDialog(None, "Save Flowchart..", startDir, "Flowchart (*.fc)")
         self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
         self.fileDialog.show()
         self.fileDialog.fileSelected.connect(self.saveFile)
         return
     fileName = unicode(fileName)
     configfile.writeConfigFile(self.saveState(), fileName)
     self.sigFileSaved.emit(fileName)
def test_multipleParameters(tmpdir):
    """
    Test config saving and loading of multiple parameters.
    """

    par1 = [1, 2, 3]
    par2 = "Test"
    par3 = {'a': 3, 'b': 'c'}

    tf = tmpdir.join("config.cfg")
    configfile.writeConfigFile({'par1': par1, 'par2': par2, 'par3': par3}, tf)
    config = configfile.readConfigFile(tf)

    assert config['par1'] == par1
    assert config['par2'] == par2
    assert config['par3'] == par3
Ejemplo n.º 7
0
 def saveFile(self, fileName=None, startDir=None, suggestedFileName='flowchart.fc'):
     if fileName is None:
         if startDir is None:
             startDir = self.filePath
         if startDir is None:
             startDir = '.'
         self.fileDialog = pg.FileDialog(None, "Save Flowchart..", startDir, "Flowchart (*.fc)")
         #self.fileDialog.setFileMode(QtGui.QFileDialog.AnyFile)
         self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave) 
         #self.fileDialog.setDirectory(startDir)
         self.fileDialog.show()
         self.fileDialog.fileSelected.connect(self.saveFile)
         return
         #fileName = QtGui.QFileDialog.getSaveFileName(None, "Save Flowchart..", startDir, "Flowchart (*.fc)")
     configfile.writeConfigFile(self.saveState(), fileName)
     self.sigFileSaved.emit(fileName)
Ejemplo n.º 8
0
 def saveFile(self, fileName=None, startDir=None, suggestedFileName='flowchart.fc'):
     if fileName is None:
         if startDir is None:
             startDir = self.filePath
         if startDir is None:
             startDir = '.'
         self.fileDialog = pg.FileDialog(None, "Save Flowchart..", startDir, "Flowchart (*.fc)")
         #self.fileDialog.setFileMode(QtGui.QFileDialog.AnyFile)
         self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave) 
         #self.fileDialog.setDirectory(startDir)
         self.fileDialog.show()
         self.fileDialog.fileSelected.connect(self.saveFile)
         return
         #fileName = QtGui.QFileDialog.getSaveFileName(None, "Save Flowchart..", startDir, "Flowchart (*.fc)")
     configfile.writeConfigFile(self.saveState(), fileName)
     self.sigFileSaved.emit(fileName)
Ejemplo n.º 9
0
    def saveBakFile(self):
        if not GlobalOptions.save_bak:
            return
        fname = self.currentFileName()
        if fname is None:
            # save in pygwa root folder
            bakname = os.path.join(os.path.dirname(__file__), '../', 'unsaved_flowchart.fc.bak')
        else:
            #save to current file folder
            bakname = fname+'.bak'

        bakname = os.path.abspath(bakname)
        try:
            configfile.writeConfigFile(self.win.fc.saveState(), bakname)
        except Exception, e:
            if GlobalOptions.notify_on_savebak_error:
                ErrorPopupMessagBox(self.win, 'Save Backup File', 'Cannot save backup file at <i>{0}</i>'.format(bakname))
                return
Ejemplo n.º 10
0
def test_multipleParameters():
    """
    Test config saving and loading of multiple parameters.
    """
    tmp = tempfile.mktemp(".cfg")

    par1 = [1, 2, 3]
    par2 = "Test"
    par3 = {'a': 3, 'b': 'c'}

    configfile.writeConfigFile({'par1': par1, 'par2': par2, 'par3': par3}, tmp)
    config = configfile.readConfigFile(tmp)

    assert config['par1'] == par1
    assert config['par2'] == par2
    assert config['par3'] == par3

    os.remove(tmp)
Ejemplo n.º 11
0
    def saveBakFile(self):
        if not GlobalOptions.save_bak:
            return
        fname = self.currentFileName()
        if fname is None:
            # save in pygwa root folder
            bakname = os.path.join(os.path.dirname(__file__), '../',
                                   'unsaved_flowchart.fc.bak')
        else:
            #save to current file folder
            bakname = fname + '.bak'

        bakname = os.path.abspath(bakname)
        try:
            configfile.writeConfigFile(self.win.fc.saveState(), bakname)
        except Exception, e:
            if GlobalOptions.notify_on_savebak_error:
                ErrorPopupMessagBox(
                    self.win, 'Save Backup File',
                    'Cannot save backup file at <i>{0}</i>'.format(bakname))
                return
Ejemplo n.º 12
0
    def saveFile(self, fileName=None, startDir=None, suggestedFileName='flowchart.fc'):
        if fileName is None:
            if startDir is None:
                startDir = self.filePath
            if startDir is None:
                startDir = '.'
            fname = QtGui.QFileDialog.getSaveFileName(self.parent, caption="Save Flowchart As...", directory=startDir, filter="Flowchart (*.fc)")[0]
            if fname:
                fileName = fname
            else:
                return

        logger.info('saving file [{0}]'.format(fileName))

        fileName = unicode(fileName)
        if os.path.splitext(fileName)[1] != '.fc':
            fileName += u'.fc'
        try:
            configfile.writeConfigFile(self.saveState(), fileName)
        except Exception, err:
            logger.error('Failed to Save file [{0}]'.format(fileName), exc_info=True)
            ErrorPopupMessagBox(self.parent, "Save Flowchart", 'Cannot save flowchart to file <i>{0}</i>'.format(fileName))
            return
Ejemplo n.º 13
0
 def save(self):
     filename, _ = QtWidgets.QFileDialog.getSaveFileName(self, "Save State..", "untitled.cfg", "Config Files (*.cfg)")
     if not filename:
         return
     state = self.params.saveState()
     configfile.writeConfigFile(state, filename)
Ejemplo n.º 14
0
def write_index(p, index):
    configfile.writeConfigFile(index, p)