Merge branch 'add-save' into develop

This commit is contained in:
Sebastian Wehling-Benatelli 2014-12-18 13:35:23 +01:00
commit f5ab88909f
3 changed files with 16 additions and 4 deletions

View File

@ -143,18 +143,25 @@ class MainWindow(QMainWindow):
filt = """Supported event formats (*.mat *.qml *.xml *.kor
*.evt)"""
caption = 'Select event to open'
fname = QFileDialog().getOpenFileName(self, caption=caption,
self.fname = QFileDialog().getOpenFileName(self, caption=caption,
filter=filt)
else:
fname = unicode(action.data().toString())
self.fname = unicode(action.data().toString())
if not self.okToContinue():
return
else:
return
if fname:
self.data = Data(evtdata=fname)
self.fname = fname
self.data = Data(evtdata=self.fname)
def saveData(self):
settings = QSettings()
exform = settings.value('data/exportFormat', 'None')
try:
self.data.exportEvent(self.fname, exform)
except FormatError:
return False
return True
def getComponent(self):

View File

@ -7,6 +7,7 @@ from obspy.core import (read, Stream)
from obspy import readEvents
from obspy.core.event import (Event, Catalog)
from pylot.core.util import fnConstructor
from pylot.core.util.errors import FormatError
class Data(object):
@ -71,7 +72,8 @@ class Data(object):
from pylot.core.util.defaults import OUTPUTFORMATS
if evtformat.strip() not in OUTPUTFORMATS.values():
evtformat = OUTPUTFORMATS.values()[0]
errmsg = 'selected format {0} not available'.format(evtformat)
raise FormatError(errmsg)
if fnout is None:
ID = self.evtdata.getEventID()

View File

@ -8,3 +8,6 @@ Created on Thu Mar 20 09:47:04 2014
class OptionsError(Exception):
pass
class FormatError(Exception):
pass