Format with Black and isort
This commit is contained in:
parent
2d570b97ff
commit
0f96fe58b1
|
@ -6,7 +6,7 @@ repos:
|
||||||
args: ["--py3-plus"]
|
args: ["--py3-plus"]
|
||||||
|
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 19.10b0
|
rev: 20.8b1
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
args: ["--target-version", "py35"]
|
args: ["--target-version", "py35"]
|
||||||
|
@ -15,7 +15,7 @@ repos:
|
||||||
types: []
|
types: []
|
||||||
|
|
||||||
- repo: https://github.com/PyCQA/isort
|
- repo: https://github.com/PyCQA/isort
|
||||||
rev: 5.5.1
|
rev: 5.5.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
|
|
||||||
|
|
|
@ -146,29 +146,29 @@ class _Network:
|
||||||
token=None,
|
token=None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
name: the name of the network
|
name: the name of the network
|
||||||
homepage: the homepage URL
|
homepage: the homepage URL
|
||||||
ws_server: the URL of the webservices server
|
ws_server: the URL of the webservices server
|
||||||
api_key: a provided API_KEY
|
api_key: a provided API_KEY
|
||||||
api_secret: a provided API_SECRET
|
api_secret: a provided API_SECRET
|
||||||
session_key: a generated session_key or None
|
session_key: a generated session_key or None
|
||||||
username: a username of a valid user
|
username: a username of a valid user
|
||||||
password_hash: the output of pylast.md5(password) where password is
|
password_hash: the output of pylast.md5(password) where password is
|
||||||
the user's password
|
the user's password
|
||||||
domain_names: a dict mapping each DOMAIN_* value to a string domain
|
domain_names: a dict mapping each DOMAIN_* value to a string domain
|
||||||
name
|
name
|
||||||
urls: a dict mapping types to URLs
|
urls: a dict mapping types to URLs
|
||||||
token: an authentication token to retrieve a session
|
token: an authentication token to retrieve a session
|
||||||
|
|
||||||
if username and password_hash were provided and not session_key,
|
if username and password_hash were provided and not session_key,
|
||||||
session_key will be generated automatically when needed.
|
session_key will be generated automatically when needed.
|
||||||
|
|
||||||
Either a valid session_key or a combination of username and
|
Either a valid session_key or a combination of username and
|
||||||
password_hash must be present for scrobbling.
|
password_hash must be present for scrobbling.
|
||||||
|
|
||||||
You should use a preconfigured network object through a
|
You should use a preconfigured network object through a
|
||||||
get_*_network(...) method instead of creating an object
|
get_*_network(...) method instead of creating an object
|
||||||
of this class, unless you know what you're doing.
|
of this class, unless you know what you're doing.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -209,56 +209,56 @@ class _Network:
|
||||||
|
|
||||||
def get_artist(self, artist_name):
|
def get_artist(self, artist_name):
|
||||||
"""
|
"""
|
||||||
Return an Artist object
|
Return an Artist object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return Artist(artist_name, self)
|
return Artist(artist_name, self)
|
||||||
|
|
||||||
def get_track(self, artist, title):
|
def get_track(self, artist, title):
|
||||||
"""
|
"""
|
||||||
Return a Track object
|
Return a Track object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return Track(artist, title, self)
|
return Track(artist, title, self)
|
||||||
|
|
||||||
def get_album(self, artist, title):
|
def get_album(self, artist, title):
|
||||||
"""
|
"""
|
||||||
Return an Album object
|
Return an Album object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return Album(artist, title, self)
|
return Album(artist, title, self)
|
||||||
|
|
||||||
def get_authenticated_user(self):
|
def get_authenticated_user(self):
|
||||||
"""
|
"""
|
||||||
Returns the authenticated user
|
Returns the authenticated user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return AuthenticatedUser(self)
|
return AuthenticatedUser(self)
|
||||||
|
|
||||||
def get_country(self, country_name):
|
def get_country(self, country_name):
|
||||||
"""
|
"""
|
||||||
Returns a country object
|
Returns a country object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return Country(country_name, self)
|
return Country(country_name, self)
|
||||||
|
|
||||||
def get_user(self, username):
|
def get_user(self, username):
|
||||||
"""
|
"""
|
||||||
Returns a user object
|
Returns a user object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return User(username, self)
|
return User(username, self)
|
||||||
|
|
||||||
def get_tag(self, name):
|
def get_tag(self, name):
|
||||||
"""
|
"""
|
||||||
Returns a tag object
|
Returns a tag object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return Tag(name, self)
|
return Tag(name, self)
|
||||||
|
|
||||||
def _get_language_domain(self, domain_language):
|
def _get_language_domain(self, domain_language):
|
||||||
"""
|
"""
|
||||||
Returns the mapped domain name of the network to a DOMAIN_* value
|
Returns the mapped domain name of the network to a DOMAIN_* value
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if domain_language in self.domain_names:
|
if domain_language in self.domain_names:
|
||||||
|
@ -271,13 +271,13 @@ class _Network:
|
||||||
|
|
||||||
def _get_ws_auth(self):
|
def _get_ws_auth(self):
|
||||||
"""
|
"""
|
||||||
Returns an (API_KEY, API_SECRET, SESSION_KEY) tuple.
|
Returns an (API_KEY, API_SECRET, SESSION_KEY) tuple.
|
||||||
"""
|
"""
|
||||||
return self.api_key, self.api_secret, self.session_key
|
return self.api_key, self.api_secret, self.session_key
|
||||||
|
|
||||||
def _delay_call(self):
|
def _delay_call(self):
|
||||||
"""
|
"""
|
||||||
Makes sure that web service calls are at least 0.2 seconds apart.
|
Makes sure that web service calls are at least 0.2 seconds apart.
|
||||||
"""
|
"""
|
||||||
now = time.time()
|
now = time.time()
|
||||||
|
|
||||||
|
@ -1408,31 +1408,31 @@ class WSError(Exception):
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
"""Returns the exception ID, from one of the following:
|
"""Returns the exception ID, from one of the following:
|
||||||
STATUS_INVALID_SERVICE = 2
|
STATUS_INVALID_SERVICE = 2
|
||||||
STATUS_INVALID_METHOD = 3
|
STATUS_INVALID_METHOD = 3
|
||||||
STATUS_AUTH_FAILED = 4
|
STATUS_AUTH_FAILED = 4
|
||||||
STATUS_INVALID_FORMAT = 5
|
STATUS_INVALID_FORMAT = 5
|
||||||
STATUS_INVALID_PARAMS = 6
|
STATUS_INVALID_PARAMS = 6
|
||||||
STATUS_INVALID_RESOURCE = 7
|
STATUS_INVALID_RESOURCE = 7
|
||||||
STATUS_OPERATION_FAILED = 8
|
STATUS_OPERATION_FAILED = 8
|
||||||
STATUS_INVALID_SK = 9
|
STATUS_INVALID_SK = 9
|
||||||
STATUS_INVALID_API_KEY = 10
|
STATUS_INVALID_API_KEY = 10
|
||||||
STATUS_OFFLINE = 11
|
STATUS_OFFLINE = 11
|
||||||
STATUS_SUBSCRIBERS_ONLY = 12
|
STATUS_SUBSCRIBERS_ONLY = 12
|
||||||
STATUS_TOKEN_UNAUTHORIZED = 14
|
STATUS_TOKEN_UNAUTHORIZED = 14
|
||||||
STATUS_TOKEN_EXPIRED = 15
|
STATUS_TOKEN_EXPIRED = 15
|
||||||
STATUS_TEMPORARILY_UNAVAILABLE = 16
|
STATUS_TEMPORARILY_UNAVAILABLE = 16
|
||||||
STATUS_LOGIN_REQUIRED = 17
|
STATUS_LOGIN_REQUIRED = 17
|
||||||
STATUS_TRIAL_EXPIRED = 18
|
STATUS_TRIAL_EXPIRED = 18
|
||||||
STATUS_NOT_ENOUGH_CONTENT = 20
|
STATUS_NOT_ENOUGH_CONTENT = 20
|
||||||
STATUS_NOT_ENOUGH_MEMBERS = 21
|
STATUS_NOT_ENOUGH_MEMBERS = 21
|
||||||
STATUS_NOT_ENOUGH_FANS = 22
|
STATUS_NOT_ENOUGH_FANS = 22
|
||||||
STATUS_NOT_ENOUGH_NEIGHBOURS = 23
|
STATUS_NOT_ENOUGH_NEIGHBOURS = 23
|
||||||
STATUS_NO_PEAK_RADIO = 24
|
STATUS_NO_PEAK_RADIO = 24
|
||||||
STATUS_RADIO_NOT_FOUND = 25
|
STATUS_RADIO_NOT_FOUND = 25
|
||||||
STATUS_API_KEY_SUSPENDED = 26
|
STATUS_API_KEY_SUSPENDED = 26
|
||||||
STATUS_DEPRECATED = 27
|
STATUS_DEPRECATED = 27
|
||||||
STATUS_RATE_LIMIT_EXCEEDED = 29
|
STATUS_RATE_LIMIT_EXCEEDED = 29
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self.status
|
return self.status
|
||||||
|
@ -2937,8 +2937,8 @@ def _url_safe(text):
|
||||||
|
|
||||||
def _number(string):
|
def _number(string):
|
||||||
"""
|
"""
|
||||||
Extracts an int from a string.
|
Extracts an int from a string.
|
||||||
Returns a 0 if None or an empty string was passed.
|
Returns a 0 if None or an empty string was passed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not string:
|
if not string:
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
"""
|
"""
|
||||||
Integration (not unit) tests for pylast.py
|
Integration (not unit) tests for pylast.py
|
||||||
"""
|
"""
|
||||||
import pylast
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import pylast
|
||||||
|
|
||||||
from .test_pylast import WRITE_TEST, TestPyLastWithLastFm
|
from .test_pylast import WRITE_TEST, TestPyLastWithLastFm
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
"""
|
"""
|
||||||
Integration (not unit) tests for pylast.py
|
Integration (not unit) tests for pylast.py
|
||||||
"""
|
"""
|
||||||
import pylast
|
|
||||||
from flaky import flaky
|
from flaky import flaky
|
||||||
|
|
||||||
|
import pylast
|
||||||
|
|
||||||
from .test_pylast import PyLastTestCase, load_secrets
|
from .test_pylast import PyLastTestCase, load_secrets
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,10 @@ Integration (not unit) tests for pylast.py
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import pylast
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import pylast
|
||||||
|
|
||||||
from .test_pylast import WRITE_TEST, TestPyLastWithLastFm
|
from .test_pylast import WRITE_TEST, TestPyLastWithLastFm
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,11 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import pylast
|
|
||||||
import pytest
|
import pytest
|
||||||
from flaky import flaky
|
from flaky import flaky
|
||||||
|
|
||||||
|
import pylast
|
||||||
|
|
||||||
WRITE_TEST = sys.version_info[:2] == (3, 8)
|
WRITE_TEST = sys.version_info[:2] == (3, 8)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,10 @@ Integration (not unit) tests for pylast.py
|
||||||
"""
|
"""
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import pylast
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import pylast
|
||||||
|
|
||||||
from .test_pylast import WRITE_TEST, TestPyLastWithLastFm
|
from .test_pylast import WRITE_TEST, TestPyLastWithLastFm
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,10 @@ import os
|
||||||
import re
|
import re
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import pylast
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import pylast
|
||||||
|
|
||||||
from .test_pylast import TestPyLastWithLastFm
|
from .test_pylast import TestPyLastWithLastFm
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import pylast
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import pylast
|
||||||
|
|
||||||
|
|
||||||
def mock_network():
|
def mock_network():
|
||||||
return mock.Mock(_get_ws_auth=mock.Mock(return_value=("", "", "")))
|
return mock.Mock(_get_ws_auth=mock.Mock(return_value=("", "", "")))
|
||||||
|
|
Loading…
Reference in a new issue