]> git.phdru.name Git - bookmarks_db.git/blob - Storage/bkmk_stpickle.py
444cf35c3395d9a851c09284d4e63fe85d90fcc6
[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
7 __author__ = "Oleg Broytman <phd@phdru.name>"
8 __copyright__ = "Copyright (C) 2000-2014 PhiloSoft Design"
9 __license__ = "GNU GPL"
10
11 __all__ = ['storage_pickle']
12
13
14 try:
15    import cPickle
16    pickle = cPickle
17
18 except ImportError:
19    import pickle
20
21
22 class storage_pickle(object):
23    filename = "bookmarks_db.pickle"
24
25    def store(self, root_folder):
26       outfile = open(self.filename, 'wb')
27       pickle.dump(root_folder, outfile, 1)
28       outfile.close()
29
30    def load(self):
31       infile = open(self.filename, 'rb')
32       root_folder = pickle.load(infile)
33       infile.close()
34
35       return root_folder