예제 #1
0
 def store(self, tree):
     with open(os.path.join(STORAGE_DIR, tree.id), 'w') as f:
         f.write(
             LocalStorageCipher.encrypt(
                 tree.json
                 )
             )
예제 #2
0
 def get(self, x):
     if x in self._cache:
         return self._cache[x]
     elif os.path.exists(os.path.join(STORAGE_DIR, x)):
         with open(os.path.join(STORAGE_DIR, x), 'r') as f:
             tree = Tree(
                 json.loads(
                     LocalStorageCipher.decrypt(
                         f.read()
                         )
                     )
                 )
         self._cache[x] = tree
         return tree
     else:
         self[x] = Tree()
         return self[x]