def set(self, key, data): filename = path.join(self.directory, '%s' % make_md5(self.V, key)) f = open(filename, 'wb') try: f.write(pickle.dumps(data)) finally: f.close()
def maybe_pickle(value): """Pickle the given value if it is not a string.""" if not isinstance(value, basestring): return pickle.dumps(value) return value
def maybe_pickle(value): """Pickle the given value if it is not a string.""" if not isinstance(value, str): return pickle.dumps(value) return value