def get_backend_factory(uri, config): """get_backend_factory(uri, config) Parses a URI and creates the factory. TODO: crypto stuff are added by magic, and only s3 is supported. This should be configurable """ type,ident = uri.split(':',1) if type == 's3': ret = lambda: s3backend.S3Backend(ident, config.to_dict()) elif type == 'dir': ret = lambda: directorybackend.DirectoryBackend(ident, config.to_dict()) else: raise NotImplementedError('backend type %s not implemented' % (type)) crypto_key = config.get_option('crypto-key').get_required() hash = config.get_option('hash').get_required() if True: ret2 = lambda: gpgcrypto.DataCryptoGPG(ret(), crypto_key) else: ret2 = ret if True: ret3 = lambda: gpgcrypto.NameCrypto(ret2(), crypto_key, hash_algorithm=hash) else: ret3 = ret2 return ret3
def make_backend(self): return directorybackend.DirectoryBackend(self.tempdir)