aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2022-08-31 12:02:39 +0300
committerBonfaceKilz2022-08-31 12:06:57 +0300
commitd1ba4d3a6bd007c1c504c9ff1957efc6672fd139 (patch)
tree83f6ec63a1febdd6754c73f2d2970c23c1c695c0
parent33fd250d57fd8fa68a6241aa8c0ab3e477a7a515 (diff)
downloadgenenetwork2-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.py8
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(