diff options
author | Munyoki Kilyungi | 2022-08-31 12:02:39 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-08-31 12:06:57 +0300 |
commit | d1ba4d3a6bd007c1c504c9ff1957efc6672fd139 (patch) | |
tree | 83f6ec63a1febdd6754c73f2d2970c23c1c695c0 | |
parent | 33fd250d57fd8fa68a6241aa8c0ab3e477a7a515 (diff) | |
download | genenetwork2-d1ba4d3a6bd007c1c504c9ff1957efc6672fd139.tar.gz |
Re-add read_from_pyfile
* wqflask/wqflask/database.py (read_from_pyfile): Re-add it. This is
used in the sql_uri() function.
-rw-r--r-- | wqflask/wqflask/database.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py index 4b05c926..82a35013 100644 --- a/wqflask/wqflask/database.py +++ b/wqflask/wqflask/database.py @@ -10,6 +10,14 @@ import contextlib import MySQLdb +def read_from_pyfile(pyfile, setting): + orig_sys_path = sys.path[:] + sys.path.insert(0, os.path.dirname(pyfile)) + module = importlib.import_module(os.path.basename(pyfile).strip(".py")) + sys.path = orig_sys_path[:] + return module.__dict__.get(setting) + + def sql_uri(): """Read the SQL_URI from the environment or settings file.""" return os.environ.get( |