From 0ae79be3a0de000e386f149d6428814998d2d8a2 Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 26 Dec 2014 17:16:41 +0200 Subject: [PATCH 1/9] Add pypy3; track coverage in Scrutinizer --- .scrutinizer.yml | 9 +++++++++ .travis.yml | 10 +++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .scrutinizer.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..43dbfa3 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,9 @@ +checks: + python: + code_rating: true + duplicate_code: true +filter: + excluded_paths: + - '*/test/*' +tools: + external_code_coverage: true diff --git a/.travis.yml b/.travis.yml index ceca581..9271b54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,17 +5,20 @@ python: - "3.3" - "3.4" - "pypy" +- "pypy3" sudo: false install: -- pip install -r test_requirements.txt -- pip install coveralls +- travis_retry pip install -r test_requirements.txt +- travis_retry pip install coveralls script: coverage run --source=pylast ./test_pylast.py after_success: - coveralls +- coveralls +- travis_retry pip install scrutinizer-ocular +- ocular after_script: - coverage report @@ -36,4 +39,5 @@ matrix: allow_failures: - python: "3.4" - python: "pypy" + - python: "pypy3" fast_finish: true From 0a158e72383f86132ac67e5e45f1d95589a75f18 Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 26 Dec 2014 17:31:10 +0200 Subject: [PATCH 2/9] Landscape.io fixes --- pylast.py | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/pylast.py b/pylast.py index dda9720..132ed72 100644 --- a/pylast.py +++ b/pylast.py @@ -312,9 +312,9 @@ class _Network(object): if domain_language in self.domain_names: return self.domain_names[domain_language] - def _get_url(self, domain, type): + def _get_url(self, domain, url_type): return "http://%s/%s" % ( - self._get_language_domain(domain), self.urls[type]) + self._get_language_domain(domain), self.urls[url_type]) def _get_ws_auth(self): """ @@ -404,14 +404,14 @@ class _Network(object): return seq def get_geo_events( - self, long=None, lat=None, location=None, distance=None, + self, longitude=None, latitude=None, location=None, distance=None, tag=None, festivalsonly=None, limit=None, cacheable=True): """ Returns all events in a specific location by country or city name. Parameters: - long (Optional) : Specifies a longitude value to retrieve events for - (service returns nearby events by default) - lat (Optional) : Specifies a latitude value to retrieve events for + longitude (Optional) : Specifies a longitude value to retrieve events + for (service returns nearby events by default) + latitude (Optional) : Specifies a latitude value to retrieve events for (service returns nearby events by default) location (Optional) : Specifies a location to retrieve events for (service returns nearby events by default) @@ -426,10 +426,10 @@ class _Network(object): params = {} - if long: - params["long"] = long - if lat: - params["lat"] = lat + if longitude: + params["long"] = longlongitude + if latitude: + params["lat"] = latitude if location: params["location"] = location if limit: @@ -768,17 +768,17 @@ class _Network(object): if remaining_tracks: self.scrobble_many(remaining_tracks) - def get_play_links(self, type, things, cacheable=True): + def get_play_links(self, link_type, things, cacheable=True): method = type + ".getPlaylinks" params = {} for i, thing in enumerate(things): - if type == "artist": + if link_type == "artist": params['artist[' + str(i) + ']'] = thing - elif type == "album": + elif link_type == "album": params['artist[' + str(i) + ']'] = thing.artist params['album[' + str(i) + ']'] = thing.title - elif type == "track": + elif link_type == "track": params['artist[' + str(i) + ']'] = thing.artist params['track[' + str(i) + ']'] = thing.title @@ -793,13 +793,13 @@ class _Network(object): return seq def get_artist_play_links(self, artists, cacheable=True): - return self.get_play_links("artist", artists) + return self.get_play_links("artist", artists, cacheable) def get_album_play_links(self, albums, cacheable=True): - return self.get_play_links("album", albums) + return self.get_play_links("album", albums, cacheable) def get_track_play_links(self, tracks, cacheable=True): - return self.get_play_links("track", tracks) + return self.get_play_links("track", tracks, cacheable) class LastFMNetwork(_Network): @@ -2089,6 +2089,8 @@ class Artist(_BaseObject, _Taggable): """ The artist.getImages method has been deprecated by Last.fm. """ + assert order # silence warnings + assert limit # silence warnings raise WSError( self.network, "27", "The artist.getImages method has been deprecated by Last.fm.") @@ -2717,7 +2719,7 @@ class Playlist(_BaseObject): __hash__ = _BaseObject.__hash__ - def __init__(self, user, id, network): + def __init__(self, user, playlist_id, network): _BaseObject.__init__(self, network, "playlist") if isinstance(user, User): @@ -2725,7 +2727,7 @@ class Playlist(_BaseObject): else: self.user = User(user, self.network) - self.id = id + self.id = playlist_id @_string_output def __str__(self): @@ -3897,10 +3899,10 @@ class Venue(_BaseObject): __hash__ = _BaseObject.__hash__ - def __init__(self, id, network, venue_element=None): + def __init__(self, netword_id, network, venue_element=None): _BaseObject.__init__(self, network, "venue") - self.id = _number(id) + self.id = _number(netword_id) if venue_element is not None: self.info = _extract_element_tree(venue_element) self.name = self.info.get('name') @@ -4213,7 +4215,7 @@ class _ScrobblerRequest(object): def __init__(self, url, params, network, type="POST"): for key in params: - params[key] = str(params[key]) + params[key] = str(params[key]) self.params = params self.type = type From 2e560849741f3390a4d6c530980178dfba5a7bec Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 26 Dec 2014 18:57:22 +0200 Subject: [PATCH 3/9] Remove asserts which can fail --- pylast.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pylast.py b/pylast.py index 132ed72..2207b98 100644 --- a/pylast.py +++ b/pylast.py @@ -2089,8 +2089,6 @@ class Artist(_BaseObject, _Taggable): """ The artist.getImages method has been deprecated by Last.fm. """ - assert order # silence warnings - assert limit # silence warnings raise WSError( self.network, "27", "The artist.getImages method has been deprecated by Last.fm.") From 04d26a2c79f663be895b3ee4c07ff5f6cda07b45 Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 26 Dec 2014 23:12:18 +0200 Subject: [PATCH 4/9] Fix params --- test_pylast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_pylast.py b/test_pylast.py index 81dcbbc..bfdcbbe 100755 --- a/test_pylast.py +++ b/test_pylast.py @@ -870,7 +870,7 @@ class TestPyLast(unittest.TestCase): # Arrange # Act events = self.network.get_geo_events( - lat=53.466667, long=-2.233333, distance=5, limit=1) + latitude=53.466667, longitude=-2.233333, distance=5, limit=1) # Assert self.assertEqual(len(events), 1) From 5a15b3b6a61e91b6ec1e96870f4b692d4d536dd5 Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 26 Dec 2014 23:13:40 +0200 Subject: [PATCH 5/9] Fix params --- pylast.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pylast.py b/pylast.py index 2207b98..7dd418b 100644 --- a/pylast.py +++ b/pylast.py @@ -427,7 +427,7 @@ class _Network(object): params = {} if longitude: - params["long"] = longlongitude + params["long"] = longitude if latitude: params["lat"] = latitude if location: @@ -1110,7 +1110,8 @@ class _Request(object): if self.network.is_proxy_enabled(): conn = HTTPConnection( - host=self.network._get_proxy()[0], port=self.network._get_proxy()[1]) + host=self.network._get_proxy()[0], + port=self.network._get_proxy()[1]) try: conn.request( From 24f49074bfd710e96d5bed3880b8a309ebd6c966 Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 26 Dec 2014 23:20:39 +0200 Subject: [PATCH 6/9] Fix params --- pylast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylast.py b/pylast.py index 7dd418b..45ce68d 100644 --- a/pylast.py +++ b/pylast.py @@ -769,7 +769,7 @@ class _Network(object): self.scrobble_many(remaining_tracks) def get_play_links(self, link_type, things, cacheable=True): - method = type + ".getPlaylinks" + method = link_type + ".getPlaylinks" params = {} for i, thing in enumerate(things): From 79d741269ac9fa23d224b13aca0ab2c86be52267 Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 26 Dec 2014 23:32:21 +0200 Subject: [PATCH 7/9] Fix params --- test_pylast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_pylast.py b/test_pylast.py index bfdcbbe..bc5dcb8 100755 --- a/test_pylast.py +++ b/test_pylast.py @@ -422,7 +422,7 @@ class TestPyLast(unittest.TestCase): def test_playlist_is_hashable(self): # Arrange playlist = pylast.Playlist( - user="RJ", id="1k1qp_doglist", network=self.network) + user="RJ", playlist_id="1k1qp_doglist", network=self.network) # Act/Assert self.helper_is_thing_hashable(playlist) From aa022c5a71fab99d9f360c4c275d995fbb8eed0b Mon Sep 17 00:00:00 2001 From: hugovk Date: Mon, 5 Jan 2015 23:19:23 +0200 Subject: [PATCH 8/9] Don't use .build file for minor version because we define the full version in pylast.py as well --- .build | 1 - MANIFEST.in | 1 - setup.py | 20 +------------------- 3 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 .build diff --git a/.build b/.build deleted file mode 100644 index 573541a..0000000 --- a/.build +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/MANIFEST.in b/MANIFEST.in index 9e84b8c..022f2b4 100755 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,4 +3,3 @@ include setup.py include README include COPYING include INSTALL -include .build diff --git a/setup.py b/setup.py index c166df7..9579b9a 100755 --- a/setup.py +++ b/setup.py @@ -5,27 +5,9 @@ from distutils.core import setup import os -def get_build(): - path = "./.build" - - if os.path.exists(path): - fp = open(path, "r") - build = eval(fp.read()) - if os.path.exists("./.increase_build"): - build += 1 - fp.close() - else: - build = 1 - - fp = open(path, "w") - fp.write(str(build)) - fp.close() - - return str(build) - setup( name="pylast", - version="1.0." + get_build(), + version="1.0.0", author="Amr Hassan ", description=("A Python interface to Last.fm " "(and other API compatible social networks)"), From 9b9dc2e2c54f4dd68873c9085631cc3d4fa15776 Mon Sep 17 00:00:00 2001 From: hugovk Date: Mon, 5 Jan 2015 23:20:22 +0200 Subject: [PATCH 9/9] Remove unused import --- setup.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/setup.py b/setup.py index 9579b9a..baadad3 100755 --- a/setup.py +++ b/setup.py @@ -2,8 +2,6 @@ from distutils.core import setup -import os - setup( name="pylast",