diff --git a/.build b/.build deleted file mode 100644 index 573541a..0000000 --- a/.build +++ /dev/null @@ -1 +0,0 @@ -0 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 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/pylast.py b/pylast.py index 43e9eb7..8005c71 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"] = longitude + 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): - method = type + ".getPlaylinks" + def get_play_links(self, link_type, things, cacheable=True): + method = link_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): @@ -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( @@ -2717,7 +2718,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 +2726,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 +3898,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 +4214,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 diff --git a/setup.py b/setup.py index c166df7..baadad3 100755 --- a/setup.py +++ b/setup.py @@ -2,30 +2,10 @@ 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)"), diff --git a/test_pylast.py b/test_pylast.py index 81dcbbc..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) @@ -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)