comparison env/lib/python3.7/site-packages/planemo/database/factory.py @ 2:6af9afd405e9 draft

"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author shellac
date Thu, 14 May 2020 14:56:58 -0400
parents 26e78fe6e8c4
children
comparison
equal deleted inserted replaced
1:75ca89e9b81c 2:6af9afd405e9
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 )