[gnome-music] Cleanup use of python static and class methods
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Cleanup use of python static and class methods
- Date: Mon, 14 Sep 2015 08:51:19 +0000 (UTC)
commit 50bac83315bedf8486d5dc58392f2b47301552ea
Author: Peter Shinners <pete shinners org>
Date: Mon Sep 7 09:09:19 2015 -0700
Cleanup use of python static and class methods
Several classmethods and methods switched to staticmethod. This is a minor Python cleanup. No
functionality or logic changes.
https://bugzilla.gnome.org/show_bug.cgi?id=754654
gnomemusic/albumArtCache.py | 12 ++++++------
gnomemusic/playlists.py | 14 +++++++-------
gnomemusic/query.py | 5 +++++
3 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/gnomemusic/albumArtCache.py b/gnomemusic/albumArtCache.py
index b3b6f3a..d1bd96a 100644
--- a/gnomemusic/albumArtCache.py
+++ b/gnomemusic/albumArtCache.py
@@ -97,13 +97,13 @@ class AlbumArtCache(GObject.GObject):
}
@classmethod
- def get_default(self):
- if not self.instance:
- self.instance = AlbumArtCache()
- return self.instance
+ def get_default(cls):
+ if not cls.instance:
+ cls.instance = AlbumArtCache()
+ return cls.instance
- @classmethod
- def get_media_title(self, media, escaped=False):
+ @staticmethod
+ def get_media_title(media, escaped=False):
title = media.get_title()
if title:
if escaped:
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index e7e5cb6..a7aaaf8 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -83,8 +83,8 @@ class StaticPlaylists:
self.RecentlyAdded.QUERY = Query.get_recently_added_songs()
self.Favorites.QUERY = Query.get_favorite_songs()
- @classmethod
- def get_protected_ids(self):
+ @staticmethod
+ def get_protected_ids():
return [str(cls.ID) for name, cls in inspect.getmembers(StaticPlaylists)
if inspect.isclass(cls) and not (name == "__class__")]
@@ -108,12 +108,12 @@ class Playlists(GObject.GObject):
return '<Playlists>'
@classmethod
- def get_default(self, tracker=None):
- if self.instance:
- return self.instance
+ def get_default(cls, tracker=None):
+ if cls.instance:
+ return cls.instance
else:
- self.instance = Playlists()
- return self.instance
+ cls.instance = Playlists()
+ return cls.instance
@log
def __init__(self):
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index b9ab38e..d09dff0 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -1038,6 +1038,7 @@ class Query():
return query
+ @staticmethod
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...?)
@@ -1073,6 +1074,7 @@ class Query():
return query
+ @staticmethod
def get_recently_added_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...?)
@@ -1108,6 +1110,7 @@ class Query():
return query
+ @staticmethod
def get_favorite_songs():
query = """
SELECT ?url
@@ -1395,6 +1398,7 @@ class Query():
return query
+ @staticmethod
def add_favorite(song_url):
query = """
INSERT {
@@ -1411,6 +1415,7 @@ class Query():
return query
+ @staticmethod
def remove_favorite(song_url):
query = """
DELETE {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]