]> git.phdru.name Git - bookmarks_db.git/blob - Storage/bkmk_stpickle.py
c4ad32b82ee6c7200db243b1029e9f0403b97a00
[bookmarks_db.git] / Storage / bkmk_stpickle.py
1 """Bookmarks storage manager - pickle; certainly the most simple and elegant :)
2
3 This file is a part of Bookmarks database and Internet robot.
4 """
5
6 __author__ = "Oleg Broytman <phd@phdru.name>"
7 __copyright__ = "Copyright (C) 2000-2012 PhiloSoft Design"
8 __license__ = "GNU GPL"
9
10 __all__ = ['storage_pickle']
11
12
13 try:
14    import cPickle
15    pickle = cPickle
16
17 except ImportError:
18    import pickle
19
20
21 class storage_pickle:
22    filename = "bookmarks_db.pickle"
23
24    def store(self, root_folder):
25       outfile = open(self.filename, 'wb')
26       pickle.dump(root_folder, outfile, 1)
27       outfile.close()
28
29    def load(self):
30       infile = open(self.filename, 'rb')
31       root_folder = pickle.load(infile)
32       infile.close()
33
34       return root_folder