diff options
author | Mike Crute <mike@crute.us> | 2020-12-19 21:36:08 +0000 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2020-12-19 21:36:08 +0000 |
commit | 816c7e47942c15b0ca35276fad8d23d33100798e (patch) | |
tree | d34ef0a1d922289a3c7cbbbb9aad8fa25f1889f6 /pydora | |
parent | 135c4076374b5126bd49889ee9d994fac94e4119 (diff) | |
download | pydora-816c7e47942c15b0ca35276fad8d23d33100798e.tar.bz2 pydora-816c7e47942c15b0ca35276fad8d23d33100798e.tar.xz pydora-816c7e47942c15b0ca35276fad8d23d33100798e.zip |
New version of black moved the cheese :-(
Diffstat (limited to 'pydora')
-rw-r--r-- | pydora/audio_backend.py | 39 | ||||
-rw-r--r-- | pydora/configure.py | 3 | ||||
-rw-r--r-- | pydora/player.py | 21 | ||||
-rw-r--r-- | pydora/utils.py | 3 |
4 files changed, 22 insertions, 44 deletions
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 | ||
15 | class PlayerException(Exception): | 15 | class 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 | ||
22 | class UnsupportedEncoding(PlayerException): | 21 | class 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 | ||
29 | class PlayerUnusable(PlayerException): | 27 | class 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 | ||
210 | class MPG123Player(BasePlayer): | 198 | class 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 | ||
13 | class Umask: | 13 | class 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 | ||
196 | class SilentPopen(subprocess.Popen): | 196 | class 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") |