[gnome-music] Pep8 fixes



commit 33ea3d46538182cc528311b0cda4fadda0c7d9dc
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Mon Jan 19 11:50:03 2015 +0100

    Pep8 fixes

 gnomemusic/grilo.py        |    2 +-
 gnomemusic/notification.py |    6 +++---
 gnomemusic/playlists.py    |   30 ++++++++++++++++++------------
 gnomemusic/query.py        |   34 +++++++++++++++++-----------------
 4 files changed, 39 insertions(+), 33 deletions(-)
---
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 82c2318..be2bd86 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -266,4 +266,4 @@ class Grilo(GObject.GObject):
 
 Grl.init(None)
 
-grilo = Grilo()
\ No newline at end of file
+grilo = Grilo()
diff --git a/gnomemusic/notification.py b/gnomemusic/notification.py
index 707ca85..e499313 100644
--- a/gnomemusic/notification.py
+++ b/gnomemusic/notification.py
@@ -58,9 +58,9 @@ class NotificationManager:
         nChannels = self._noArtworkIcon.get_n_channels()
         data = self._noArtworkIcon.get_pixels()
 
-        self._noArtworkIconSerialized = GLib.Variant('(iiibiiay)',
-                                                    (IMAGE_SIZE, IMAGE_SIZE, rowStride, hasAlpha,
-                                                     bitsPerSample, nChannels, data))
+        self._noArtworkIconSerialized = GLib.Variant(
+            '(iiibiiay)',
+            (IMAGE_SIZE, IMAGE_SIZE, rowStride, hasAlpha, bitsPerSample, nChannels, data))
 
         self._player.connect('playing-changed', self._on_playing_changed)
         self._player.connect('current-changed', self._update_track)
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index a5cdb47..e79c747 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -26,7 +26,7 @@
 # delete this exception statement from your version.
 
 
-from gi.repository import Grl, GLib, GObject, Gio, Tracker
+from gi.repository import Grl, GLib, GObject
 from gnomemusic.grilo import grilo
 from gnomemusic.query import Query
 import inspect
@@ -43,17 +43,19 @@ class StaticPlaylists:
         ID = None
         QUERY = Query.get_most_played_songs()
         TAG_TEXT = "MOST_PLAYED"
-        TITLE = "Most Played" # Will eventually be translated
+        TITLE = "Most Played"  # Will eventually be translated
+
     class NeverPlayed:
         ID = None
         QUERY = Query.get_never_played_songs()
         TAG_TEXT = "NEVER_PLAYED"
-        TITLE = "Never Played" # Will eventually be translated
+        TITLE = "Never Played"  # Will eventually be translated
+
     class RecentlyPlayed:
         ID = None
         QUERY = Query.get_recently_played_songs()
         TAG_TEXT = "RECENTLY_PLAYED"
-        TITLE = "Recently Played" # Will eventually be translated
+        TITLE = "Recently Played"  # Will eventually be translated
 
 
 class Playlists(GObject.GObject):
@@ -89,12 +91,14 @@ class Playlists(GObject.GObject):
     @log
     def fetch_or_create_static_playlists(self):
         """For all static playlists: get ID, if exists; if not, create the playlist and get ID."""
-        for playlist in [cls for name, cls in inspect.getmembers(StaticPlaylists) if inspect.isclass(cls) \
-        and not (name  == "__class__")]: # hacky
+        playlists = [cls for name, cls in inspect.getmembers(StaticPlaylists)
+                     if inspect.isclass(cls) and not (name == "__class__")]  # hacky
+
+        for playlist in playlists:
             cursor = self.tracker.query(Query.get_playlist_with_tag(playlist.TAG_TEXT), None)
             while cursor.next():
                 playlist_id = cursor.get_string(1)[0]
-                playlist.ID = int(playlist_id) # hacky; shouldn't be reassigned every time
+                playlist.ID = int(playlist_id)  # hacky; shouldn't be reassigned every time
 
             if not playlist.ID:
                 # create the playlist
@@ -112,8 +116,8 @@ class Playlists(GObject.GObject):
     def update_playcount(self, song_url):
         query = Query.update_playcount(song_url)
         self.tracker.update(query, GLib.PRIORITY_DEFAULT, None)
-        self.update_all_static_playlists() # not the best place to put this func;
-            # maybe a 'scrobble' func that updates playcount & last played and then updates playlists?
+        self.update_all_static_playlists()  # not the best place to put this func;
+        # maybe a 'scrobble' func that updates playcount & last played and then updates playlists?
 
     @log
     def update_last_played(self, song_url):
