[change] delete old obspy dmt database files, current files unselectable
The metadata files that come from the obspy dmt database are saved in a list. When a new event is opened, the obspy dmt metadata files from the old event are deleted from the inventory (and the new ones are added). The metadata files from the obspy dmt database are now unselectable in the MetadataWidget. The clear inventory function is called when saving the project (otherwise the obspy dmt metadata gets saved and becomes editable). The update_obspy_dmt function is called after the save to get the obspy_dmt_metadata back to continue working after the save.
This commit is contained in:
7
PyLoT.py
7
PyLoT.py
@@ -1978,10 +1978,11 @@ class MainWindow(QMainWindow):
|
||||
self.update_obspy_dmt()
|
||||
|
||||
def update_obspy_dmt(self):
|
||||
self.metadata.clear_inventory()
|
||||
if self.obspy_dmt:
|
||||
invpath = os.path.join(self.get_current_event_path(), 'resp')
|
||||
if not invpath in self.metadata.inventories:
|
||||
self.metadata.add_inventory(invpath)
|
||||
self.metadata.add_inventory(invpath, obspy_dmt_inv = True)
|
||||
# check if directory is empty
|
||||
if os.listdir(invpath):
|
||||
self.init_map_button.setEnabled(True)
|
||||
@@ -3369,6 +3370,7 @@ class MainWindow(QMainWindow):
|
||||
'''
|
||||
Save back project to new pickle file.
|
||||
'''
|
||||
self.metadata.clear_inventory()
|
||||
dlg = QFileDialog(self)
|
||||
fnm = dlg.getSaveFileName(self, 'Create a new project file...', filter='Pylot project (*.plp)')
|
||||
filename = fnm[0]
|
||||
@@ -3383,6 +3385,7 @@ class MainWindow(QMainWindow):
|
||||
self.saveProjectAsAction.setEnabled(True)
|
||||
self.update_status('Saved new project to {}'.format(filename), duration=5000)
|
||||
self.add2recentProjects(filename)
|
||||
self.update_obspy_dmt()
|
||||
return True
|
||||
|
||||
def saveProject(self, new=False):
|
||||
@@ -3395,9 +3398,11 @@ class MainWindow(QMainWindow):
|
||||
self.setDirty(True)
|
||||
return False
|
||||
else:
|
||||
self.metadata.clear_inventory()
|
||||
self.project.parameter = self._inputs
|
||||
self.exportEvents()
|
||||
self.project.save()
|
||||
self.update_obspy_dmt()
|
||||
if not self.project.dirty:
|
||||
self.setDirty(False)
|
||||
self.update_status('Saved back project to file:\n{}'.format(self.project.location), duration=5000)
|
||||
|
||||
Reference in New Issue
Block a user