From dda6b50e4cf3a8f97a80eece23ff41a617987eac Mon Sep 17 00:00:00 2001 From: Mauricio Rojas Fernandez Date: Fri, 27 Sep 2024 16:10:46 -0600 Subject: [PATCH] adding support for loading files into the current scope --- extras/sfutils/sfutils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/extras/sfutils/sfutils.py b/extras/sfutils/sfutils.py index ed535e1..f02cb79 100644 --- a/extras/sfutils/sfutils.py +++ b/extras/sfutils/sfutils.py @@ -18,6 +18,17 @@ def text_input(self, labelOrName,value=None,key=None): return value st = StreamlitMock() +import importlib +import inspect + +def run(module_name): + """ + Loads all the module elements into the current scope + """ + caller_globals = inspect.currentframe().f_back.f_globals + module = importlib.import_module(module_name) + caller_globals.update({k: v for k, v in module.__dict__.items() if not k.startswith('_')}) + class WidgetUtils: def __init__(self):