@@ -125,7 +129,7 @@ class Playlists(GObject.GObject):
         """Given a static playlist (subclass of StaticPlaylists), updates according to its query."""
         # Clear the playlist
         self.clear_playlist_with_id(playlist.ID)
-        
+
         # Get a list of matching songs
         cursor = self.tracker.query(playlist.QUERY, None)
         if not cursor:
@@ -144,8 +148,10 @@ class Playlists(GObject.GObject):
         self.emit('playlist-updated', playlist.ID)
 
     def update_all_static_playlists(self):
-        for playlist in [cls for name, cls in inspect.getmembers(StaticPlaylists) if inspect.isclass(cls) \
-        and not (name  == "__class__")]: # hacky
+        playlists = [cls for name, cls in inspect.getmembers(StaticPlaylists)
+                     if inspect.isclass(cls) and not (name == "__class__")]  # hacky
+
+        for playlist in playlists:
             self.update_static_playlist(playlist)
 
     @log
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index 16e5959..7e8059c 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -61,18 +61,19 @@ class Query():
         """Returns a SPARQL ORDER BY statement sorting by the given attribute, ignoring
             articles as defined in _("the"). 'Attr' should be given without parentheses,
             e.g., "attr='?author'"."""
-        return_statement = "fn:lower-case(%(attribute)s)" % {'attribute' : attr }
+        return_statement = "fn:lower-case(%(attribute)s)" % {'attribute': attr}
         # TRANSLATORS: _("the") should be a space-separated list of all-lowercase articles
-            # (such as 'the') that should be ignored when alphabetizing artists/albums. This
-            # list should include 'the' regardless of language. If some articles occur more
-            # frequently than others, most common should appear first, least common last.
+        # (such as 'the') that should be ignored when alphabetizing artists/albums. This
+        # list should include 'the' regardless of language. If some articles occur more
+        # frequently than others, most common should appear first, least common last.
         for article in reversed(_("the a an").split(" ")):
             return_statement = '''IF(fn:starts-with(fn:lower-case(%(attribute)s), "%(article)s"),
             fn:substring(fn:lower-case(%(attribute)s), %(substr_start)s),
-            %(nested_if)s)''' % {'attribute' : attr,
-                'article' : article+" ",
-                'substr_start' : str(len(article)+2),
-                'nested_if' : return_statement }
+            %(nested_if)s)''' % {
+                'attribute': attr,
+                'article': article + " ",
+                'substr_start': str(len(article) + 2),
+                'nested_if': return_statement}
         return return_statement
 
     @staticmethod
@@ -254,8 +255,8 @@ class Query():
             'where_clause': where_clause.replace('\n', ' ').strip(),
             'music_dir': Query.MUSIC_URI,
             'download_dir': Query.DOWNLOAD_URI,
-            'album_order' : Query.order_by_statement("?title"),
-            'artist_order' : Query.order_by_statement("?author")
+            'album_order': Query.order_by_statement("?title"),
+            'artist_order': Query.order_by_statement("?author")
         }
 
         return query
@@ -408,7 +409,7 @@ class Query():
             'music_dir': Query.MUSIC_URI,
             'download_dir': Query.DOWNLOAD_URI,
             'artist_order': Query.order_by_statement("?author"),
-            'album_order' : Query.order_by_statement("nie:title(?album)")
+            'album_order': Query.order_by_statement("nie:title(?album)")
         }
 
         return query
@@ -905,7 +906,6 @@ class Query():
 
         return Query.playlists(query)
 
-
     @staticmethod
     def get_playlist_with_urn(playlist_urn):
         query = """
@@ -988,10 +988,11 @@ class Query():
     def get_recently_played_songs():
         #TODO: or this could take comparison date as an argument so we don't need to make a date string in 
query.py...
         #TODO: set time interval somewhere? A settings file? (Default is maybe 2 weeks...?)
-        
-        days_difference = 3 # currently hardcoding time interval of 3 days
+
+        days_difference = 3  # currently hardcoding time interval of 3 days
         seconds_difference = days_difference * SECONDS_PER_DAY
-        compare_date = time.strftime(sparql_midnight_dateTime_format, 
time.gmtime(time.time()-seconds_difference))
+        compare_date = time.strftime(
+            sparql_midnight_dateTime_format, time.gmtime(time.time() - seconds_difference))
 
         query = """
         SELECT ?url
@@ -1006,7 +1007,6 @@ class Query():
 
         return query
 
-
     # Functions for search
     # TODO: make those queries actually return something
     @staticmethod
@@ -1268,4 +1268,4 @@ class Query():
             'playlist_id': playlist_id
         }
 
-        return query
\ No newline at end of file
+        return query


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]