]> kaliko git repositories - mpd-sima.git/blobdiff - sima/utils/config.py
Improved log handling
[mpd-sima.git] / sima / utils / config.py
index 157d7c3c341ce7cea04a47aa54e3ba468b30c608..b3a8d46a8c0c9a4d94ed001295226e631eecf61e 100644 (file)
@@ -25,6 +25,7 @@ Parse configuration file and set defaults for missing options.
 
 # IMPORTS
 import configparser
+import logging
 import sys
 
 from configparser import Error
@@ -60,6 +61,9 @@ DEFAULT_CONF = {
             'verbosity': "info",
             'logfile': "",
             },
+        'crop': {
+            'consume': 10,
+            },
         'echonest': {
             'queue_mode': "track", #TODO control values
             'max_art': 15,
@@ -75,6 +79,7 @@ DEFAULT_CONF = {
             'track_to_add': 1,
             'album_to_add': 1,
             'depth': 1,
+            'cache': True,
             },
         'randomfallback': {
             'flavour': "sensible", # in pure, sensible
@@ -101,8 +106,8 @@ class ConfMan(object):  # CONFIG MANAGER CLASS
         * command line options (overrides previous)
     """
 
-    def __init__(self, logger, options=None):
-        self.log = logger
+    def __init__(self, options=None):
+        self.log = logging.getLogger('sima')
         # options settings priority:
         # defauts < env. var. < conf. file < command line
         self.conf_file = options.get('conf_file')
@@ -115,20 +120,8 @@ class ConfMan(object):  # CONFIG MANAGER CLASS
         ## INIT CALLS
         self.init_config()
         self.supersedes_config_with_cmd_line_options()
-
-    def get_pw(self):
-        try:
-            self.config.getboolean('MPD', 'password')
-            self.log.debug('No password set, proceeding without ' +
-                           'authentication...')
-            return None
-        except ValueError:
-            # ValueError if password not a boolean, hence an actual password.
-            pwd = self.config.get('MPD', 'password')
-            if not pwd:
-                self.log.debug('Password set as an empty string.')
-                return None
-            return pwd
+        # generate dbfile
+        self.config['sima']['db_file'] = join(self.config['sima']['var_dir'], 'sima.db')
 
     def control_mod(self):
         """
@@ -204,7 +197,6 @@ class ConfMan(object):  # CONFIG MANAGER CLASS
 
         ## Sima sqlite DB
         self.config['sima']['var_dir'] = join(data_dir)
-        self.config['sima']['db_file'] = join(data_dir, 'sima.db')
 
         # If no conf file present, uses defaults
         if not isfile(self.conf_file):