1
Fork 0
This commit is contained in:
Jake Howard 2015-12-02 22:39:40 +00:00
parent ba732934d0
commit a9ec77cce0
2 changed files with 5 additions and 2 deletions

View File

@ -1,8 +1,8 @@
import click
from project.utils import get_config
@click.command('config')
@click.argument('key')
def cli(key):
print(get_config(key))
pass

View File

@ -6,9 +6,11 @@ try:
except ImportError:
from yaml import Loader
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
USER_CONFIG_DIR = "~/.dfa.yml"
def get_config_data(filename):
try:
config_file = open(filename)
@ -17,10 +19,11 @@ def get_config_data(filename):
return []
DEFAULT_CONFIG = get_config_data(os.path.join(BASE_DIR, 'config' ,'defaults.yml'))
DEFAULT_CONFIG = get_config_data(os.path.join(BASE_DIR, 'config', 'defaults.yml'))
USER_CONFIG = get_config_data(os.path.expanduser(USER_CONFIG_DIR))
def get_config(key):
if USER_CONFIG and key in USER_CONFIG:
return USER_CONFIG[key]