1
0

Added more tests for user config parsing.

This commit is contained in:
Chris Glass
2014-06-26 11:08:13 +02:00
parent ad3640d7a4
commit 34f0a65c49
2 changed files with 60 additions and 8 deletions

View File

@@ -157,19 +157,22 @@ def read_system_config(path=SYSTEM_CONFIG_PATH):
def read_user_config(path):
"""Parse and store the user config settings in electrum.conf into user_config[]."""
if not path: return
if not path: return {} # Return a dict, since we will call update() on it.
config_path = os.path.join(path, "config")
result = {}
if os.path.exists(config_path):
try:
with open(config_path, "r") as f:
data = f.read()
except IOError:
return
try:
d = ast.literal_eval( data ) #parse raw data from reading wallet file
result = ast.literal_eval( data ) #parse raw data from reading wallet file
except Exception:
print_msg("Error: Cannot read config file.")
return
result = {}
return d
if not type(result) is dict:
return {}
return result