Luke Plant avatar Luke Plant committed bcdcbac

Simplified various implementations by using only instances of Player subclasses, not the Player subclass itself

Comments (0)

Files changed (3)

 
 Currently supported players are:
 """
-    for P in players:
-        n = getattr(P, 'friendly_name', None)
+    for p in players:
+        n = getattr(p, 'friendly_name', None)
         if n is not None:
             help += " " + n + "\n"
 

playerdo/backends/mpris.py

     return [n for i, n in l]
 
 
-class classproperty(property):
-    def __get__(self, cls, owner):
-        return self.fget.__get__(None, owner)()
-
-
 class MprisPlayer(Player):
 
     _friendly_name = "Any MPRIS player"
     player_object_name = "/Player"
 
-    @classproperty
-    @classmethod
-    def friendly_name(cls):
-        retval = cls._friendly_name
+    @property
+    def friendly_name(self):
+        retval = self._friendly_name
         try:
-            l = get_sorted_candidate_buses(cls.player_object_name)
+            l = get_sorted_candidate_buses(self.player_object_name)
             names = []
             for n in l:
                 try:
 
     # Get running players
     running_ps = []
-    for P in players:
-        p = P()
+    for p in players:
         try:
             running = p.is_running()
             if running:
     """
     Checks that all backends have required dependencies, printing any failures
     """
-    for P in players:
-        p = P()
+    for p in players:
         failures = p.check_dependencies()
         if len(failures) > 0:
             sys.stdout.write("Player '%s' has missing dependencies:\n" % p.friendly_name)
         sys.exit(1)
 
 def find_players():
-    return [v for v in globals().values()
+    return [v() for v in globals().values()
             if type(v) is type and issubclass(v, Player)]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.