Exemplo n.º 1
0
def _meta_dir(obj, meta=None):
    filepath = _meta_path(obj)
    if meta:
        with open(filepath, 'wb') as f:
            pickle.dump(meta, f)
        return

    try:
        with open(filepath, 'rb') as f:
            meta = pickle.load(f)
        return meta
    except:
        return {}
Exemplo n.º 2
0
def save(obj, path_or_buffer):
    if isinstance(path_or_buffer, str):
        f = open(str, 'wb')
    else:
        f = path_or_buffer

    try:
        return pickle.dump(obj, f, protocol=pickle.HIGHEST_PROTOCOL)
    finally:
        f.close()
Exemplo n.º 3
0
def _save_meta(obj, name, path):
    with open(os.path.join(path, name), 'wb') as f:
        pickle.dump(obj, f)
Exemplo n.º 4
0
 def save_keys(self):
     if not self.autosave:
         return
     with open(self.keys_fn, 'wb') as f:
         pickle.dump(self._keys, f)
Exemplo n.º 5
0
 def save(self):
     with closing(self.get_fp('wb')) as f:
         pickle.dump(self, f)
Exemplo n.º 6
0
 def save(self):
     with open(self.filepath, 'wb') as f:
         pickle.dump(self.cache, f)
Exemplo n.º 7
0
 def save(self):
     with closing(self.get_fp('wb')) as f:
         pickle.dump(self, f)
Exemplo n.º 8
0
 def save(self):
     with open(self.filepath, 'wb') as f:
         pickle.dump(self.cache, f)
Exemplo n.º 9
0
def _save_meta(obj, name, path):
    with open(os.path.join(path, name), 'wb') as f:
        pickle.dump(obj, f)
Exemplo n.º 10
0
 def save_keys(self):
     if not self.autosave:
         return
     with open(self.keys_fn, 'wb') as f:
         pickle.dump(self._keys, f)