* Fixed not using the limit on *.get_top_tags(limit). (Closes Issue #61)
This commit is contained in:
parent
96e90dfebf
commit
52ce81743a
19
pylast.py
19
pylast.py
|
@ -322,9 +322,11 @@ class _Network(object):
|
|||
tag = Tag(_extract(node, "name"), self)
|
||||
weight = _number(_extract(node, "count"))
|
||||
|
||||
if len(seq) < limit:
|
||||
seq.append(TopItem(tag, weight))
|
||||
|
||||
if limit:
|
||||
seq = seq[:limit]
|
||||
|
||||
return seq
|
||||
|
||||
def enable_proxy(self, host, port):
|
||||
|
@ -1084,13 +1086,14 @@ class _Taggable(object):
|
|||
seq = []
|
||||
|
||||
for element in elements:
|
||||
if limit and len(seq) >= limit:
|
||||
break
|
||||
tag_name = _extract(element, 'name')
|
||||
tagcount = _extract(element, 'count')
|
||||
|
||||
seq.append(TopItem(Tag(tag_name, self.network), tagcount))
|
||||
|
||||
if limit:
|
||||
seq = seq[:limit]
|
||||
|
||||
return seq
|
||||
|
||||
class WSError(Exception):
|
||||
|
@ -1239,9 +1242,11 @@ class Album(_BaseObject, _Taggable):
|
|||
|
||||
seq = []
|
||||
for name in _extract_all(e, "name"):
|
||||
if len(seq) < limit:
|
||||
seq.append(Tag(name, self.network))
|
||||
|
||||
if limit:
|
||||
seq = seq[:limit]
|
||||
|
||||
return seq
|
||||
|
||||
def get_tracks(self):
|
||||
|
@ -3004,7 +3009,7 @@ class User(_BaseObject):
|
|||
return seq
|
||||
|
||||
def get_top_tags(self, limit=None):
|
||||
"""Returns a sequence of the top tags used by this user with their counts as (Tag, tagcount).
|
||||
"""Returns a sequence of the top tags used by this user with their counts as TopItem objects.
|
||||
* limit: The limit of how many tags to return.
|
||||
"""
|
||||
|
||||
|
@ -3012,9 +3017,11 @@ class User(_BaseObject):
|
|||
|
||||
seq = []
|
||||
for node in doc.getElementsByTagName("tag"):
|
||||
if len(seq) < limit:
|
||||
seq.append(TopItem(Tag(_extract(node, "name"), self.network), _extract(node, "count")))
|
||||
|
||||
if limit:
|
||||
seq = seq[:limit]
|
||||
|
||||
return seq
|
||||
|
||||
def get_top_tracks(self, period = PERIOD_OVERALL):
|
||||
|
|
Loading…
Reference in a new issue