[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:
Marcel Paffrath 2017-06-19 13:54:43 +02:00
parent 9aba69686d
commit 0717f491aa
2 changed files with 37 additions and 3 deletions

View File

@ -2392,8 +2392,12 @@ class Event(object):
except:
pass
def get_notes(self):
def get_notes_path(self):
notesfile = os.path.join(self.path, 'notes.txt')
return notesfile
def get_notes(self):
notesfile = self.get_notes_path()
if os.path.isfile(notesfile):
with open(notesfile) as infile:
text = '[eventInfo: '+str(infile.readlines()[0].split('\n')[0])+']'
@ -2455,6 +2459,36 @@ class Event(object):
def getAutopicks(self):
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):
'''

View File

@ -1 +1 @@
053c-dirty
9aba-dirty