python3-discogs-client 2.5__tar.gz → 2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python3-discogs-client-2.5/python3_discogs_client.egg-info → python3-discogs-client-2.7}/PKG-INFO +1 -1
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/__init__.py +1 -1
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/client.py +26 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/fetchers.py +8 -3
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/models.py +4 -1
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/test_core.py +32 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/test_models.py +3 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7/python3_discogs_client.egg-info}/PKG-INFO +1 -1
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/setup.py +1 -1
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/LICENSE +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/MANIFEST.in +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/exceptions.py +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/__init__.py +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/artists/1/releases_per_page=50&page=1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/artists/1/releases_per_page=50&page=2.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/artists/1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/artists/2.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/artists/3.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/database/search_artist=trash80&per_page=50&page=1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/database/search_artist=trash80&title=icarus&per_page=50&page=1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/database/search_q=trash%2080&per_page=50&page=1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/database/search_q=trash80&per_page=50&page=1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/labels/1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/labels/31405.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/lists/1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/marketplace/fee/20.5000/EUR.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/marketplace/listings/150899904.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/marketplace/stats/1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/masters/4242/versions_per_page=50&page=1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/masters/4242.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/oauth/identity.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/releases/1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/releases/2.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/releases/3.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/releases/3329867.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/releases/79.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/users/example/collection/folders/0/releases_page=1&per_page=50.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/users/example/collection/folders.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/users/example/collection/value.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/users/example/inventory_per_page=50&page=1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/users/example/wants_per_page=50&page=1.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/users/example.json +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/test_fetchers.py +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/test_utils.py +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/utils.py +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/python3_discogs_client.egg-info/SOURCES.txt +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/python3_discogs_client.egg-info/dependency_links.txt +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/python3_discogs_client.egg-info/requires.txt +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/python3_discogs_client.egg-info/top_level.txt +0 -0
- {python3-discogs-client-2.5 → python3-discogs-client-2.7}/setup.cfg +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
+
from typing import Union
|
|
2
3
|
from urllib.parse import urlencode
|
|
3
4
|
|
|
4
5
|
from discogs_client import models
|
|
@@ -193,3 +194,28 @@ class Client:
|
|
|
193
194
|
if not isinstance(value, bool):
|
|
194
195
|
raise ValueError("Backoff enabled toggle should be of type bool")
|
|
195
196
|
self._fetcher.backoff_enabled = value
|
|
197
|
+
|
|
198
|
+
@property
|
|
199
|
+
def connection_timeout(self):
|
|
200
|
+
"""Return current client connection timeout"""
|
|
201
|
+
return self._fetcher.connect_timeout
|
|
202
|
+
|
|
203
|
+
@property
|
|
204
|
+
def read_timeout(self):
|
|
205
|
+
"""Return current client read timeout"""
|
|
206
|
+
return self._fetcher.read_timeout
|
|
207
|
+
|
|
208
|
+
def set_timeout(self,
|
|
209
|
+
connect: Union[int, float] = 5,
|
|
210
|
+
read: Union[int, float] = 10) -> None:
|
|
211
|
+
"""Set request timeout parameters
|
|
212
|
+
|
|
213
|
+
Parameters
|
|
214
|
+
----------
|
|
215
|
+
connect : (Union[int, float], optional)
|
|
216
|
+
Time in seconds after which connect will timeout. Defaults to 5.
|
|
217
|
+
read : (Union[int, float], optional)
|
|
218
|
+
Time in seconds after which request will timeout. Defaults to 10.
|
|
219
|
+
"""
|
|
220
|
+
self._fetcher.connect_timeout = connect
|
|
221
|
+
self._fetcher.read_timeout = read
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import requests
|
|
2
1
|
from requests.api import request
|
|
3
2
|
from oauthlib import oauth1
|
|
4
3
|
import json
|
|
@@ -6,6 +5,7 @@ import os
|
|
|
6
5
|
import re
|
|
7
6
|
from discogs_client.utils import backoff
|
|
8
7
|
from urllib.parse import parse_qsl
|
|
8
|
+
from typing import Union
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class Fetcher:
|
|
@@ -16,6 +16,8 @@ class Fetcher:
|
|
|
16
16
|
(It's a slightly leaky abstraction designed to make testing easier.)
|
|
17
17
|
"""
|
|
18
18
|
backoff_enabled = True
|
|
19
|
+
connect_timeout: Union[float, int, None] = None
|
|
20
|
+
read_timeout: Union[float, int, None] = None
|
|
19
21
|
|
|
20
22
|
def fetch(self, client, method, url, data=None, headers=None, json=True):
|
|
21
23
|
"""Fetch the given request
|
|
@@ -52,8 +54,11 @@ class Fetcher:
|
|
|
52
54
|
|
|
53
55
|
@backoff
|
|
54
56
|
def request(self, method, url, data, headers, params=None):
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
return request(
|
|
58
|
+
method=method, url=url, data=data,
|
|
59
|
+
headers=headers, params=params,
|
|
60
|
+
timeout=(self.connect_timeout, self.read_timeout)
|
|
61
|
+
)
|
|
57
62
|
|
|
58
63
|
|
|
59
64
|
class LoggingDelegator:
|
|
@@ -478,7 +478,10 @@ class Artist(PrimaryAPIObject):
|
|
|
478
478
|
#: single string, for example: "DJ ABC Feat MC Z". Also check out the
|
|
479
479
|
#: ``artists_sort`` attribute of a ``Release`` object.
|
|
480
480
|
join = SimpleField()
|
|
481
|
-
|
|
481
|
+
#: This attribute is only present when an ``Artist`` object is part of a
|
|
482
|
+
#: ``credits`` list of a ``Release`` object.
|
|
483
|
+
role = SimpleField()
|
|
484
|
+
|
|
482
485
|
def __init__(self, client, dict_):
|
|
483
486
|
super(Artist, self).__init__(client, dict_)
|
|
484
487
|
self.data['resource_url'] = '{0}/artists/{1}'.format(client._base_url, dict_['id'])
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
from discogs_client import Client
|
|
3
|
+
from discogs_client.fetchers import MemoryFetcher
|
|
3
4
|
from discogs_client.tests import DiscogsClientTestCase
|
|
4
5
|
from discogs_client.exceptions import ConfigurationError, HTTPError
|
|
5
6
|
from datetime import datetime
|
|
@@ -110,6 +111,37 @@ class CoreTestCase(DiscogsClientTestCase):
|
|
|
110
111
|
results.per_page = 10
|
|
111
112
|
self.assertTrue(results._num_pages is None)
|
|
112
113
|
|
|
114
|
+
def test_timeout_defaults_to_none(self):
|
|
115
|
+
# Need to create client without LoggingDelegator here
|
|
116
|
+
# self.d would throw AttributeError trying to access timeout properties on LoggingDelegator
|
|
117
|
+
client = Client('')
|
|
118
|
+
client._fetcher = MemoryFetcher({})
|
|
119
|
+
self.assertEqual(None, client.connection_timeout)
|
|
120
|
+
self.assertEqual(None, client.read_timeout)
|
|
121
|
+
|
|
122
|
+
def test_set_timeout_in_float(self):
|
|
123
|
+
self.d.set_timeout(connect=1.23, read=7.42)
|
|
124
|
+
self.assertEqual(1.23, self.d.connection_timeout)
|
|
125
|
+
self.assertEqual(7.42, self.d.read_timeout)
|
|
126
|
+
|
|
127
|
+
def test_set_timeout_in_int(self):
|
|
128
|
+
self.d.set_timeout(connect=3, read=6)
|
|
129
|
+
self.assertEqual(3, self.d.connection_timeout)
|
|
130
|
+
self.assertEqual(6, self.d.read_timeout)
|
|
131
|
+
|
|
132
|
+
def test_set_timeout_to_none(self):
|
|
133
|
+
self.d.set_timeout(connect=5, read=None)
|
|
134
|
+
self.assertEqual(5, self.d.connection_timeout)
|
|
135
|
+
self.assertEqual(None, self.d.read_timeout)
|
|
136
|
+
|
|
137
|
+
self.d.set_timeout(connect=None, read=10)
|
|
138
|
+
self.assertEqual(None, self.d.connection_timeout)
|
|
139
|
+
self.assertEqual(10, self.d.read_timeout)
|
|
140
|
+
|
|
141
|
+
self.d.set_timeout(connect=None, read=None)
|
|
142
|
+
self.assertEqual(None, self.d.connection_timeout)
|
|
143
|
+
self.assertEqual(None, self.d.read_timeout)
|
|
144
|
+
|
|
113
145
|
|
|
114
146
|
def suite():
|
|
115
147
|
suite = unittest.TestSuite()
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/test_models.py
RENAMED
|
@@ -9,6 +9,9 @@ class ModelsTestCase(DiscogsClientTestCase):
|
|
|
9
9
|
"""Artists can be fetched and parsed"""
|
|
10
10
|
a = self.d.artist(1)
|
|
11
11
|
self.assertEqual(a.name, 'Persuader, The')
|
|
12
|
+
a2 = self.d.release(1).credits[0]
|
|
13
|
+
self.assertEqual(a2.name, 'Jesper Dahlbäck')
|
|
14
|
+
self.assertEqual(a2.role, 'Music By [All Tracks By]')
|
|
12
15
|
|
|
13
16
|
def test_same_artist(self):
|
|
14
17
|
"""Artists can be fetched and parsed multiple times"""
|
|
@@ -4,7 +4,7 @@ from setuptools import setup
|
|
|
4
4
|
|
|
5
5
|
setup(
|
|
6
6
|
name='python3-discogs-client',
|
|
7
|
-
version='2.
|
|
7
|
+
version='2.7',
|
|
8
8
|
description='Python API client for Discogs',
|
|
9
9
|
long_description='This is an active fork of the official "Discogs API client for Python", which was deprecated by discogs.com as of June 2020. We think it is a very useful Python module and decided to continue maintaining it. Please visit: https://github.com/joalla/discogs_client for more information.',
|
|
10
10
|
url='https://github.com/joalla/discogs_client',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/artists/1.json
RENAMED
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/artists/2.json
RENAMED
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/artists/3.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/labels/1.json
RENAMED
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/labels/31405.json
RENAMED
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/lists/1.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/masters/4242.json
RENAMED
|
File without changes
|
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/releases/1.json
RENAMED
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/releases/2.json
RENAMED
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/releases/3.json
RENAMED
|
File without changes
|
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/res/releases/79.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/test_fetchers.py
RENAMED
|
File without changes
|
{python3-discogs-client-2.5 → python3-discogs-client-2.7}/discogs_client/tests/test_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|