comparison env/lib/python3.7/site-packages/planemo/database/factory.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
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 )