def loader(): if os.path.exists(file_name): inp = file(file_name) data = json.load(inp) inp.close() return {name: data} else: return {}
def loader(): if os.path.exists(file_name): inp = file(file_name) batch = json.load(inp) inp.close() return batch else: return {}
def change_batch(change, file_name): if os.path.exists(file_name): # read in old data try: inp = file(file_name) batch = json.load(inp) inp.close() except: warn("Couldn't load old data") batch = {} else: batch = {} # apply changes change(batch) # writing back out = file(file_name, 'w') json.dump(batch, out) out.close()
def load_batch(file_name): inp = file(file_name) data = json.load(inp) inp.close() return data