- def _readUserConf(package_name, default=[]):
- # .config
- xdg_config_home = os.getenv('XDG_CONFIG_HOME') or compat_expanduser('~/.config')
- userConfFile = os.path.join(xdg_config_home, package_name, 'config')
- if not os.path.isfile(userConfFile):
- userConfFile = os.path.join(xdg_config_home, '%s.conf' % package_name)
- userConf = Config.read_file(userConfFile, default=None)
- if userConf is not None:
- return userConf, userConfFile
-
- # appdata
- appdata_dir = os.getenv('appdata')
- if appdata_dir:
- userConfFile = os.path.join(appdata_dir, package_name, 'config')
- userConf = Config.read_file(userConfFile, default=None)
- if userConf is None:
- userConfFile += '.txt'
- userConf = Config.read_file(userConfFile, default=None)
- if userConf is not None:
- return userConf, userConfFile
+ def read_config(*paths):
+ path = os.path.join(*paths)
+ conf = Config.read_file(path, default=None)
+ if conf is not None:
+ return conf, path