aboutsummaryrefslogtreecommitdiff
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
parent5087590bff74bb5bb71c9ae6c51bc6f27646a04b (diff)
downloadpydora-6b7990a3de49ebf9483a70003a20dd6636e8c000.tar.bz2
pydora-6b7990a3de49ebf9483a70003a20dd6636e8c000.tar.xz
pydora-6b7990a3de49ebf9483a70003a20dd6636e8c000.zip
Upgrade Python syntax with pyupgrade --py3-plus
-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
-rw-r--r--pydora/audio_backend.py8
-rw-r--r--pydora/configure.py6
-rw-r--r--pydora/player.py12
-rw-r--r--pydora/utils.py16
-rwxr-xr-xsetup.py4
-rw-r--r--tests/test_pandora/test_client.py2
-rw-r--r--tests/test_pandora/test_models.py2
-rw-r--r--tests/test_pandora/test_transport.py4
14 files changed, 45 insertions, 45 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
diff --git a/pydora/audio_backend.py b/pydora/audio_backend.py
index d39bb9b..bd778ad 100644
--- a/pydora/audio_backend.py
+++ b/pydora/audio_backend.py
@@ -30,7 +30,7 @@ class PlayerUnusable(PlayerException):
30 pass 30 pass
31 31
32 32
33class BasePlayer(object): 33class BasePlayer:
34 """Audio Backend Process Manager 34 """Audio Backend Process Manager
35 35
36 Starts and owns a handle to an audio backend process then feeds commands to 36 Starts and owns a handle to an audio backend process then feeds commands to
@@ -208,7 +208,7 @@ class MPG123Player(BasePlayer):
208 """ 208 """
209 209
210 def __init__(self, callbacks, control_channel): 210 def __init__(self, callbacks, control_channel):
211 super(MPG123Player, self).__init__(callbacks, control_channel) 211 super().__init__(callbacks, control_channel)
212 self._cmd.extend(["-q", "-R", "--ignore-mime", "."]) 212 self._cmd.extend(["-q", "-R", "--ignore-mime", "."])
213 213
214 def _find_path(self): 214 def _find_path(self):
@@ -246,7 +246,7 @@ class VLCPlayer(BasePlayer):
246 VOL_STEPS = 5 246 VOL_STEPS = 5
247 247
248 def __init__(self, callbacks, control_channel): 248 def __init__(self, callbacks, control_channel):
249 super(VLCPlayer, self).__init__(callbacks, control_channel) 249 super().__init__(callbacks, control_channel)
250 self._cmd.extend(["-I", "rc", "--advanced", "--rc-fake-tty", "-q"]) 250 self._cmd.extend(["-I", "rc", "--advanced", "--rc-fake-tty", "-q"])
251 self._last_poll = 0 251 self._last_poll = 0
252 252
@@ -300,7 +300,7 @@ class RemoteVLC(VLCPlayer):
300 def __init__(self, host, port, callbacks, control_channel): 300 def __init__(self, host, port, callbacks, control_channel):
301 self._connect_to = (host, int(port)) 301 self._connect_to = (host, int(port))
302 self._control_sock = None 302 self._control_sock = None
303 super(RemoteVLC, self).__init__(callbacks, control_channel) 303 super().__init__(callbacks, control_channel)
304 304
305 def _get_select_readers(self): 305 def _get_select_readers(self):
306 return [self._control_channel, self._control_sock] 306 return [self._control_channel, self._control_sock]
diff --git a/pydora/configure.py b/pydora/configure.py
index 7c051df..d31c097 100644
--- a/pydora/configure.py
+++ b/pydora/configure.py
@@ -10,7 +10,7 @@ from pandora.clientbuilder import PydoraConfigFileBuilder
10from .utils import Screen, Colors 10from .utils import Screen, Colors
11 11
12 12
13class Umask(object): 13class Umask:
14 """Set/Restore Umask Context Manager 14 """Set/Restore Umask Context Manager
15 """ 15 """
16 16
@@ -25,7 +25,7 @@ class Umask(object):
25 os.umask(self.old_umask) 25 os.umask(self.old_umask)
26 26
27 27
28class PandoraKeysConfigParser(object): 28class PandoraKeysConfigParser:
29 """Parser for Pandora Keys Source Page 29 """Parser for Pandora Keys Source Page
30 30
31 This is an extremely naive restructured text parser designed only to parse 31 This is an extremely naive restructured text parser designed only to parse
@@ -97,7 +97,7 @@ class PandoraKeysConfigParser(object):
97 return partners 97 return partners
98 98
99 99
100class Configurator(object): 100class Configurator:
101 """Interactive Configuration Builder 101 """Interactive Configuration Builder
102 102
103 Allows a user to configure pydora interactively. Ultimately writes the 103 Allows a user to configure pydora interactively. Ultimately writes the
diff --git a/pydora/player.py b/pydora/player.py
index 74b6110..fdacc63 100644
--- a/pydora/player.py
+++ b/pydora/player.py
@@ -18,7 +18,7 @@ from .audio_backend import MPG123Player, VLCPlayer
18from .audio_backend import UnsupportedEncoding, PlayerUnusable 18from .audio_backend import UnsupportedEncoding, PlayerUnusable
19 19
20 20
21class PlayerCallbacks(object): 21class PlayerCallbacks:
22 """Interface for Player Callbacks 22 """Interface for Player Callbacks
23 23
24 This class simply exists to document the interface for callback 24 This class simply exists to document the interface for callback
@@ -46,7 +46,7 @@ class PlayerCallbacks(object):
46 pass 46 pass
47 47
48 48
49class PlayerApp(object): 49class PlayerApp:
50 50
51 CMD_MAP = { 51 CMD_MAP = {
52 "n": ("play next song", "skip_song"), 52 "n": ("play next song", "skip_song"),
@@ -122,7 +122,7 @@ class PlayerApp(object):
122 122
123 for i, station in enumerate(self.stations): 123 for i, station in enumerate(self.stations):
124 i = "{:>3}".format(i) 124 i = "{:>3}".format(i)
125 print(u"{}: {}".format(Colors.yellow(i), station.name)) 125 print("{}: {}".format(Colors.yellow(i), station.name))
126 126
127 return self.stations[self.screen.get_integer("Station: ")] 127 return self.stations[self.screen.get_integer("Station: ")]
128 128
@@ -130,10 +130,10 @@ class PlayerApp(object):
130 """Play callback 130 """Play callback
131 """ 131 """
132 if song.is_ad: 132 if song.is_ad:
133 print(u"{} ".format(Colors.cyan("Advertisement"))) 133 print("{} ".format(Colors.cyan("Advertisement")))
134 else: 134 else:
135 print(u"{} by {}".format(Colors.cyan(song.song_name), 135 print("{} by {}".format(Colors.cyan(song.song_name),
136 Colors.yellow(song.artist_name))) 136 Colors.yellow(song.artist_name)))
137 137
138 def skip_song(self, song): 138 def skip_song(self, song):
139 if song.is_ad: 139 if song.is_ad:
diff --git a/pydora/utils.py b/pydora/utils.py
index ca40095..6675773 100644
--- a/pydora/utils.py
+++ b/pydora/utils.py
@@ -13,15 +13,15 @@ class TerminalPlatformUnsupported(Exception):
13 pass 13 pass
14 14
15 15
16class Colors(object): 16class Colors:
17 17
18 def __wrap_with(raw_code): 18 def __wrap_with(raw_code):
19 @staticmethod 19 @staticmethod
20 def inner(text, bold=False): 20 def inner(text, bold=False):
21 code = raw_code 21 code = raw_code
22 if bold: 22 if bold:
23 code = u"1;{}".format(code) 23 code = "1;{}".format(code)
24 return u"\033[{}m{}\033[0m".format(code, text) 24 return "\033[{}m{}\033[0m".format(code, text)
25 return inner 25 return inner
26 26
27 red = __wrap_with("31") 27 red = __wrap_with("31")
@@ -33,7 +33,7 @@ class Colors(object):
33 white = __wrap_with("37") 33 white = __wrap_with("37")
34 34
35 35
36class PosixEchoControl(object): 36class PosixEchoControl:
37 """Posix Console Echo Control Driver 37 """Posix Console Echo Control Driver
38 38
39 Uses termios on POSIX compliant platforms to control console echo. Is not 39 Uses termios on POSIX compliant platforms to control console echo. Is not
@@ -63,7 +63,7 @@ class PosixEchoControl(object):
63 self.termios.tcsetattr(handle, self.termios.TCSANOW, attrs) 63 self.termios.tcsetattr(handle, self.termios.TCSANOW, attrs)
64 64
65 65
66class Win32EchoControl(object): 66class Win32EchoControl:
67 """Windows Console Echo Control Driver 67 """Windows Console Echo Control Driver
68 68
69 This uses the console API from WinCon.h and ctypes to control console echo 69 This uses the console API from WinCon.h and ctypes to control console echo
@@ -109,7 +109,7 @@ class Win32EchoControl(object):
109 self._SetConsoleMode(stdin, mode & self.DISABLE_ECHO_INPUT) 109 self._SetConsoleMode(stdin, mode & self.DISABLE_ECHO_INPUT)
110 110
111 111
112class Screen(object): 112class Screen:
113 113
114 def __init__(self): 114 def __init__(self):
115 try: 115 try:
@@ -201,8 +201,8 @@ class SilentPopen(subprocess.Popen):
201 kwargs["stdin"] = subprocess.PIPE 201 kwargs["stdin"] = subprocess.PIPE
202 kwargs["stdout"] = subprocess.PIPE 202 kwargs["stdout"] = subprocess.PIPE
203 kwargs["stderr"] = self._dev_null 203 kwargs["stderr"] = self._dev_null
204 super(SilentPopen, self).__init__(*args, **kwargs) 204 super().__init__(*args, **kwargs)
205 205
206 def __del__(self): 206 def __del__(self):
207 self._dev_null.close() 207 self._dev_null.close()
208 super(SilentPopen, self).__del__() 208 super().__del__()
diff --git a/setup.py b/setup.py
index 614df41..63abed1 100755
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ from setuptools import setup, find_packages
6 6
7 7
8# Python 2 setuptools test class is not an object 8# Python 2 setuptools test class is not an object
9class TestsWithCoverage(test, object): 9class TestsWithCoverage(test):
10 10
11 description = "run unit tests with coverage" 11 description = "run unit tests with coverage"
12 12
@@ -28,7 +28,7 @@ class TestsWithCoverage(test, object):
28 28
29 # Unittest calls exit prior to python 3. How naughty 29 # Unittest calls exit prior to python 3. How naughty
30 try: 30 try:
31 super(TestsWithCoverage, self).run() 31 super().run()
32 except SystemExit: 32 except SystemExit:
33 pass 33 pass
34 34
diff --git a/tests/test_pandora/test_client.py b/tests/test_pandora/test_client.py
index 901e072..9945bff 100644
--- a/tests/test_pandora/test_client.py
+++ b/tests/test_pandora/test_client.py
@@ -10,7 +10,7 @@ from tests.test_pandora.test_models import TestAdItem
10 10
11class TestAPIClientLogin(TestCase): 11class TestAPIClientLogin(TestCase):
12 12
13 class StubTransport(object): 13 class StubTransport:
14 14
15 API_VERSION = None 15 API_VERSION = None
16 16
diff --git a/tests/test_pandora/test_models.py b/tests/test_pandora/test_models.py
index 8cfbd9d..0d37ca0 100644
--- a/tests/test_pandora/test_models.py
+++ b/tests/test_pandora/test_models.py
@@ -25,7 +25,7 @@ class TestField(TestCase):
25 25
26class TestModelMetaClass(TestCase): 26class TestModelMetaClass(TestCase):
27 27
28 class TestModel(object, metaclass=m.ModelMetaClass): 28 class TestModel(metaclass=m.ModelMetaClass):
29 29
30 foo = "bar" 30 foo = "bar"
31 a_field = m.Field("testing") 31 a_field = m.Field("testing")
diff --git a/tests/test_pandora/test_transport.py b/tests/test_pandora/test_transport.py
index 96dd40e..7eaaa6b 100644
--- a/tests/test_pandora/test_transport.py
+++ b/tests/test_pandora/test_transport.py
@@ -247,7 +247,7 @@ class TestTransportRequestPrep(TestCase):
247 247
248 248
249# All Cryptor implementations must pass these test cases unmodified 249# All Cryptor implementations must pass these test cases unmodified
250class CommonCryptorTestCases(object): 250class CommonCryptorTestCases:
251 251
252 def test_decrypt_invalid_padding(self): 252 def test_decrypt_invalid_padding(self):
253 with self.assertRaises(ValueError): 253 with self.assertRaises(ValueError):
@@ -288,7 +288,7 @@ class TestEncryptor(TestCase):
288 EXPECTED_TIME = 4111 288 EXPECTED_TIME = 4111
289 ENCODED_TIME = "31353037343131313539" 289 ENCODED_TIME = "31353037343131313539"
290 290
291 class NoopCrypto(object): 291 class NoopCrypto:
292 292
293 def __init__(self, key): 293 def __init__(self, key):
294 pass 294 pass