[closes #203] events can be saved as pickle now, not intended to save back event notes to notes.txt file as it is only used for automatically generated event folders
This commit is contained in:
parent
9aba69686d
commit
0717f491aa
36
QtPyLoT.py
36
QtPyLoT.py
@ -2392,8 +2392,12 @@ class Event(object):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_notes(self):
|
def get_notes_path(self):
|
||||||
notesfile = os.path.join(self.path, 'notes.txt')
|
notesfile = os.path.join(self.path, 'notes.txt')
|
||||||
|
return notesfile
|
||||||
|
|
||||||
|
def get_notes(self):
|
||||||
|
notesfile = self.get_notes_path()
|
||||||
if os.path.isfile(notesfile):
|
if os.path.isfile(notesfile):
|
||||||
with open(notesfile) as infile:
|
with open(notesfile) as infile:
|
||||||
text = '[eventInfo: '+str(infile.readlines()[0].split('\n')[0])+']'
|
text = '[eventInfo: '+str(infile.readlines()[0].split('\n')[0])+']'
|
||||||
@ -2455,6 +2459,36 @@ class Event(object):
|
|||||||
def getAutopicks(self):
|
def getAutopicks(self):
|
||||||
return self.autopicks
|
return self.autopicks
|
||||||
|
|
||||||
|
def save(self, filename):
|
||||||
|
'''
|
||||||
|
Save PyLoT Event to a file.
|
||||||
|
Can be loaded by using event.load(filename).
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
import cPickle
|
||||||
|
except ImportError:
|
||||||
|
import _pickle as cPickle
|
||||||
|
|
||||||
|
try:
|
||||||
|
outfile = open(filename, 'wb')
|
||||||
|
cPickle.dump(self, outfile, -1)
|
||||||
|
except Exception as e:
|
||||||
|
print('Could not pickle PyLoT event. Reason: {}'.format(e))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def load(filename):
|
||||||
|
'''
|
||||||
|
Load project from filename.
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
import cPickle
|
||||||
|
except ImportError:
|
||||||
|
import _pickle as cPickle
|
||||||
|
infile = open(filename, 'rb')
|
||||||
|
event = cPickle.load(infile)
|
||||||
|
print('Loaded %s' % filename)
|
||||||
|
return event
|
||||||
|
|
||||||
|
|
||||||
class getExistingDirectories(QFileDialog):
|
class getExistingDirectories(QFileDialog):
|
||||||
'''
|
'''
|
||||||
|
@ -1 +1 @@
|
|||||||
053c-dirty
|
9aba-dirty
|
||||||
|
Loading…
Reference in New Issue
Block a user