Ejemplo n.º 1
0
 def getPreview(self, params):
     """Preview of data files."""
     try:
         f = open(params.filename, "rb")
         data = f.read()
         f.close()
     except EnvironmentError, e:
         return _("Cannot read file (%s)") % utils.decodeDefault(e.strerror), False
Ejemplo n.º 2
0
 def getPreview(self, params):
     """Preview of data files."""
     try:
         f = open(params.filename, "rb")
         data = f.read()
         f.close()
     except EnvironmentError, e:
         return _("Cannot read file (%s)") % utils.decodeDefault(
             e.strerror), False
Ejemplo n.º 3
0
    def doImport(self, params):
        """Import the data."""

        name = params.field_results["name"].strip()
        if not name:
            raise ImportPluginException(_("Please provide a name for the dataset"))

        try:
            f = open(params.filename, "rb")
            f.seek( params.field_results["offset"] )
            retn = f.read()
            f.close()
        except EnvironmentError, e:
            raise ImportPluginException(_("Error while reading file '%s'\n\n%s") %
                                        (params.filename, utils.decodeDefault(e.strerror)))
Ejemplo n.º 4
0
 def slotLoadStyleSheet(self):
     """Load a style sheet."""
     filename = self.parent()._fileOpenDialog('vst', _('Veusz stylesheet'),
                                              _('Load stylesheet'))
     if filename:
         try:
             self.loadStyleSheet(filename)
         except EnvironmentError, e:
             qt4.QMessageBox.critical(
                 self, _("Error - Veusz"),
                 _("Unable to load '%s'\n\n%s") %
                 (filename, utils.decodeDefault(e.strerror)))
         else:
             # add to recent file list
             self.recentButton.addFile(filename)
Ejemplo n.º 5
0
 def slotLoadStyleSheet(self):
     """Load a style sheet."""
     filename = self.parent()._fileOpenDialog(
         'vst', _('Veusz stylesheet'), _('Load stylesheet'))
     if filename:
         try:
             self.loadStyleSheet(filename)
         except EnvironmentError, e:
             qt4.QMessageBox.critical(
                 self, _("Error - Veusz"),
                 _("Unable to load '%s'\n\n%s") % (
                     filename, utils.decodeDefault(e.strerror)))
         else:
             # add to recent file list
             self.recentButton.addFile(filename)
Ejemplo n.º 6
0
    def slotSaveStyleSheet(self):
        """Save stylesheet as a file."""

        filename = self.parent()._fileSaveDialog('vst', _('Veusz stylesheet'),
                                                 _('Save stylesheet'))
        if filename:
            try:
                f = open(filename, 'w')
                self.document.exportStyleSheet(f)
                f.close()
                self.recentButton.addFile(filename)

            except EnvironmentError, e:
                qt4.QMessageBox.critical(
                    self, _("Error - Veusz"),
                    _("Unable to save '%s'\n\n%s") %
                    (filename, utils.decodeDefault(e.strerror)))
Ejemplo n.º 7
0
    def slotSaveStyleSheet(self):
        """Save stylesheet as a file."""
    
        filename = self.parent()._fileSaveDialog(
            'vst', _('Veusz stylesheet'), _('Save stylesheet'))
        if filename:
            try:
                f = open(filename, 'w')
                self.document.exportStyleSheet(f)
                f.close()
                self.recentButton.addFile(filename)

            except EnvironmentError, e:
                qt4.QMessageBox.critical(
                    self, _("Error - Veusz"),
                    _("Unable to save '%s'\n\n%s") % (
                        filename, utils.decodeDefault(e.strerror)))
Ejemplo n.º 8
0
    def doImport(self, params):
        """Import the data."""

        name = params.field_results["name"].strip()
        if not name:
            raise ImportPluginException(
                _("Please provide a name for the dataset"))

        try:
            f = open(params.filename, "rb")
            f.seek(params.field_results["offset"])
            retn = f.read()
            f.close()
        except EnvironmentError, e:
            raise ImportPluginException(
                _("Error while reading file '%s'\n\n%s") %
                (params.filename, utils.decodeDefault(e.strerror)))