Browse Source

don't display an error if the config file does not exist. assume it is JSON

283
ThomasV 9 years ago
parent
commit
34a3af7ca3
  1. 11
      lib/simple_config.py

11
lib/simple_config.py

@ -211,19 +211,14 @@ def read_user_config(path):
if not path: if not path:
return {} return {}
config_path = os.path.join(path, "config") config_path = os.path.join(path, "config")
if not os.path.exists(config_path):
return {}
try: try:
with open(config_path, "r") as f: with open(config_path, "r") as f:
data = f.read() data = f.read()
except IOError:
print_msg("Error: Cannot read config file.", path)
return {}
try:
result = json.loads(data) result = json.loads(data)
except: except:
try: print_msg("Warning: Cannot read config file.", config_path)
result = ast.literal_eval(data)
except:
print_msg("Error: Cannot read config file.")
return {} return {}
if not type(result) is dict: if not type(result) is dict:
return {} return {}

Loading…
Cancel
Save