X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Futils%2Fconfig.py;h=4d8d1127c191511b041169823e2bc8077253ecd7;hb=92860d5ab0d6008fad149eea960de91acd15719a;hp=1dd9567835d6411affbcf963edd6a7b31b4b4107;hpb=5fe20b6caffe162afe5be18e77fe40004d00c95e;p=mpd-sima.git diff --git a/sima/utils/config.py b/sima/utils/config.py index 1dd9567..4d8d112 100644 --- a/sima/utils/config.py +++ b/sima/utils/config.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright (c) 2009, 2010, 2011, 2013 Jack Kaliko +# Copyright (c) 2009, 2010, 2011, 2013, 2014 Jack Kaliko # # This file is part of sima # @@ -36,31 +35,51 @@ from stat import (S_IMODE, ST_MODE, S_IRWXO, S_IRWXG) from . import utils # DEFAULTS -DIRNAME = 'sima' +DIRNAME = 'mpd_sima' CONF_FILE = 'sima.cfg' DEFAULT_CONF = { 'MPD': { 'host': "localhost", - 'password': "false", - 'port': "6600"}, + #'password': "", + 'port': "6600", + }, 'sima': { - 'similarity': "15", - 'dynamic': "10", - 'queue_mode': "track", #TODO control values + 'internal': "Crop, Lastfm, RandomFallBack", + 'contrib': "", 'user_db': "false", 'history_duration': "8", 'queue_length': "1", - 'track_to_add': "1", - 'album_to_add': "1", - 'consume': "0", - 'single_album': "false", - 'check_new_version':"false",}, + }, 'daemon':{ 'daemon': "false", - 'pidfile': "",}, + 'pidfile': "", + }, 'log': { - 'verbosity': "info"}} + 'verbosity': "info", + 'logfile': "", + }, + 'echonest': { + 'queue_mode': "track", #TODO control values + 'max_art': "15", + 'single_album': "false", + 'track_to_add': "1", + 'album_to_add': "1", + 'depth': "1", + }, + 'lastfm': { + 'queue_mode': "track", #TODO control values + 'max_art': "10", + 'single_album': "false", + 'track_to_add': "1", + 'album_to_add': "1", + 'depth': "1", + }, + 'randomfallback': { + 'flavour': "sensible", # in pure, sensible + 'track_to_add': "1", + } + } # @@ -97,6 +116,7 @@ class ConfMan(object): # CONFIG MANAGER CLASS self.init_config() self.control_conf() self.supersedes_config_with_cmd_line_options() + self.config['sima']['db_file'] = self.db_file def get_pw(self): try: @@ -106,11 +126,11 @@ class ConfMan(object): # CONFIG MANAGER CLASS return None except ValueError: # ValueError if password not a boolean, hence an actual password. - pw = self.config.get('MPD', 'password') - if not pw: + pwd = self.config.get('MPD', 'password') + if not pwd: self.log.debug('Password set as an empty string.') return None - return pw + return pwd def control_mod(self): """ @@ -169,8 +189,8 @@ class ConfMan(object): # CONFIG MANAGER CLASS self.log.debug('[%s] present in conf file' % section) for option in self.defaults[section]: if self.config.has_option(section, option): - #self.log.debug(u'option "%s" set to "%s" in conf. file' % - # (option, self.config.get(section, option))) + #self.log.debug('option "%s" set to "%s" in conf. file'% + # (option, self.config.get(section, option))) pass else: self.log.debug( @@ -195,7 +215,7 @@ class ConfMan(object): # CONFIG MANAGER CLASS elif self.startopt.get('var_dir'): # If var folder is provided via CLI set data_dir accordingly data_dir = join(self.startopt.get('var_dir')) - elif (homedir and isdir(homedir) and homedir not in ['/']): + elif homedir and isdir(homedir) and homedir not in ['/']: data_dir = join(homedir, '.local', 'share', DIRNAME) else: self.log.error('Can\'t find a suitable location for data folder (XDG_DATA_HOME)') @@ -211,7 +231,7 @@ class ConfMan(object): # CONFIG MANAGER CLASS pass elif environ.get('XDG_CONFIG_HOME'): conf_dir = join(environ.get('XDG_CONFIG_HOME'), DIRNAME) - elif (homedir and isdir(homedir) and homedir not in ['/']): + elif homedir and isdir(homedir) and homedir not in ['/']: conf_dir = join(homedir, '.config', DIRNAME) # Create conf_dir if necessary if not isdir(conf_dir): @@ -226,7 +246,6 @@ class ConfMan(object): # CONFIG MANAGER CLASS self.db_file = join(data_dir, 'sima.db') config = configparser.SafeConfigParser() - # If no conf file present, uses defaults if not isfile(self.conf_file): self.config = config