aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2020-12-19 21:36:08 +0000
committerMike Crute <mike@crute.us>2020-12-19 21:36:08 +0000
commit816c7e47942c15b0ca35276fad8d23d33100798e (patch)
treed34ef0a1d922289a3c7cbbbb9aad8fa25f1889f6
parent135c4076374b5126bd49889ee9d994fac94e4119 (diff)
downloadpydora-816c7e47942c15b0ca35276fad8d23d33100798e.tar.bz2
pydora-816c7e47942c15b0ca35276fad8d23d33100798e.tar.xz
pydora-816c7e47942c15b0ca35276fad8d23d33100798e.zip
New version of black moved the cheese :-(
-rw-r--r--pandora/clientbuilder.py3
-rw-r--r--pandora/errors.py5
-rw-r--r--pandora/models/_base.py9
-rw-r--r--pydora/audio_backend.py39
-rw-r--r--pydora/configure.py3
-rw-r--r--pydora/player.py21
-rw-r--r--pydora/utils.py3
-rw-r--r--tests/test_pandora/test_client.py4
-rw-r--r--tests/test_pandora/test_models.py11
-rw-r--r--tests/test_pandora/test_transport.py5
10 files changed, 46 insertions, 57 deletions
diff --git a/pandora/clientbuilder.py b/pandora/clientbuilder.py
index 2b11ffb..5adebd1 100644
--- a/pandora/clientbuilder.py
+++ b/pandora/clientbuilder.py
@@ -226,8 +226,7 @@ class PydoraConfigFileBuilder(FileBasedClientBuilder):
226 226
227 227
228class PianobarSettingsDict(TranslatingDict): 228class PianobarSettingsDict(TranslatingDict):
229 """Pianobar Translating Dictionary 229 """Pianobar Translating Dictionary"""
230 """
231 230
232 KEY_TRANSLATIONS = { 231 KEY_TRANSLATIONS = {
233 "DECRYPT_PASSWORD": "DECRYPTION_KEY", 232 "DECRYPT_PASSWORD": "DECRYPTION_KEY",
diff --git a/pandora/errors.py b/pandora/errors.py
index 3b03db2..f240e0f 100644
--- a/pandora/errors.py
+++ b/pandora/errors.py
@@ -89,7 +89,10 @@ class PandoraException(Exception):
89 exception = type( 89 exception = type(
90 name, 90 name,
91 (PandoraException,), 91 (PandoraException,),
92 {"code": code, "message": api_message,}, 92 {
93 "code": code,
94 "message": api_message,
95 },
93 ) 96 )
94 97
95 export_to[name] = __API_EXCEPTIONS__[code] = exception 98 export_to[name] = __API_EXCEPTIONS__[code] = exception
diff --git a/pandora/models/_base.py b/pandora/models/_base.py
index 8904be1..c39050b 100644
--- a/pandora/models/_base.py
+++ b/pandora/models/_base.py
@@ -98,8 +98,7 @@ class PandoraModel(metaclass=ModelMetaClass):
98 98
99 @classmethod 99 @classmethod
100 def from_json_list(cls, api_client, data): 100 def from_json_list(cls, api_client, data):
101 """Convert a list of JSON values to a list of models 101 """Convert a list of JSON values to a list of models"""
102 """
103 return [cls.from_json(api_client, item) for item in data] 102 return [cls.from_json(api_client, item) for item in data]
104 103
105 def __init__(self, api_client): 104 def __init__(self, api_client):
@@ -147,15 +146,13 @@ class PandoraModel(metaclass=ModelMetaClass):
147 146
148 @classmethod 147 @classmethod
149 def from_json(cls, api_client, data): 148 def from_json(cls, api_client, data):
150 """Convert one JSON value to a model object 149 """Convert one JSON value to a model object"""
151 """
152 self = cls(api_client) 150 self = cls(api_client)
153 PandoraModel.populate_fields(api_client, self, data) 151 PandoraModel.populate_fields(api_client, self, data)
154 return self 152 return self
155 153
156 def _base_repr(self, and_also=None): 154 def _base_repr(self, and_also=None):
157 """Common repr logic for subclasses to hook 155 """Common repr logic for subclasses to hook"""
158 """
159 items = [ 156 items = [
160 "=".join((key, repr(getattr(self, key)))) 157 "=".join((key, repr(getattr(self, key))))
161 for key in sorted(self._fields.keys()) 158 for key in sorted(self._fields.keys())
diff --git a/pydora/audio_backend.py b/pydora/audio_backend.py
index aecd87e..1186d93 100644
--- a/pydora/audio_backend.py
+++ b/pydora/audio_backend.py
@@ -13,22 +13,19 @@ log = logging.getLogger("pydora.audio_backend")
13 13
14 14
15class PlayerException(Exception): 15class PlayerException(Exception):
16 """Base class for all player exceptions 16 """Base class for all player exceptions"""
17 """
18 17
19 pass 18 pass
20 19
21 20
22class UnsupportedEncoding(PlayerException): 21class UnsupportedEncoding(PlayerException):
23 """Song encoding is not supported by player backend 22 """Song encoding is not supported by player backend"""
24 """
25 23
26 pass 24 pass
27 25
28 26
29class PlayerUnusable(PlayerException): 27class PlayerUnusable(PlayerException):
30 """Player can not be used on this system 28 """Player can not be used on this system"""
31 """
32 29
33 pass 30 pass
34 31
@@ -67,13 +64,11 @@ class BasePlayer:
67 raise NotImplementedError 64 raise NotImplementedError
68 65
69 def _load_track(self, song): 66 def _load_track(self, song):
70 """Load a track into the audio backend by song model 67 """Load a track into the audio backend by song model"""
71 """
72 raise NotImplementedError 68 raise NotImplementedError
73 69
74 def _player_stopped(self, value): 70 def _player_stopped(self, value):
75 """Determine if player has stopped 71 """Determine if player has stopped"""
76 """
77 raise NotImplementedError 72 raise NotImplementedError
78 73
79 def raise_volume(self): 74 def raise_volume(self):
@@ -93,13 +88,11 @@ class BasePlayer:
93 raise NotImplementedError 88 raise NotImplementedError
94 89
95 def _post_start(self): 90 def _post_start(self):
96 """Optionally, do something after the audio backend is started 91 """Optionally, do something after the audio backend is started"""
97 """
98 return 92 return
99 93
100 def _loop_hook(self): 94 def _loop_hook(self):
101 """Optionally, do something each main loop iteration 95 """Optionally, do something each main loop iteration"""
102 """
103 return 96 return
104 97
105 def _read_from_process(self, handle): 98 def _read_from_process(self, handle):
@@ -111,19 +104,16 @@ class BasePlayer:
111 return handle.readline().strip() 104 return handle.readline().strip()
112 105
113 def _send_cmd(self, cmd): 106 def _send_cmd(self, cmd):
114 """Write command to remote process 107 """Write command to remote process"""
115 """
116 self._process.stdin.write("{}\n".format(cmd).encode("utf-8")) 108 self._process.stdin.write("{}\n".format(cmd).encode("utf-8"))
117 self._process.stdin.flush() 109 self._process.stdin.flush()
118 110
119 def stop(self): 111 def stop(self):
120 """Stop the currently playing song 112 """Stop the currently playing song"""
121 """
122 self._send_cmd("stop") 113 self._send_cmd("stop")
123 114
124 def pause(self): 115 def pause(self):
125 """Pause the player 116 """Pause the player"""
126 """
127 self._send_cmd("pause") 117 self._send_cmd("pause")
128 118
129 def __del__(self): 119 def __del__(self):
@@ -138,8 +128,7 @@ class BasePlayer:
138 self._ensure_started() 128 self._ensure_started()
139 129
140 def _ensure_started(self): 130 def _ensure_started(self):
141 """Ensure player backing process is started 131 """Ensure player backing process is started"""
142 """
143 if self._process and self._process.poll() is None: 132 if self._process and self._process.poll() is None:
144 return 133 return
145 134
@@ -189,8 +178,7 @@ class BasePlayer:
189 self._callbacks.post_poll() 178 self._callbacks.post_poll()
190 179
191 def end_station(self): 180 def end_station(self):
192 """Stop playing the station 181 """Stop playing the station"""
193 """
194 raise StopIteration 182 raise StopIteration
195 183
196 def play_station(self, station): 184 def play_station(self, station):
@@ -208,8 +196,7 @@ class BasePlayer:
208 196
209 197
210class MPG123Player(BasePlayer): 198class MPG123Player(BasePlayer):
211 """Player Backend Using mpg123 199 """Player Backend Using mpg123"""
212 """
213 200
214 def __init__(self, callbacks, control_channel): 201 def __init__(self, callbacks, control_channel):
215 super().__init__(callbacks, control_channel) 202 super().__init__(callbacks, control_channel)
diff --git a/pydora/configure.py b/pydora/configure.py
index d58d445..1124746 100644
--- a/pydora/configure.py
+++ b/pydora/configure.py
@@ -11,8 +11,7 @@ from .utils import Screen, Colors
11 11
12 12
13class Umask: 13class Umask:
14 """Set/Restore Umask Context Manager 14 """Set/Restore Umask Context Manager"""
15 """
16 15
17 def __init__(self, umask): 16 def __init__(self, umask):
18 self.umask = umask 17 self.umask = umask
diff --git a/pydora/player.py b/pydora/player.py
index c4ce2e0..18209b1 100644
--- a/pydora/player.py
+++ b/pydora/player.py
@@ -26,23 +26,19 @@ class PlayerCallbacks:
26 """ 26 """
27 27
28 def play(self, song): 28 def play(self, song):
29 """Called once when a song starts playing 29 """Called once when a song starts playing"""
30 """
31 pass 30 pass
32 31
33 def pre_poll(self): 32 def pre_poll(self):
34 """Called before polling for process status 33 """Called before polling for process status"""
35 """
36 pass 34 pass
37 35
38 def post_poll(self): 36 def post_poll(self):
39 """Called after polling for process status 37 """Called after polling for process status"""
40 """
41 pass 38 pass
42 39
43 def input(self, value, song): 40 def input(self, value, song):
44 """Called after user input during song playback 41 """Called after user input during song playback"""
45 """
46 pass 42 pass
47 43
48 44
@@ -113,8 +109,7 @@ class PlayerApp:
113 sys.exit(1) 109 sys.exit(1)
114 110
115 def station_selection_menu(self, error=None): 111 def station_selection_menu(self, error=None):
116 """Format a station menu and make the user select a station 112 """Format a station menu and make the user select a station"""
117 """
118 self.screen.clear() 113 self.screen.clear()
119 114
120 if error: 115 if error:
@@ -127,8 +122,7 @@ class PlayerApp:
127 return self.stations[self.screen.get_integer("Station: ")] 122 return self.stations[self.screen.get_integer("Station: ")]
128 123
129 def play(self, song): 124 def play(self, song):
130 """Play callback 125 """Play callback"""
131 """
132 if song.is_ad: 126 if song.is_ad:
133 print("{} ".format(Colors.cyan("Advertisement"))) 127 print("{} ".format(Colors.cyan("Advertisement")))
134 else: 128 else:
@@ -231,8 +225,7 @@ class PlayerApp:
231 print("") 225 print("")
232 226
233 def input(self, input, song): 227 def input(self, input, song):
234 """Input callback, handles key presses 228 """Input callback, handles key presses"""
235 """
236 try: 229 try:
237 cmd = getattr(self, self.CMD_MAP[input][1]) 230 cmd = getattr(self, self.CMD_MAP[input][1])
238 except (IndexError, KeyError): 231 except (IndexError, KeyError):
diff --git a/pydora/utils.py b/pydora/utils.py
index 5a96ff1..b38fb5b 100644
--- a/pydora/utils.py
+++ b/pydora/utils.py
@@ -194,8 +194,7 @@ def iterate_forever(func, *args, **kwargs):
194 194
195 195
196class SilentPopen(subprocess.Popen): 196class SilentPopen(subprocess.Popen):
197 """A Popen varient that dumps it's output and error 197 """A Popen varient that dumps it's output and error"""
198 """
199 198
200 def __init__(self, *args, **kwargs): 199 def __init__(self, *args, **kwargs):
201 self._dev_null = open(os.devnull, "w") 200 self._dev_null = open(os.devnull, "w")
diff --git a/tests/test_pandora/test_client.py b/tests/test_pandora/test_client.py
index 4262d34..7d3e7bd 100644
--- a/tests/test_pandora/test_client.py
+++ b/tests/test_pandora/test_client.py
@@ -203,7 +203,9 @@ class TestCreatingStation(TestCase):
203class TestCreatingGenreStation(TestCase): 203class TestCreatingGenreStation(TestCase):
204 def test_has_initial_checksum(self): 204 def test_has_initial_checksum(self):
205 fake_data = { 205 fake_data = {
206 "categories": [{"categoryName": "foo", "stations": []},], 206 "categories": [
207 {"categoryName": "foo", "stations": []},
208 ],
207 # Not actually part of the genre station response but is needed to 209 # Not actually part of the genre station response but is needed to
208 # fake out the mock for get_genre_stations_checksum 210 # fake out the mock for get_genre_stations_checksum
209 "checksum": "foo", 211 "checksum": "foo",
diff --git a/tests/test_pandora/test_models.py b/tests/test_pandora/test_models.py
index a155588..11f9f6a 100644
--- a/tests/test_pandora/test_models.py
+++ b/tests/test_pandora/test_models.py
@@ -64,7 +64,12 @@ class TestAdditionalUrlField(TestCase):
64 self.assertEqual(ret, {"foo": "test"}) 64 self.assertEqual(ret, {"foo": "test"})
65 65
66 def test_multiple_urls(self): 66 def test_multiple_urls(self):
67 dummy_data = {"_paramAdditionalUrls": ["abc", "def",]} 67 dummy_data = {
68 "_paramAdditionalUrls": [
69 "abc",
70 "def",
71 ]
72 }
68 73
69 field = plm.AdditionalUrlField("additionalAudioUrl") 74 field = plm.AdditionalUrlField("additionalAudioUrl")
70 75
@@ -708,7 +713,9 @@ class TestGenreStationList(TestCase):
708 713
709 TEST_DATA = { 714 TEST_DATA = {
710 "checksum": "bar", 715 "checksum": "bar",
711 "categories": [{"categoryName": "foo", "stations": []},], 716 "categories": [
717 {"categoryName": "foo", "stations": []},
718 ],
712 } 719 }
713 720
714 def test_has_changed(self): 721 def test_has_changed(self):
diff --git a/tests/test_pandora/test_transport.py b/tests/test_pandora/test_transport.py
index 28ca6b2..ac32acf 100644
--- a/tests/test_pandora/test_transport.py
+++ b/tests/test_pandora/test_transport.py
@@ -118,7 +118,10 @@ class TestTransportSetters(TestCase):
118 118
119 def test_set_user(self): 119 def test_set_user(self):
120 self.transport.set_user( 120 self.transport.set_user(
121 {"userId": "user", "userAuthToken": "auth",} 121 {
122 "userId": "user",
123 "userAuthToken": "auth",
124 }
122 ) 125 )
123 126
124 self.assertEqual("user", self.transport.user_id) 127 self.assertEqual("user", self.transport.user_id)