1class FoobarDB(object):
2 def __init__(self , location):
3 self.location = os.path.expanduser(location)
4 self.load(self.location)
5
6 def load(self , location):
7 if os.path.exists(location):
8 self._load()
9 else:
10 self.db = {}
11 return True
12
13 def _load(self):
14 self.db = json.load(open(self.location , "r"))
15
16 def dumpdb(self):
17 try:
18 json.dump(self.db , open(self.location, "w+"))
19 return True
20 except:
21 return False