#Settings files load automatically in Settings (look for SettingsUpdate)

dev-linux
Ivan Maslov 5 years ago
parent 35f761736f
commit 60801e8f8c

@ -159,16 +159,19 @@ def Settings():
#Get file list from Settings folder #Get file list from Settings folder
import os import os
import pdb import pdb
#lFunction to call in subfiles
lSubmoduleFunctionName = "SettingsUpdate"
lSettingsPath = os.path.join(os.getcwd(), "Settings") lSettingsPath = os.path.join(os.getcwd(), "Settings")
#pdb.set_trace()
#Lambda function to get files .py from settings folder except Settings.py #Lambda function to get files .py from settings folder except Settings.py
lFileList = [f for f in os.listdir(lSettingsPath) if os.path.isfile(os.path.join(lSettingsPath, f)) and f.split(".")[-1]=="py" and f != "Settings.py"] lFileList = [f for f in os.listdir(lSettingsPath) if os.path.isfile(os.path.join(lSettingsPath, f)) and f.split(".")[-1] == "py" and os.path.join(lSettingsPath, f) != __file__]
#TODO Import files as python module and call SettingsUpdate()
import importlib.util import importlib.util
for lModuleFilePathItem in lFileList for lModuleFilePathItem in lFileList:
spec = importlib.util.spec_from_file_location("module.name", "/path/to/file.py") lModuleName = lModuleFilePathItem[0:-3]
foo = importlib.util.module_from_spec(spec) lFileFullPath = os.path.join(lSettingsPath, lModuleFilePathItem)
#spec.loader.exec_module(foo) lTechSpecification = importlib.util.spec_from_file_location(lModuleName, lFileFullPath)
#foo.MyClass() lTechModuleFromSpec = importlib.util.module_from_spec(lTechSpecification)
#Return Global settings lTechSpecificationModuleLoader = lTechSpecification.loader.exec_module(lTechModuleFromSpec)
if "SettingsUpdate" in dir(lTechModuleFromSpec):
#Run SettingUpdate function in submodule
getattr(lTechModuleFromSpec, lSubmoduleFunctionName)(mDict)
return mDict return mDict

@ -1,2 +1,2 @@
def SettingsUpdate(): def SettingsUpdate(inDict):
print("Everything is ok!") print("Everything is ok!")
Loading…
Cancel
Save