]> kaliko git repositories - mpd-sima.git/commitdiff
Expose only config in MPDClient instance.
authorkaliko <kaliko@azylum.org>
Wed, 21 Apr 2021 12:28:36 +0000 (14:28 +0200)
committerkaliko <kaliko@azylum.org>
Wed, 21 Apr 2021 12:28:36 +0000 (14:28 +0200)
Remove useless daemon argument

sima/core.py
sima/mpdclient.py

index f4154d9d9f60c68c4812d189d72cb231df1788f6..695a18ca3ca621293164cefef6c1fe088a5af7d7 100644 (file)
@@ -46,7 +46,7 @@ class Sima(Daemon):
         self.log = getLogger('sima')
         self._plugins = list()
         self._core_plugins = list()
-        self.player = PlayerClient(self)  # Player client
+        self.player = PlayerClient(conf)  # MPD client
         self.short_history = deque(maxlen=60)
 
     def add_history(self):
index 95cfb5765c23e41df83cb571924cdb0e6c6f6575..7eeed94d86fa29e13b717081eba9ca2c2c46da86 100644 (file)
@@ -20,6 +20,7 @@
 from difflib import get_close_matches
 from functools import wraps
 from itertools import dropwhile
+from logging import getLogger
 
 # external module
 from musicpd import MPDClient, MPDError
@@ -133,12 +134,11 @@ class MPD(MPDClient):
                           'MUSICBRAINZ_RELEASETRACKID', 'MUSICBRAINZ_WORKID'}
     database = None
 
-    def __init__(self, daemon):
+    def __init__(self, config):
         super().__init__()
         self.use_mbid = True
-        self.daemon = daemon
-        self.log = daemon.log
-        self.config = self.daemon.config['MPD']
+        self.log = getLogger('sima')
+        self.config = config
         self._cache = None
 
     # ######### Overriding MPDClient ###########
@@ -156,10 +156,11 @@ class MPD(MPDClient):
 
     def connect(self):
         """Overriding explicitly MPDClient.connect()"""
+        mpd_config = self.config['MPD']
         # host, port, password
-        host = self.config.get('host')
-        port = self.config.get('port')
-        password = self.config.get('password', fallback=None)
+        host = mpd_config.get('host')
+        port = mpd_config.get('port')
+        password = mpd_config.get('password', fallback=None)
         self.disconnect()
         try:
             super().connect(host, port)
@@ -199,7 +200,7 @@ class MPD(MPDClient):
         for tag in MPD.needed_mbid_tags:
             self.tagtypes('enable', tag)
         # Controls use of MusicBrainzIdentifier
-        if self.daemon.config.get('sima', 'musicbrainzid'):
+        if self.config.getboolean('sima', 'musicbrainzid'):
             tt = set(self.tagtypes())
             if len(MPD.needed_mbid_tags & tt) != len(MPD.needed_mbid_tags):
                 self.log.warning('Use of MusicBrainzIdentifier is set but MPD '