import json
import os


class DataStore(object):
    def __init__(self, storagePath="desertbot_data.json"):
        self.storagePath = storagePath
        self.data = {}
        self.load()

    def load(self):
        if not os.path.exists(self.storagePath):
            self.save()
            return
        with open(self.storagePath) as storageFile:
            self.data = json.load(storageFile)

    def save(self):
        tmpFile = "{}.tmp".format(self.storagePath)
        with open(tmpFile, "w") as storageFile:
            storageFile.write(json.dumps(self.data, indent=4))
        os.rename(tmpFile, self.storagePath)

    def __len__(self):
        return len(self.data)

    def __iter__(self):
        return iter(self.data)

    def __getitem__(self, item):
        return self.data[item]

import json
import os


class DataStore(object):
    def __init__(self, storagePath="desertbot_data.json"):
        self.storagePath = storagePath
        self.data = None
        self.load()

    def load(self):
        if not os.path.exists(self.storagePath):
            self.data = {}
            self.save()
            return
        with open(self.storagePath) as storageFile:
            self.data = json.load(storageFile)

    def save(self):
        tmpFile = "{}.tmp".format(self.storagePath)
        with open(tmpFile, "w") as storageFile:
            storageFile.write(json.dumps(self.data, indent=4))
        os.rename(tmpFile, self.storagePath)

--- 
+++ 
@@ -5,12 +5,11 @@
 class DataStore(object):
     def __init__(self, storagePath="desertbot_data.json"):
         self.storagePath = storagePath
-        self.data = None
+        self.data = {}
         self.load()
 
     def load(self):
         if not os.path.exists(self.storagePath):
-            self.data = {}
             self.save()
             return
         with open(self.storagePath) as storageFile:
@@ -21,3 +20,12 @@
         with open(tmpFile, "w") as storageFile:
             storageFile.write(json.dumps(self.data, indent=4))
         os.rename(tmpFile, self.storagePath)
+
+    def __len__(self):
+        return len(self.data)
+
+    def __iter__(self):
+        return iter(self.data)
+
+    def __getitem__(self, item):
+        return self.data[item]
Allow using DataStore class as if dict
