]> kaliko git repositories - mpd-sima.git/blobdiff - sima/utils/config.py
Fixed blacklisting in track mode
[mpd-sima.git] / sima / utils / config.py
index 06765254da21b24e7d1765921ccfd7181494f2bb..4d8d1127c191511b041169823e2bc8077253ecd7 100644 (file)
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
-
-# Copyright (c) 2009, 2010, 2011, 2013 Jack Kaliko <kaliko@azylum.org>
+# Copyright (c) 2009, 2010, 2011, 2013, 2014 Jack Kaliko <kaliko@azylum.org>
 #
 #  This file is part of sima
 #
@@ -36,32 +35,49 @@ 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': {
+            'internal': "Crop, Lastfm, RandomFallBack",
+            'contrib': "",
             'user_db': "false",
             'history_duration': "8",
             'queue_length': "1",
-            'consume': "0",},
+            },
         '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': {
-            'dynamic': "10",
-            'similarity': "18",
             '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",
             }
         }
 #
@@ -100,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:
@@ -109,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):
         """
@@ -172,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(
@@ -198,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)')
@@ -214,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):
@@ -229,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