Commits

Luke Plant committed e61579d

PEP8 fixes

Comments (0)

Files changed (5)

 #!/usr/bin/env python
 
 #
-# Wrapper for controlling various music players, so that you can define keyboard
-# shortcuts that work for whatever player you are using.  Ideally it will still
-# work even if multiple players are running if all but one are 'stopped', but
-# some music players do not have such a state or it cannot be determined.
+# Wrapper for controlling various music players, so that you can define
+# keyboard shortcuts that work for whatever player you are using.  Ideally it
+# will still work even if multiple players are running if all but one are
+# 'stopped', but some music players do not have such a state or it cannot be
+# determined.
 #
 
 from playerdo.main import do_test, do_command, find_players
 import sys
 
 
-
 def usage(players):
     # Print help and list of supported players
     help = """Usage: player_do <command>
 
-  Media players that are currently running will be detected, and the command will
-  be passed on to the first, giving priority to players that seem to be active.
+  Media players that are currently running will be detected, and the command
+  will be passed on to the first, giving priority to players that seem to be
+  active.
 
 <command> is one of:
 """
     max_len = len(sorted(commands, key=lambda c: len(c[0]))[-1][0])
     for name, doc, f in commands:
-        help += " " + name +  " "*(max_len - len(name) + 2) + doc + "\n"
+        help += " " + name + " " * (max_len - len(name) + 2) + doc + "\n"
 
     help += """
 Not all operations are supported or fully supported by all players.
 
 
 # List of commands: (name, docstring, callable)
-
 commands = []
 
-for c in ["play", "pause", "unpause", "togglepause", "playpause", "stop", "next", "prev", "osd"]:
+for c in ["play", "pause", "unpause", "togglepause",
+          "playpause", "stop", "next", "prev", "osd"]:
     def mk_command(name):
         def command(players):
             return do_command(name, players)
     ("help", "Prints help.", print_usage),
 ])
 
-
 command_dict = dict((name, f) for name, doc, f in commands)
 
 
         sys.exit(1)
     else:
         command(players)
-

playerdo/backends/base.py

 from playerdo.utils import program_running, catch_unimplemented
 
+
 # Base class useful for implementing players
 class Player(object):
 
         Shows OSD (on screen display).
         """
         raise NotImplementedError
-

playerdo/backends/mpris.py

 
 def get_all_mpris_buses():
     bus = dbus.SessionBus()
-    return [str(s) for s in bus.list_names() if str(s).startswith('org.mpris.')]
+    return [str(s) for s in bus.list_names()
+            if str(s).startswith('org.mpris.')]
 
 
 class MprisPlayer(Player):
 
     def osd(self):
         self.player.ShowOSD()
-
-
-
 from playerdo.backends.base import Player
 import sys
 
+
 def get_running_players(players):
     """
     Given a list of Player classes, returns a list of players (instances) that
         elif is_stopped == False:
             state.append(0)
         else:
-            # In-between value for unknowns, because a player that is definitely
-            # stopped is less preferred than one that *might* be playing.
+            # In-between value for unknowns, because a player that is
+            # definitely stopped is less preferred than one that *might* be
+            # playing.
             state.append(1)
 
     l = zip(state, running_ps)
 
     return [x[1] for x in l]
 
+
 def do_test(players):
     # Check dependencies of all players
     pass
     try:
         player.do_command(command)
     except NotImplementedError:
-        sys.stderr.write("Operation '%s' not supported for player '%s'.\n" % (command, player.friendly_name))
+        sys.stderr.write("Operation '%s' not supported for player '%s'.\n" %
+                         (command, player.friendly_name))
         sys.exit(1)
 
 
 def find_players():
-    return [v for v in globals().values() if type(v) is type and issubclass(v, Player)]
+    return [v for v in globals().values()
+            if type(v) is type and issubclass(v, Player)]

playerdo/utils.py

         pass
     return retval
 
+
 def process_retval(args, input=None):
     """
     Executes the process with the commandline specified in 'args' and returns
     p.communicate(input=input)
     return p.returncode
 
+
 def process_true(args, input=None):
     """
     Executes a process and rturns true if the process has a zero return code
     """
     return process_retval(args, input=input) == 0
 
+
 def program_running(progam):
     return process_true(["pidof", progam])
 
     Wrapper for a dbus object, so that the bus name and object name only needs
     to be specified once.
     """
+
     def __init__(self, bus_name, object_name):
         bus = dbus.SessionBus()
         self._bus = bus
 # Misc helpers
 def catch_unimplemented(c, replacement=None):
     """
-    Execute a callable c, returning replacement if it throws NotImplementedError
+    Execute a callable c, returning replacement if it throws
+    NotImplementedError
     """
     try:
         return c()
     except NotImplementedError:
         return replacement
-