Remove dead Last.fm group methods

This commit is contained in:
Hugo 2017-09-25 18:29:12 +03:00
parent 6d738d3f43
commit 454c519fd9
2 changed files with 3 additions and 106 deletions

View file

@ -241,13 +241,6 @@ class _Network(object):
return Metro(metro_name, country_name, self) return Metro(metro_name, country_name, self)
def get_group(self, name):
"""
Returns a Group object
"""
return Group(name, self)
def get_user(self, username): def get_user(self, username):
""" """
Returns a user object Returns a user object
@ -766,7 +759,6 @@ class LastFMNetwork(_Network):
"country": "place/%(country_name)s", "country": "place/%(country_name)s",
"tag": "tag/%(name)s", "tag": "tag/%(name)s",
"track": "music/%(artist)s/_/%(title)s", "track": "music/%(artist)s/_/%(title)s",
"group": "group/%(name)s",
"user": "user/%(name)s", "user": "user/%(name)s",
} }
) )
@ -830,7 +822,6 @@ class LibreFMNetwork(_Network):
"country": "place/%(country_name)s", "country": "place/%(country_name)s",
"tag": "tag/%(name)s", "tag": "tag/%(name)s",
"track": "music/%(artist)s/_/%(title)s", "track": "music/%(artist)s/_/%(title)s",
"group": "group/%(name)s",
"user": "user/%(name)s", "user": "user/%(name)s",
} }
) )
@ -1288,7 +1279,7 @@ class _Chartable(object):
""" """
Returns the weekly album charts for the week starting from the Returns the weekly album charts for the week starting from the
from_date value to the to_date value. from_date value to the to_date value.
Only for Group or User. Only for User.
""" """
return self.get_weekly_charts("album", from_date, to_date) return self.get_weekly_charts("album", from_date, to_date)
@ -1296,7 +1287,7 @@ class _Chartable(object):
""" """
Returns the weekly artist charts for the week starting from the Returns the weekly artist charts for the week starting from the
from_date value to the to_date value. from_date value to the to_date value.
Only for Group, Tag or User. Only for Tag or User.
""" """
return self.get_weekly_charts("artist", from_date, to_date) return self.get_weekly_charts("artist", from_date, to_date)
@ -1304,7 +1295,7 @@ class _Chartable(object):
""" """
Returns the weekly track charts for the week starting from the Returns the weekly track charts for the week starting from the
from_date value to the to_date value. from_date value to the to_date value.
Only for Group or User. Only for User.
""" """
return self.get_weekly_charts("track", from_date, to_date) return self.get_weekly_charts("track", from_date, to_date)
@ -2580,77 +2571,6 @@ class Track(_Opus):
'artist': artist, 'title': title} 'artist': artist, 'title': title}
class Group(_BaseObject, _Chartable):
"""A Last.fm group."""
name = None
__hash__ = _BaseObject.__hash__
def __init__(self, name, network):
_BaseObject.__init__(self, network, 'group')
_Chartable.__init__(self, 'group')
self.name = name
def __repr__(self):
return "pylast.Group(%s, %s)" % (repr(self.name), repr(self.network))
@_string_output
def __str__(self):
return self.get_name()
def __eq__(self, other):
return self.get_name().lower() == other.get_name().lower()
def __ne__(self, other):
return self.get_name() != other.get_name()
def _get_params(self):
return {self.ws_prefix: self.get_name()}
def get_name(self):
"""Returns the group name. """
return self.name
def get_url(self, domain_name=DOMAIN_ENGLISH):
"""Returns the url of the group page on the network.
* domain_name: The network's language domain. Possible values:
o DOMAIN_ENGLISH
o DOMAIN_GERMAN
o DOMAIN_SPANISH
o DOMAIN_FRENCH
o DOMAIN_ITALIAN
o DOMAIN_POLISH
o DOMAIN_PORTUGUESE
o DOMAIN_SWEDISH
o DOMAIN_TURKISH
o DOMAIN_RUSSIAN
o DOMAIN_JAPANESE
o DOMAIN_CHINESE
"""
name = _url_safe(self.get_name())
return self.network._get_url(domain_name, "group") % {'name': name}
def get_members(self, limit=50, cacheable=False):
"""
Returns a sequence of User objects
if limit==None it will return all
"""
nodes = _collect_nodes(
limit, self, self.ws_prefix + ".getMembers", cacheable)
users = []
for node in nodes:
users.append(User(_extract(node, "name"), self.network))
return users
class User(_BaseObject, _Chartable): class User(_BaseObject, _Chartable):
"""A Last.fm user.""" """A Last.fm user."""

View file

@ -287,13 +287,6 @@ class TestPyLast(unittest.TestCase):
# Act/Assert # Act/Assert
self.helper_is_thing_hashable(event) self.helper_is_thing_hashable(event)
def test_group_is_hashable(self):
# Arrange
group = self.network.get_group("Audioscrobbler Beta")
# Act/Assert
self.helper_is_thing_hashable(group)
def test_library_is_hashable(self): def test_library_is_hashable(self):
# Arrange # Arrange
library = pylast.Library(user=self.username, network=self.network) library = pylast.Library(user=self.username, network=self.network)
@ -639,13 +632,6 @@ class TestPyLast(unittest.TestCase):
# Assert # Assert
self.helper_validate_results(result1, result2, result3) self.helper_validate_results(result1, result2, result3)
def test_cacheable_group_get_members(self):
# Arrange
group = self.network.get_group("Audioscrobbler Beta")
# Act/Assert
self.helper_validate_cacheable(group, "get_members")
def test_cacheable_library(self): def test_cacheable_library(self):
# Arrange # Arrange
library = pylast.Library(self.username, self.network) library = pylast.Library(self.username, self.network)
@ -987,15 +973,6 @@ class TestPyLast(unittest.TestCase):
self.helper_assert_chart(album_chart, pylast.Album) self.helper_assert_chart(album_chart, pylast.Album)
self.helper_assert_chart(track_chart, pylast.Track) self.helper_assert_chart(track_chart, pylast.Track)
def test_group_charts(self):
# Arrange
group = self.network.get_group("mnml")
dates = group.get_weekly_chart_dates()
self.helper_dates_valid(dates)
# Act/Assert
self.helper_get_assert_charts(group, dates[-2])
def test_tag_charts(self): def test_tag_charts(self):
# Arrange # Arrange
tag = self.network.get_tag("rock") tag = self.network.get_tag("rock")