I have my code here that reads my config file:
def getConfig(env):
pwd=os.getcwd()
if "win" in (platform.system().lower()):
f = open(pwd+"\config_"+env.lower()+"_dataset2.json")
else:
f = open(pwd+"/config_"+env.lower()+"_dataset2.json")
config = json.load(f)
f.close()
return config
The thing is, I want it to read my other config file as well but I don't know how to incorporate it in the original code above. I know something like this won't work:
def getConfig(env):
pwd=os.getcwd()
if "win" in (platform.system().lower()):
f = open(pwd+"\config_"+env.lower()+"_dataset2.json")
else:
f = open(pwd+"/config_"+env.lower()+"_dataset2.json")
if "win" in (platform.system().lower()):
f = open(pwd+"\config_"+env.lower()+"_dataset1.json")
else:
f = open(pwd+"/config_"+env.lower()+"_dataset1.json")
config = json.load(f)
f.close()
return config
I'm stuck on having the option to run both config files at once, or just run dataset1.json individually, or just run dataset2.json individually.
Maybe something like:
dataset2=config_"+env.lower()+"_dataset2.json
dataset1=config_"+env.lower()+"_dataset1.json
if dataset2:
f = open(pwd+"\config_"+env.lower()+"_dataset2.json")....
@staticmethod
def getConfig(env):
pwd=os.getcwd()
env = env.lower()
with open(os.path.join(pwd, f"config_{env}_dataset2.json")) as f:
config2 = json.load(f)
with open(os.path.join(pwd, f"config_{env}_dataset1.json")) as f:
config1 = json.load(f)
return config2, config1
config2, config1 = getConfig(env)
TypeError: 'staticmethod' object is not callable