From a6f209a3f91c0b37afa048935b81b043e778970b Mon Sep 17 00:00:00 2001 From: hugovk Date: Sun, 12 Apr 2015 19:37:53 +0300 Subject: [PATCH 1/8] Remove unused argument --- pylast/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index f7fe250..da5cb5e 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -4038,7 +4038,7 @@ def _extract(node, name, index=0): return None -def _extract_element_tree(node, index=0): +def _extract_element_tree(node): """Extract an element tree into a multi-level dictionary NB: If any elements have text nodes as well as nested From f13c94abe8cec029bc569b8fdb0c4a63cada7139 Mon Sep 17 00:00:00 2001 From: hugovk Date: Sun, 12 Apr 2015 19:39:19 +0300 Subject: [PATCH 2/8] Don't redefine built-in --- pylast/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index da5cb5e..6076d42 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -4197,13 +4197,13 @@ class BadSessionError(ScrobblingError): class _ScrobblerRequest(object): - def __init__(self, url, params, network, type="POST"): + def __init__(self, url, params, network, request_type="POST"): for key in params: params[key] = str(params[key]) self.params = params - self.type = type + self.type = request_type (self.hostname, self.subdir) = url_split_host(url[len("http:"):]) self.network = network From 4597514317b8ad9b983f4e3b9cfcce838ca4aaf1 Mon Sep 17 00:00:00 2001 From: hugovk Date: Sun, 12 Apr 2015 19:55:48 +0300 Subject: [PATCH 3/8] 2015 --- pylast/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 6076d42..fe6873e 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -4,7 +4,7 @@ # A Python interface to Last.fm (and other API compatible social networks) # # Copyright 2008-2010 Amr Hassan -# Copyright 2013-2014 hugovk +# Copyright 2013-2015 hugovk # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import six __version__ = '1.1.0' __author__ = 'Amr Hassan, hugovk' -__copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2014 hugovk" +__copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2015 hugovk" __license__ = "apache2" __email__ = 'amr.hassan@gmail.com' From be8ae40caf444a0af8a5f1a986783fef99f281ea Mon Sep 17 00:00:00 2001 From: hugovk Date: Sun, 26 Apr 2015 20:10:24 +0300 Subject: [PATCH 4/8] Failing test for #124 --- tests/test_pylast.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index 8962ef3..e3581b9 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -1101,6 +1101,14 @@ class TestPyLast(unittest.TestCase): # Assert self.helper_only_one_thing_in_top_list(tags, pylast.Tag) + def test_network_get_top_tags_with_no_limit(self): + # Arrange + # Act + tags = self.network.get_top_tags() + + # Assert + self.helper_at_least_one_thing_in_top_list(tags, pylast.Tag) + def test_network_get_top_tracks_with_limit(self): # Arrange # Act From 926c01a97e9ca6c82e948d20cbc068f75591bc64 Mon Sep 17 00:00:00 2001 From: hugovk Date: Sun, 26 Apr 2015 20:11:49 +0300 Subject: [PATCH 5/8] Don't compare with limit if limit is None. Fixes #124. --- pylast/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index fe6873e..51bb5a1 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -396,7 +396,7 @@ class _Network(object): seq = [] for node in doc.getElementsByTagName("tag"): - if len(seq) >= limit: + if limit and len(seq) >= limit: break tag = Tag(_extract(node, "name"), self) weight = _number(_extract(node, "count")) From 97ec6f84fc72c35d7ae84838a1ce8f565e18ebc1 Mon Sep 17 00:00:00 2001 From: hugovk Date: Sun, 26 Apr 2015 20:14:09 +0300 Subject: [PATCH 6/8] Add EditorConfig --- .editorconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..de5533f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 + +# 4 space indentation +[*.py] +indent_size = 4 +indent_style = space From 88a74273a0d852ae3b7888c2017849305caeef22 Mon Sep 17 00:00:00 2001 From: hugovk Date: Sun, 26 Apr 2015 21:26:21 +0300 Subject: [PATCH 7/8] Sometimes Last.fm returns an error for dates[1]: No chart available for this user/date-range combination --- tests/test_pylast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index e3581b9..ee14679 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -1236,7 +1236,7 @@ class TestPyLast(unittest.TestCase): self.helper_dates_valid(dates) # Act/Assert - self.helper_get_assert_charts(lastfm_user, dates[1]) + self.helper_get_assert_charts(lastfm_user, dates[0]) def test_track_top_fans(self): # Arrange From e26b542bec72a70ce53a5eb26a07bdeae08024e5 Mon Sep 17 00:00:00 2001 From: hugovk Date: Sun, 26 Apr 2015 22:18:58 +0300 Subject: [PATCH 8/8] Retry failures up to four times, require at least one pass --- tests/test_pylast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index ee14679..1574d13 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -31,7 +31,7 @@ def load_secrets(): return doc -@flaky +@flaky(max_runs=5, min_passes=1) class TestPyLast(unittest.TestCase): secrets = None