aboutsummaryrefslogtreecommitdiff
path: root/pandora
diff options
context:
space:
mode:
authorHugo <hugovk@users.noreply.github.com>2019-04-07 18:17:11 +0300
committerMike Crute <crutem@amazon.com>2019-04-07 10:11:23 -0700
commit6b7990a3de49ebf9483a70003a20dd6636e8c000 (patch)
tree7fa4c6eefe49067588d5cef3640cf12bba9cf90e /pandora
parent5087590bff74bb5bb71c9ae6c51bc6f27646a04b (diff)
downloadpydora-6b7990a3de49ebf9483a70003a20dd6636e8c000.tar.bz2
pydora-6b7990a3de49ebf9483a70003a20dd6636e8c000.tar.xz
pydora-6b7990a3de49ebf9483a70003a20dd6636e8c000.zip
Upgrade Python syntax with pyupgrade --py3-plus
Diffstat (limited to 'pandora')
-rw-r--r--pandora/client.py2
-rw-r--r--pandora/clientbuilder.py10
-rw-r--r--pandora/errors.py2
-rw-r--r--pandora/models/_base.py8
-rw-r--r--pandora/models/ad.py2
-rw-r--r--pandora/transport.py12
6 files changed, 18 insertions, 18 deletions
diff --git a/pandora/client.py b/pandora/client.py
index b077954..bb30738 100644
--- a/pandora/client.py
+++ b/pandora/client.py
@@ -16,7 +16,7 @@ instance of a client.
16from . import errors 16from . import errors
17 17
18 18
19class BaseAPIClient(object): 19class BaseAPIClient:
20 """Base Pandora API Client 20 """Base Pandora API Client
21 21
22 The base API client has lower level methods that are composed together to 22 The base API client has lower level methods that are composed together to
diff --git a/pandora/clientbuilder.py b/pandora/clientbuilder.py
index 7543df7..bc55cec 100644
--- a/pandora/clientbuilder.py
+++ b/pandora/clientbuilder.py
@@ -30,7 +30,7 @@ class TranslatingDict(dict):
30 VALUE_TRANSLATIONS = None 30 VALUE_TRANSLATIONS = None
31 31
32 def __init__(self, initial=None): 32 def __init__(self, initial=None):
33 super(TranslatingDict, self).__init__() 33 super().__init__()
34 34
35 assert self.KEY_TRANSLATIONS is not None 35 assert self.KEY_TRANSLATIONS is not None
36 assert self.VALUE_TRANSLATIONS is not None 36 assert self.VALUE_TRANSLATIONS is not None
@@ -70,11 +70,11 @@ class TranslatingDict(dict):
70 70
71 def __setitem__(self, key, value): 71 def __setitem__(self, key, value):
72 key = self.translate_key(key) 72 key = self.translate_key(key)
73 super(TranslatingDict, self).__setitem__( 73 super().__setitem__(
74 key, self.translate_value(key, value)) 74 key, self.translate_value(key, value))
75 75
76 76
77class APIClientBuilder(object): 77class APIClientBuilder:
78 """Abstract API Client Builder 78 """Abstract API Client Builder
79 79
80 Provides the basic functions for building an API client. Expects a 80 Provides the basic functions for building an API client. Expects a
@@ -141,7 +141,7 @@ class SettingsDictBuilder(APIClientBuilder):
141 141
142 def __init__(self, settings, **kwargs): 142 def __init__(self, settings, **kwargs):
143 self.settings = settings 143 self.settings = settings
144 super(SettingsDictBuilder, self).__init__(**kwargs) 144 super().__init__(**kwargs)
145 145
146 def build(self): 146 def build(self):
147 settings = SettingsDict(self.settings) 147 settings = SettingsDict(self.settings)
@@ -160,7 +160,7 @@ class FileBasedClientBuilder(APIClientBuilder):
160 def __init__(self, path=None, authenticate=True, **kwargs): 160 def __init__(self, path=None, authenticate=True, **kwargs):
161 self.path = path or self.DEFAULT_CONFIG_FILE 161 self.path = path or self.DEFAULT_CONFIG_FILE
162 self.authenticate = authenticate 162 self.authenticate = authenticate
163 super(FileBasedClientBuilder, self).__init__(**kwargs) 163 super().__init__(**kwargs)
164 164
165 @property 165 @property
166 def file_exists(self): 166 def file_exists(self):
diff --git a/pandora/errors.py b/pandora/errors.py
index ba377b5..c978708 100644
--- a/pandora/errors.py
+++ b/pandora/errors.py
@@ -56,7 +56,7 @@ class PandoraException(Exception):
56 56
57 def __init__(self, extended_message=""): 57 def __init__(self, extended_message=""):
58 self.extended_message = extended_message 58 self.extended_message = extended_message
59 super(PandoraException, self).__init__(self.message) 59 super().__init__(self.message)
60 60
61 @classmethod 61 @classmethod
62 def from_code(cls, code, extended_message): 62 def from_code(cls, code, extended_message):
diff --git a/pandora/models/_base.py b/pandora/models/_base.py
index 214f3c1..5689cdf 100644
--- a/pandora/models/_base.py
+++ b/pandora/models/_base.py
@@ -26,7 +26,7 @@ class Field(namedtuple("Field", ["field", "default", "formatter", "model"])):
26 """ 26 """
27 27
28 def __new__(cls, field, default=None, formatter=None, model=None): 28 def __new__(cls, field, default=None, formatter=None, model=None):
29 return super(Field, cls).__new__(cls, field, default, formatter, model) 29 return super().__new__(cls, field, default, formatter, model)
30 30
31 31
32class SyntheticField(namedtuple("SyntheticField", ["field"])): 32class SyntheticField(namedtuple("SyntheticField", ["field"])):
@@ -84,10 +84,10 @@ class ModelMetaClass(type):
84 fields[key] = val 84 fields[key] = val
85 del new_dct[key] 85 del new_dct[key]
86 86
87 return super(ModelMetaClass, cls).__new__(cls, name, parents, new_dct) 87 return super().__new__(cls, name, parents, new_dct)
88 88
89 89
90class PandoraModel(object, metaclass=ModelMetaClass): 90class PandoraModel(metaclass=ModelMetaClass):
91 """Pandora API Model 91 """Pandora API Model
92 92
93 A single object representing a Pandora data object. Subclasses are 93 A single object representing a Pandora data object. Subclasses are
@@ -208,7 +208,7 @@ class PandoraListModel(PandoraModel, list):
208 __index_key__ = None 208 __index_key__ = None
209 209
210 def __init__(self, *args, **kwargs): 210 def __init__(self, *args, **kwargs):
211 super(PandoraListModel, self).__init__(*args, **kwargs) 211 super().__init__(*args, **kwargs)
212 self._index = {} 212 self._index = {}
213 213
214 @classmethod 214 @classmethod
diff --git a/pandora/models/ad.py b/pandora/models/ad.py
index 91820c9..040c76b 100644
--- a/pandora/models/ad.py
+++ b/pandora/models/ad.py
@@ -33,7 +33,7 @@ class AdItem(PlaylistModel):
33 except ParameterMissing as exc: 33 except ParameterMissing as exc:
34 if self.tracking_tokens: 34 if self.tracking_tokens:
35 raise exc 35 raise exc
36 return super(AdItem, self).prepare_playback() 36 return super().prepare_playback()
37 37
38 def thumbs_up(self): # pragma: no cover 38 def thumbs_up(self): # pragma: no cover
39 return 39 return
diff --git a/pandora/transport.py b/pandora/transport.py
index 6f1a174..721882d 100644
--- a/pandora/transport.py
+++ b/pandora/transport.py
@@ -94,12 +94,12 @@ class RetryingSession(requests.Session):
94 """ 94 """
95 95
96 def __init__(self): 96 def __init__(self):
97 super(RetryingSession, self).__init__() 97 super().__init__()
98 self.mount('https://', HTTPAdapter(max_retries=3)) 98 self.mount('https://', HTTPAdapter(max_retries=3))
99 self.mount('http://', HTTPAdapter(max_retries=3)) 99 self.mount('http://', HTTPAdapter(max_retries=3))
100 100
101 101
102class APITransport(object): 102class APITransport:
103 """Pandora API Transport 103 """Pandora API Transport
104 104
105 The transport is responsible for speaking the low-level protocol required 105 The transport is responsible for speaking the low-level protocol required
@@ -161,7 +161,7 @@ class APITransport(object):
161 return int(self.server_sync_time + (time.time() - self.start_time)) 161 return int(self.server_sync_time + (time.time() - self.start_time))
162 162
163 def remove_empty_values(self, data): 163 def remove_empty_values(self, data):
164 return dict((k, v) for k, v in data.items() if v is not None) 164 return {k: v for k, v in data.items() if v is not None}
165 165
166 @sync_time.setter 166 @sync_time.setter
167 def sync_time(self, sync_time): 167 def sync_time(self, sync_time):
@@ -198,7 +198,7 @@ class APITransport(object):
198 } 198 }
199 199
200 def _build_url(self, method): 200 def _build_url(self, method):
201 return "{0}://{1}".format( 201 return "{}://{}".format(
202 "https" if method in self.REQUIRE_TLS else "http", 202 "https" if method in self.REQUIRE_TLS else "http",
203 self.api_host) 203 self.api_host)
204 204
@@ -236,7 +236,7 @@ class APITransport(object):
236 return self._parse_response(result) 236 return self._parse_response(result)
237 237
238 238
239class BlowfishCryptor(object): 239class BlowfishCryptor:
240 """Low-Level Blowfish Cryptography 240 """Low-Level Blowfish Cryptography
241 241
242 Handles symmetric Blowfish cryptography of raw byte messages with or 242 Handles symmetric Blowfish cryptography of raw byte messages with or
@@ -285,7 +285,7 @@ class PurePythonBlowfish(BlowfishCryptor):
285 return b"".join(self.cipher.encrypt_ecb(self._add_padding(data))) 285 return b"".join(self.cipher.encrypt_ecb(self._add_padding(data)))
286 286
287 287
288class Encryptor(object): 288class Encryptor:
289 """Pandora Blowfish Encryptor 289 """Pandora Blowfish Encryptor
290 290
291 The blowfish encryptor can encrypt and decrypt the relevant parts of the 291 The blowfish encryptor can encrypt and decrypt the relevant parts of the