diff options
author | Mike Crute <mcrute@gmail.com> | 2015-07-07 20:32:32 -0700 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2015-07-07 20:32:32 -0700 |
commit | 4300dc20ef95af928b459e145ef46e3a87b35a31 (patch) | |
tree | b73e17cef84c703762ffee85cc4749ad4f3fffd8 /pydora | |
parent | 28ce5619d8f3371c7dda51e1a4493a7b940ae106 (diff) | |
download | pydora-4300dc20ef95af928b459e145ef46e3a87b35a31.tar.bz2 pydora-4300dc20ef95af928b459e145ef46e3a87b35a31.tar.xz pydora-4300dc20ef95af928b459e145ef46e3a87b35a31.zip |
Consistent quoting
Diffstat (limited to 'pydora')
-rw-r--r-- | pydora/mpg123.py | 20 | ||||
-rwxr-xr-x | pydora/player.py | 42 | ||||
-rw-r--r-- | pydora/utils.py | 20 |
3 files changed, 41 insertions, 41 deletions
diff --git a/pydora/mpg123.py b/pydora/mpg123.py index 4f507ab..2c5e4d3 100644 --- a/pydora/mpg123.py +++ b/pydora/mpg123.py | |||
@@ -23,10 +23,10 @@ class SilentPopen(subprocess.Popen): | |||
23 | """ | 23 | """ |
24 | 24 | ||
25 | def __init__(self, *args, **kwargs): | 25 | def __init__(self, *args, **kwargs): |
26 | self._dev_null = open(os.devnull, 'w') | 26 | self._dev_null = open(os.devnull, "w") |
27 | kwargs['stdin'] = subprocess.PIPE | 27 | kwargs["stdin"] = subprocess.PIPE |
28 | kwargs['stdout'] = subprocess.PIPE | 28 | kwargs["stdout"] = subprocess.PIPE |
29 | kwargs['stderr'] = self._dev_null | 29 | kwargs["stderr"] = self._dev_null |
30 | super(SilentPopen, self).__init__(*args, **kwargs) | 30 | super(SilentPopen, self).__init__(*args, **kwargs) |
31 | 31 | ||
32 | def __del__(self): | 32 | def __del__(self): |
@@ -81,10 +81,10 @@ class Player(object): | |||
81 | return | 81 | return |
82 | 82 | ||
83 | self._process = SilentPopen( | 83 | self._process = SilentPopen( |
84 | ['mpg123', '-q', '-R', '--ignore-mime']) | 84 | ["mpg123", "-q", "-R", "--ignore-mime"]) |
85 | 85 | ||
86 | # Only output play status in the player stdout | 86 | # Only output play status in the player stdout |
87 | self._send_cmd('silence') | 87 | self._send_cmd("silence") |
88 | 88 | ||
89 | def _send_cmd(self, cmd): | 89 | def _send_cmd(self, cmd): |
90 | """Write command to remote mpg123 process | 90 | """Write command to remote mpg123 process |
@@ -95,17 +95,17 @@ class Player(object): | |||
95 | def stop(self): | 95 | def stop(self): |
96 | """Stop the currently playing song | 96 | """Stop the currently playing song |
97 | """ | 97 | """ |
98 | self._send_cmd('stop') | 98 | self._send_cmd("stop") |
99 | 99 | ||
100 | def pause(self): | 100 | def pause(self): |
101 | """Pause the player | 101 | """Pause the player |
102 | """ | 102 | """ |
103 | self._send_cmd('pause') | 103 | self._send_cmd("pause") |
104 | 104 | ||
105 | def _player_stopped(self, value): | 105 | def _player_stopped(self, value): |
106 | """Determine if player has stopped | 106 | """Determine if player has stopped |
107 | """ | 107 | """ |
108 | return value.startswith(b"@P") and value.decode('utf-8')[3] == "0" | 108 | return value.startswith(b"@P") and value.decode("utf-8")[3] == "0" |
109 | 109 | ||
110 | def play(self, song): | 110 | def play(self, song): |
111 | """Play a new song from a Pandora model | 111 | """Play a new song from a Pandora model |
@@ -114,7 +114,7 @@ class Player(object): | |||
114 | process. Calls the input callback when the user has input. | 114 | process. Calls the input callback when the user has input. |
115 | """ | 115 | """ |
116 | self._callbacks.play(song) | 116 | self._callbacks.play(song) |
117 | self._send_cmd('load {}'.format(song.audio_url)) | 117 | self._send_cmd("load {}".format(song.audio_url)) |
118 | 118 | ||
119 | while True: | 119 | while True: |
120 | try: | 120 | try: |
diff --git a/pydora/player.py b/pydora/player.py index b756ef0..9b99c8c 100755 --- a/pydora/player.py +++ b/pydora/player.py | |||
@@ -19,16 +19,16 @@ from .utils import Colors, Screen | |||
19 | class PlayerApp(object): | 19 | class PlayerApp(object): |
20 | 20 | ||
21 | CMD_MAP = { | 21 | CMD_MAP = { |
22 | 'n': ('play next song', 'skip_song'), | 22 | "n": ("play next song", "skip_song"), |
23 | 'p': ('pause/resume song', 'pause_song'), | 23 | "p": ("pause/resume song", "pause_song"), |
24 | 's': ('stop playing station', 'stop_station'), | 24 | "s": ("stop playing station", "stop_station"), |
25 | 'd': ('dislike song', 'dislike_song'), | 25 | "d": ("dislike song", "dislike_song"), |
26 | 'u': ('like song', 'like_song'), | 26 | "u": ("like song", "like_song"), |
27 | 'b': ('bookmark song', 'bookmark_song'), | 27 | "b": ("bookmark song", "bookmark_song"), |
28 | 'a': ('bookmark artist', 'bookmark_artist'), | 28 | "a": ("bookmark artist", "bookmark_artist"), |
29 | 'S': ('sleep song for 30 days', 'sleep_song'), | 29 | "S": ("sleep song for 30 days", "sleep_song"), |
30 | 'Q': ('quit player', 'quit'), | 30 | "Q": ("quit player", "quit"), |
31 | '?': ('display this help', 'help'), | 31 | "?": ("display this help", "help"), |
32 | } | 32 | } |
33 | 33 | ||
34 | def __init__(self): | 34 | def __init__(self): |
@@ -55,15 +55,15 @@ class PlayerApp(object): | |||
55 | Screen.clear() | 55 | Screen.clear() |
56 | 56 | ||
57 | for i, s in enumerate(self.stations): | 57 | for i, s in enumerate(self.stations): |
58 | i = '{:>3}'.format(i) | 58 | i = "{:>3}".format(i) |
59 | print('{}: {}'.format(Colors.yellow(i), s.name)) | 59 | print("{}: {}".format(Colors.yellow(i), s.name)) |
60 | 60 | ||
61 | return self.stations[Screen.get_integer('Station: ')] | 61 | return self.stations[Screen.get_integer("Station: ")] |
62 | 62 | ||
63 | def play(self, song): | 63 | def play(self, song): |
64 | """Play callback | 64 | """Play callback |
65 | """ | 65 | """ |
66 | print('{} by {}'.format(Colors.cyan(song.song_name), | 66 | print("{} by {}".format(Colors.cyan(song.song_name), |
67 | Colors.yellow(song.artist_name))) | 67 | Colors.yellow(song.artist_name))) |
68 | 68 | ||
69 | def skip_song(self, song): | 69 | def skip_song(self, song): |
@@ -77,24 +77,24 @@ class PlayerApp(object): | |||
77 | 77 | ||
78 | def dislike_song(self, song): | 78 | def dislike_song(self, song): |
79 | song.thumbs_down() | 79 | song.thumbs_down() |
80 | Screen.print_success('Track disliked') | 80 | Screen.print_success("Track disliked") |
81 | self.player.stop() | 81 | self.player.stop() |
82 | 82 | ||
83 | def like_song(self, song): | 83 | def like_song(self, song): |
84 | song.thumbs_up() | 84 | song.thumbs_up() |
85 | Screen.print_success('Track liked') | 85 | Screen.print_success("Track liked") |
86 | 86 | ||
87 | def bookmark_song(self, song): | 87 | def bookmark_song(self, song): |
88 | song.bookmark_song() | 88 | song.bookmark_song() |
89 | Screen.print_success('Bookmarked song') | 89 | Screen.print_success("Bookmarked song") |
90 | 90 | ||
91 | def bookmark_artist(self, song): | 91 | def bookmark_artist(self, song): |
92 | song.bookmark_artist() | 92 | song.bookmark_artist() |
93 | Screen.print_success('Bookmarked artist') | 93 | Screen.print_success("Bookmarked artist") |
94 | 94 | ||
95 | def sleep_song(self, song): | 95 | def sleep_song(self, song): |
96 | song.sleep() | 96 | song.sleep() |
97 | Screen.print_success('Song will not be played for 30 days') | 97 | Screen.print_success("Song will not be played for 30 days") |
98 | self.player.stop() | 98 | self.player.stop() |
99 | 99 | ||
100 | def quit(self, song): | 100 | def quit(self, song): |
@@ -114,7 +114,7 @@ class PlayerApp(object): | |||
114 | try: | 114 | try: |
115 | cmd = getattr(self, self.CMD_MAP[input][1]) | 115 | cmd = getattr(self, self.CMD_MAP[input][1]) |
116 | except (IndexError, KeyError): | 116 | except (IndexError, KeyError): |
117 | return Screen.print_error('Invalid command!') | 117 | return Screen.print_error("Invalid command!") |
118 | 118 | ||
119 | cmd(song) | 119 | cmd(song) |
120 | 120 | ||
@@ -140,5 +140,5 @@ def main(): | |||
140 | PlayerApp().run() | 140 | PlayerApp().run() |
141 | 141 | ||
142 | 142 | ||
143 | if __name__ == '__main__': | 143 | if __name__ == "__main__": |
144 | main() | 144 | main() |
diff --git a/pydora/utils.py b/pydora/utils.py index bf5f4ce..76d12f3 100644 --- a/pydora/utils.py +++ b/pydora/utils.py | |||
@@ -23,13 +23,13 @@ class Colors(object): | |||
23 | return "\033[{}m{}\033[0m".format(c, text) | 23 | return "\033[{}m{}\033[0m".format(c, text) |
24 | return inner | 24 | return inner |
25 | 25 | ||
26 | red = __wrap_with('31') | 26 | red = __wrap_with("31") |
27 | green = __wrap_with('32') | 27 | green = __wrap_with("32") |
28 | yellow = __wrap_with('33') | 28 | yellow = __wrap_with("33") |
29 | blue = __wrap_with('34') | 29 | blue = __wrap_with("34") |
30 | magenta = __wrap_with('35') | 30 | magenta = __wrap_with("35") |
31 | cyan = __wrap_with('36') | 31 | cyan = __wrap_with("36") |
32 | white = __wrap_with('37') | 32 | white = __wrap_with("37") |
33 | 33 | ||
34 | 34 | ||
35 | class Screen(object): | 35 | class Screen(object): |
@@ -50,7 +50,7 @@ class Screen(object): | |||
50 | 50 | ||
51 | @staticmethod | 51 | @staticmethod |
52 | def clear(): | 52 | def clear(): |
53 | sys.stdout.write('\x1b[2J\x1b[H') | 53 | sys.stdout.write("\x1b[2J\x1b[H") |
54 | sys.stdout.flush() | 54 | sys.stdout.flush() |
55 | 55 | ||
56 | @staticmethod | 56 | @staticmethod |
@@ -72,11 +72,11 @@ class Screen(object): | |||
72 | try: | 72 | try: |
73 | return int(input(prompt).strip()) | 73 | return int(input(prompt).strip()) |
74 | except ValueError: | 74 | except ValueError: |
75 | print(Colors.red('Invaid Input!')) | 75 | print(Colors.red("Invaid Input!")) |
76 | 76 | ||
77 | 77 | ||
78 | def clear_screen(): | 78 | def clear_screen(): |
79 | """Clear the terminal | 79 | """Clear the terminal |
80 | """ | 80 | """ |
81 | sys.stdout.write('\x1b[2J\x1b[H') | 81 | sys.stdout.write("\x1b[2J\x1b[H") |
82 | sys.stdout.flush() | 82 | sys.stdout.flush() |