Commit 2d0b6dcc authored by Giorgos Verigakis's avatar Giorgos Verigakis
Browse files

Move default config paths inside config module

parent 2aa8f6d1
......@@ -73,7 +73,7 @@ import os
from base64 import b64encode
from grp import getgrgid
from optparse import OptionParser
from os.path import abspath, basename, exists, expanduser
from os.path import abspath, basename, exists
from pwd import getpwuid
from sys import argv, exit, stdout
......@@ -89,13 +89,6 @@ from kamaki.config import Config
from kamaki.utils import OrderedDict, print_addresses, print_dict, print_items
# Path to the file that stores the configuration
CONFIG_PATH = expanduser('~/.kamakirc')
# Name of a shell variable to bypass the CONFIG_PATH value
CONFIG_ENV = 'KAMAKI_CONFIG'
_commands = OrderedDict()
......@@ -878,12 +871,10 @@ def main():
exit(0)
if '--config' in args:
config_path = args.grouped['--config'].get(0)
config = Config(args.grouped['--config'].get(0))
else:
config_path = os.environ.get(CONFIG_ENV, CONFIG_PATH)
config = Config(config_path)
config = Config()
for option in args.grouped.get('-o', []):
keypath, sep, val = option.partition('=')
if not sep:
......
......@@ -39,6 +39,12 @@ from ConfigParser import RawConfigParser, NoOptionError, NoSectionError
from .utils import OrderedDict
# Path to the file that stores the configuration
CONFIG_PATH = os.path.expanduser('~/.kamakirc')
# Name of a shell variable to bypass the CONFIG_PATH value
CONFIG_ENV = 'KAMAKI_CONFIG'
HEADER = """
# Kamaki configuration file
"""
......@@ -78,9 +84,9 @@ DEFAULTS = {
class Config(RawConfigParser):
def __init__(self, path=None):
RawConfigParser.__init__(self, dict_type=OrderedDict)
self.path = path
self.path = path or os.environ.get(CONFIG_ENV, CONFIG_PATH)
self._overrides = defaultdict(dict)
self.read(path)
self.read(self.path)
def sections(self):
return DEFAULTS.keys()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment