Skip to content

Commit

Permalink
Store initial settings
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljoseph committed Dec 9, 2014
1 parent 3487428 commit ead077d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions changes/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from os.path import exists, join
import io

import click
from giturlparse import parse
from path import path
from plumbum.cmd import git
from plumbum import local
import yaml
Expand Down Expand Up @@ -60,19 +62,14 @@ def parsed_repo(self):
return parse(git('config --get remote.origin.url'.split(' ')))


def project_config(context):
def project_config(module_name):
config = {}
config_path = join(context.module_name, CONFIG_FILE)
config_path = path(join(module_name, CONFIG_FILE))

# initialise config with defaults
if not exists(config_path):
config = DEFAULTS.copy()

with click.open_file(config_path, 'w') as f:
config_yaml = yaml.dump(config, default_flow_style=False)
f.write(config_yaml)
store_settings(module_name, DEFAULTS.copy())

config = yaml.safe_load(click.open_file(config_path))
config = yaml.load(io.open(config_path))
return config or {}


Expand Down

0 comments on commit ead077d

Please sign in to comment.