Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/planemo/database/factory.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
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 ) |