view BackendFactory.py @ 258:4ca1fac32dde

Pull the constant of days to keep feed entries into the abstract class
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 12 Mar 2019 02:39:18 +0100
parents f79be01821c4
children
line wrap: on
line source

# -*- coding: utf-8 -*-
import argparse

ARANGODB_BACKEND = "arangodb"
COUCHDB_BACKEND = "couchdb"
SQLALCHEMY_BACKEND = "sqlalchemy"

def _parseArguments():
    parser = argparse.ArgumentParser()
    parser.add_argument("--backend", nargs="?", choices=[ARANGODB_BACKEND, COUCHDB_BACKEND, SQLALCHEMY_BACKEND],
        required=True, help="Specify the backend to use: either arangodb, couchdb or sqlalchemy")
    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()
    elif backend == ARANGODB_BACKEND:
        from backend.arangodb.ArangoBackend import ArangoBackend
        return ArangoBackend()
    else:
        raise Exception("no backend configured")