annotate BackendFactory.py @ 259:304917762618 default tip

implementation of feed updates
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 12 Mar 2019 02:41:22 +0100
parents f79be01821c4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
217
bb3c851b18b1 add source file endcoding header
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 137
diff changeset
1 # -*- coding: utf-8 -*-
137
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
2 import argparse
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3
256
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 233
diff changeset
4 ARANGODB_BACKEND = "arangodb"
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 233
diff changeset
5 COUCHDB_BACKEND = "couchdb"
137
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
6 SQLALCHEMY_BACKEND = "sqlalchemy"
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
7
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
8 def _parseArguments():
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
9 parser = argparse.ArgumentParser()
256
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 233
diff changeset
10 parser.add_argument("--backend", nargs="?", choices=[ARANGODB_BACKEND, COUCHDB_BACKEND, SQLALCHEMY_BACKEND],
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 233
diff changeset
11 required=True, help="Specify the backend to use: either arangodb, couchdb or sqlalchemy")
137
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 return parser.parse_known_args()
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
14 def createBackend():
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
15 args = _parseArguments()
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
16 backend = args[0].backend
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
17 if backend == SQLALCHEMY_BACKEND:
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
18 from backend.sqlalchemy.SqlAlchemyBackend import SqlAlchemyBackend
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
19 return SqlAlchemyBackend()
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
20 elif backend == COUCHDB_BACKEND:
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
21 from backend.couchdb.CouchDbBackend import CouchDbBackend
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
22 return CouchDbBackend()
256
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 233
diff changeset
23 elif backend == ARANGODB_BACKEND:
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 233
diff changeset
24 from backend.arangodb.ArangoBackend import ArangoBackend
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 233
diff changeset
25 return ArangoBackend()
137
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
26 else:
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
27 raise Exception("no backend configured")