From 497746051efb18bc2d4e160f073e890b94197f59 Mon Sep 17 00:00:00 2001 From: Peter Schnebel Date: Thu, 31 Oct 2013 16:40:22 +0100 Subject: [PATCH] clean up --- beetsplug/mpc.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/beetsplug/mpc.py b/beetsplug/mpc.py index 67a95acbc..7e53e444c 100644 --- a/beetsplug/mpc.py +++ b/beetsplug/mpc.py @@ -71,6 +71,8 @@ class Client(object): self.client = MPDClient() def mpd_connect(self): + """Connect to the MPD. + """ try: self.client.connect(host=self.host, port=self.port) except SocketError, e: @@ -84,6 +86,8 @@ class Client(object): return def mpd_disconnect(self): + """Disconnect from the MPD. + """ self.client.close() self.client.disconnect() @@ -111,11 +115,9 @@ class Client(object): return result def mpd_status(self): - status = self.mpd_func('status') - if status is None: - return None - # log.debug(u'mpc(status): {0}'.format(status)) - return status + """Return the current status of the MPD. + """ + return self.mpd_func('status') def beets_get_item(self, path): """Return the beets item related to path. @@ -127,11 +129,17 @@ class Client(object): return items[0] def user_attr(self, attribute): + """Return the attribute postfixed with the user or None if user is not + set. + """ if self.user != u'': return u'{1}[{0}]'.format(self.user, attribute) return None def rating(self, play_count, skip_count, rating, skipped): + """Calculate a new rating based on play count, skip count, old rating + and the fact if it was skipped or not. + """ if skipped: rolling = (rating - rating / 2.0) else: