diff options
author | Anton Khirnov <wyskas@gmail.com> | 2009-03-06 10:13:56 +0100 |
---|---|---|
committer | Anton Khirnov <wyskas@gmail.com> | 2009-03-06 10:13:56 +0100 |
commit | 4905e4e180e203ed4c1df52468da57cf02b9ea03 (patch) | |
tree | e3a23415dc24033809ac4a7279962b126755c8a1 /nephilim/mpclient.py | |
parent | f3a7b35c0aca4246bbab37f9653222a83eb42432 (diff) |
mpclient: add/fix docstrings for functions.
Diffstat (limited to 'nephilim/mpclient.py')
-rw-r--r-- | nephilim/mpclient.py | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/nephilim/mpclient.py b/nephilim/mpclient.py index f60719e..5f60094 100644 --- a/nephilim/mpclient.py +++ b/nephilim/mpclient.py @@ -57,7 +57,7 @@ class MPClient(QtCore.QObject): self._listeners[event] = [] def connect(self, host, port): - """Connect to MPD@$host:$port. Returns true at success, false otherwise.""" + """Connect to MPD@host:port. Returns Tue at success, False otherwise.""" if self._client: return True try: @@ -86,7 +86,7 @@ class MPClient(QtCore.QObject): self._client = None def isConnected(self): - """Returns true if we're connected to MPD, false otherwise.""" + """Returns True if connected to MPD, False otherwise.""" return self._client != None def listPlaylist(self): @@ -96,6 +96,7 @@ class MPClient(QtCore.QObject): return self._curPlaylist def listLibrary(self): + """Returns current library.""" if not self.isConnected(): return [] return self._curLib @@ -107,6 +108,7 @@ class MPClient(QtCore.QObject): return self._curSong def updateDB(self, paths = None): + """Starts MPD database update.""" if not paths: return self._client.update() self._client.command_list_ok_begin() @@ -115,6 +117,7 @@ class MPClient(QtCore.QObject): self._client.command_list_end() def getStatus(self): + """Get current status""" if self.isConnected() == False: return None ret = self._retrieve(self._client.status) @@ -129,29 +132,32 @@ class MPClient(QtCore.QObject): return ret def get_outputs(self): - """returns audio outputs""" + """Returns an array of configured MPD audio outputs.""" if self.isConnected(): return self._retrieve(self._client.outputs) else: return [] def set_output(self, output_id, state): - """set audio output output_id to state""" + """Set audio output output_id to state (0/1).""" if state: self._client.enableoutput(output_id) else: self._client.disableoutput(output_id) def urlhandlers(self): + """Returns an array of available url handlers.""" if not self.isConnected(): return [] else: return self._client.urlhandlers() def repeat(self, val): + """Set repeat playlist to val (True/False).""" if isinstance(val, bool): val = 1 if val else 0 self._client.repeat(val) - def random(self,val): + def random(self, val): + """Set random playback to val (True, False).""" if isinstance(val, bool): val = 1 if val else 0 self._client.random(val) @@ -171,10 +177,11 @@ class MPClient(QtCore.QObject): return ret def isPlaying(self): + """Returns True if MPD is playing, False otherwise.""" return self.getStatus()['state'] == 'play' def play(self, id = None): - """Play song with ID $id.""" + """Play song with ID id or next song if id is None.""" self._playCalled = True if id: self._client.playid(id) @@ -204,24 +211,24 @@ class MPClient(QtCore.QObject): self._client.stop() def seek(self, time): - """Move the current playing time to $time.""" + """Seek to time.""" if self._curSongID > 0: self._client.seekid(self._curSongID, time) def deleteFromPlaylist(self, list): - """Remove all songIDs in $list from the playlist.""" + """Remove all song IDs in list from the playlist.""" self._client.command_list_ok_begin() for id in list: self._client.deleteid(id) self._client.command_list_end() self._updatePlaylist() def clear_playlist(self): - """Removes all songs from current playlist.""" + """Clear current playlist.""" self._client.clear() self._updatePlaylist() def addToPlaylist(self, paths): - """Add all files in $paths to the current playlist.""" + """Add all files in paths to the current playlist.""" try: self._client.command_list_ok_begin() for path in paths: @@ -234,7 +241,7 @@ class MPClient(QtCore.QObject): logging.error('Cannot add some files, check permissions.') def setVolume(self, volume): - """Set volumne to $volume.""" + """Set volume to volume.""" volume = min(100, max(0, volume)) self._client.setvol(volume) def getVolume(self): @@ -246,20 +253,21 @@ class MPClient(QtCore.QObject): raise Exception("Unknown event "+event) self._listeners[event].append(callback) def removeListener(self, event, callback): + """Remove callback from listeners for event.""" if not(event in self.events): raise Exception("Unknown event "+event) self._listeners[event].remove(callback) def _updateLib(self): - """Update the library.""" + """Update the cached library.""" self._curLib = self._arrayToSongArray(self._retrieve(self._client.listallinfo)) id = 0 for song in self._curLib: song._data['id'] = id id += 1 def _updatePlaylist(self): - """Update the playlist.""" + """Update the cached playlist.""" self._curPlaylist = self._arrayToSongArray(self._retrieve(self._client.playlistinfo)) def _arrayToSongArray(self, array): """Convert an array to an array of Songs.""" @@ -285,7 +293,7 @@ class MPClient(QtCore.QObject): self.callback(self.params) def _raiseEvent(self, event, params): - """Call all listeners for $event with parameters $params.""" + """Call all listeners for event with parameters params.""" if not(event in self.events): raise Exception("Unknown raised event "+event) @@ -293,7 +301,7 @@ class MPClient(QtCore.QObject): self.simpleThread(listener, params).run() def timerEvent(self, event): - "Check for changes since last check." + """Check for changes since last check.""" status = self.getStatus() if status == None: |