From f3dfedeb2aa26c797d7f9fe772199c96ee124641 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 3 Dec 2015 22:43:42 +0000 Subject: [PATCH] PEP8 --- project/config/cli.py | 2 +- project/utils/config.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/project/config/cli.py b/project/config/cli.py index 2bceca1..820d805 100644 --- a/project/config/cli.py +++ b/project/config/cli.py @@ -22,7 +22,7 @@ def set(key, value): key = " ".join(key) status = config.set(key, value) if status == "SUCCESS": - print("Repo set to", repo) + print("{} set to {}".format(key, value)) return 0 elif status == "NO_KEY": print("Key {} not found".format(key)) diff --git a/project/utils/config.py b/project/utils/config.py index 5076fb7..77d1aeb 100644 --- a/project/utils/config.py +++ b/project/utils/config.py @@ -11,6 +11,7 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__)) USER_CONFIG_DIR = os.path.expanduser("~/.dfa.yml") DEFAULT_CONFIG_DIR = os.path.join(BASE_DIR, 'defaults.yml') + def get_config_data(filename): try: with open(filename) as config_file: @@ -18,16 +19,18 @@ def get_config_data(filename): except FileNotFoundError: return {} + def write_user_config(refresh_after=False): try: with open(USER_CONFIG_DIR, 'w') as config_file: - dump(USER_CONFIG, config_file, indent=4, default_flow_style=False) + dump(USER_CONFIG, config_file, indent=4, default_flow_style=False, Dumper=Dumper) return "SUCCESS" except Exception as e: return e DEFAULT_CONFIG = get_config_data(DEFAULT_CONFIG_DIR) + USER_CONFIG = get_config_data(os.path.expanduser(USER_CONFIG_DIR)) @@ -38,6 +41,7 @@ def get(key): return DEFAULT_CONFIG[key] return None + def set(key, value, refresh_after=False): if key not in DEFAULT_CONFIG: return "NO_KEY"