Esempio n. 1
0
    def __init__(self, user_config=True):

        progpath = dirname(sys.argv[0])

        self.progname = 'cog'
        self.profiles = dict()
        self.store = dict()
        self.cfg_dirs = [pathjoin(dirname(progpath), 'etc', self.progname)]
        if user_config:
            self.make_conf()
            self.cfg_dirs.append(get_app_dir(self.progname, force_posix=True))
        self.cfg_files = [pathjoin(cfg_dir, 'settings')
                          for cfg_dir in self.cfg_dirs if isdir(cfg_dir)]

        self.profiles = merge_data(*self.cfg_files)
        self.current = self.profiles.pop('profile')
        for name, profile in self.profiles.items():
            self.profiles[name] = dict_merge(defaults, profile)
        self.use(self.current)
Esempio n. 2
0
 def __init__(self):
     tmpl_files = []
     for dir in cfg.cfg_dirs:
         tmpl_files.append(pathjoin(dir, 'templates.yaml'))
         tmpl_files += list_files(pathjoin(dir, 'templates.d'))
     self.update(self.expand_inheritances(merge_data(*tmpl_files)))