]> kaliko git repositories - python-musicpd.git/commitdiff
mpd.py: tidying up _execute()
authorJ. Alexander Treuman <jat@spatialrift.net>
Thu, 15 Jul 2010 17:34:44 +0000 (13:34 -0400)
committerJ. Alexander Treuman <jat@spatialrift.net>
Thu, 15 Jul 2010 17:34:44 +0000 (13:34 -0400)
mpd.py

diff --git a/mpd.py b/mpd.py
index 2875f95ced8c42c3511ce9d60c7868692e734755..cb16701872c5b700bc44620eb415780e7715e64c 100644 (file)
--- a/mpd.py
+++ b/mpd.py
@@ -174,14 +174,17 @@ class MPDClient(object):
             raise PendingCommandError("Cannot execute %s with "
                                       "pending commands" % command)
         retval = self._commands[command]
-        if self._command_list is not None and not callable(retval):
-            raise CommandListError("%s not allowed in command list" % command)
-        self._write_command(command, args)
-        if self._command_list is None:
+        if self._command_list is not None:
+            if not callable(retval):
+                raise CommandListError("%s not allowed in command list" %
+                                        command)
+            self._write_command(command, args)
+            self._command_list.append(retval)
+        else:
+            self._write_command(command, args)
             if callable(retval):
                 return retval()
             return retval
-        self._command_list.append(retval)
 
     def _write_line(self, line):
         self._wfile.write("%s\n" % line)