From d1ba4d3a6bd007c1c504c9ff1957efc6672fd139 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Wed, 31 Aug 2022 12:02:39 +0300 Subject: Re-add read_from_pyfile * wqflask/wqflask/database.py (read_from_pyfile): Re-add it. This is used in the sql_uri() function. --- wqflask/wqflask/database.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'wqflask') 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( -- cgit v1.2.3