Mercurial > hg > Feedworm
view BackendFactory.py @ 239:a15b3ee791a1
Automated merge with https://xanthippe.duckdns.org/hg/Feedworm
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Sat, 25 Apr 2015 04:10:12 +0200 |
parents | e34c53a3e407 |
children | f79be01821c4 |
line wrap: on
line source
# -*- coding: utf-8 -*- import argparse SQLALCHEMY_BACKEND = "sqlalchemy" COUCHDB_BACKEND = "couchdb" def _parseArguments(): parser = argparse.ArgumentParser() parser.add_argument("--backend", nargs="?", choices=[SQLALCHEMY_BACKEND, COUCHDB_BACKEND], required=True, help="Specify the backend to use: either sqlalchemy or couchdb") return parser.parse_known_args() def createBackend(): args = _parseArguments() backend = args[0].backend if backend == SQLALCHEMY_BACKEND: from backend.sqlalchemy.SqlAlchemyBackend import SqlAlchemyBackend return SqlAlchemyBackend() elif backend == COUCHDB_BACKEND: from backend.couchdb.CouchDbBackend import CouchDbBackend return CouchDbBackend() else: raise Exception("no backend configured")