implement PickleContainer

This commit is contained in:
Martin Baeuml
2011-05-13 14:48:03 +02:00
parent f5a585f78f
commit d133981a87
+19
View File
@@ -1,6 +1,10 @@
import os
import fnmatch
from core.exceptions import ImproperlyConfigured
try:
import cPickle as pickle
except:
import pickle
class AnnotationContainerFactory:
def __init__(self, containers):
@@ -95,3 +99,18 @@ class AnnotationContainer:
num += len(frame['annotations'])
return num
class PickleContainer(AnnotationContainer):
"""
Simple container which just pickles the annotations to disk.
"""
def load(self, fname):
f = open(fname, "rb")
self.annotations_ = pickle.load(f)
self.filename_ = fname
def save(self, fname):
f = open(fname, "wb")
pickle.dump(self.annotations(), f)
self.filename_ = fname