Browse Source

添加全局环境加载调用函数

dongzhaorui 1 năm trước cách đây
mục cha
commit
2d1a04c1d5
1 tập tin đã thay đổi với 11 bổ sung0 xóa
  1. 11 0
      FworkSpider/feapder/utils/tools.py

+ 11 - 0
FworkSpider/feapder/utils/tools.py

@@ -2587,3 +2587,14 @@ def import_cls(cls_info):
     module, class_name = cls_info.rsplit(".", 1)
     cls = importlib.import_module(module).__getattribute__(class_name)
     return cls
+
+
+def load_globals(*module_name):
+    global_dict = globals()
+    module_vars = dir(module_name)
+    for var_name in module_vars:
+        if not var_name.startswith('__'):
+            var_value = getattr(module_name, var_name)
+            global_dict[var_name] = var_value
+
+    return global_dict