comparison env/lib/python3.7/site-packages/planemo/database/factory.py @ 0:26e78fe6e8c4 draft

"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author shellac
date Sat, 02 May 2020 07:14:21 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:26e78fe6e8c4
1 """Create a DatabaseSource from supplied planemo configuration."""
2 from galaxy.tool_util.deps.commands import which
3
4 from .postgres import LocalPostgresDatabaseSource
5 from .postgres_docker import DockerPostgresDatabaseSource
6
7
8 def create_database_source(**kwds):
9 """Return a :class:`planemo.database.DatabaseSource` for configuration."""
10 database_type = kwds.get("database_type", "auto")
11 if database_type == "auto":
12 if which("psql"):
13 database_type = "postgres"
14 elif which("docker"):
15 database_type = "postgres_docker"
16 else:
17 raise Exception("Cannot find executables for psql or docker, cannot configure a database source.")
18
19 if database_type == "postgres":
20 return LocalPostgresDatabaseSource(**kwds)
21 elif database_type == "postgres_docker":
22 return DockerPostgresDatabaseSource(**kwds)
23 # TODO
24 # from .sqlite import SqliteDatabaseSource
25 # elif database_type == "sqlite":
26 # return SqliteDatabaseSource(**kwds)
27 else:
28 raise Exception("Unknown database type [%s]." % database_type)
29
30
31 __all__ = (
32 "create_database_source",
33 )