diff options
author | Mike Crute <mcrute@gmail.com> | 2016-06-11 20:38:27 -0700 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2016-06-11 20:48:28 -0700 |
commit | 8fe17e28ec673587c72b30eed38d713a0cffe3b6 (patch) | |
tree | dbe2346366411319f8c5e760c190469b0a726a77 /pydora | |
parent | a61dba18d255112c4f9285362dd8c2452506a76c (diff) | |
download | pydora-8fe17e28ec673587c72b30eed38d713a0cffe3b6.tar.bz2 pydora-8fe17e28ec673587c72b30eed38d713a0cffe3b6.tar.xz pydora-8fe17e28ec673587c72b30eed38d713a0cffe3b6.zip |
Cleanup pylint nitpicks
Diffstat (limited to 'pydora')
-rw-r--r-- | pydora/configure.py | 12 | ||||
-rw-r--r-- | pydora/mpg123.py | 6 | ||||
-rwxr-xr-x | pydora/player.py | 8 | ||||
-rw-r--r-- | pydora/utils.py | 30 |
4 files changed, 26 insertions, 30 deletions
diff --git a/pydora/configure.py b/pydora/configure.py index 21ea3c3..824ab03 100644 --- a/pydora/configure.py +++ b/pydora/configure.py | |||
@@ -10,7 +10,7 @@ from pandora.clientbuilder import PydoraConfigFileBuilder | |||
10 | from .utils import Screen, Colors | 10 | from .utils import Screen, Colors |
11 | 11 | ||
12 | 12 | ||
13 | class umask(object): | 13 | class Umask(object): |
14 | """Set/Restore Umask Context Manager | 14 | """Set/Restore Umask Context Manager |
15 | """ | 15 | """ |
16 | 16 | ||
@@ -36,7 +36,7 @@ class PandoraKeysConfigParser(object): | |||
36 | "plain/json/partners.rst") | 36 | "plain/json/partners.rst") |
37 | 37 | ||
38 | FIELD_RE = re.compile( | 38 | FIELD_RE = re.compile( |
39 | ":(?P<key>[^:]+): (?:`{2})?(?P<value>[^`\n]+)(?:`{2})?$") | 39 | ":(?P<key>[^:]+): (?:`{2})?(?P<value>[^`\n]+)(?:`{2})?$") |
40 | 40 | ||
41 | def _fixup_key(self, key): | 41 | def _fixup_key(self, key): |
42 | key = key.lower() | 42 | key = key.lower() |
@@ -89,8 +89,8 @@ class PandoraKeysConfigParser(object): | |||
89 | elif self._is_device_terminator(line): | 89 | elif self._is_device_terminator(line): |
90 | key = self._clean_device_name(buffer.pop()) | 90 | key = self._clean_device_name(buffer.pop()) |
91 | current_partner = partners[key] = { | 91 | current_partner = partners[key] = { |
92 | "api_host": self._format_api_host(api_host) | 92 | "api_host": self._format_api_host(api_host) |
93 | } | 93 | } |
94 | 94 | ||
95 | buffer.append(line.strip().lower()) | 95 | buffer.append(line.strip().lower()) |
96 | 96 | ||
@@ -142,8 +142,8 @@ class Configurator(object): | |||
142 | self.cfg.set("api", key, value) | 142 | self.cfg.set("api", key, value) |
143 | 143 | ||
144 | def write_config(self): | 144 | def write_config(self): |
145 | with umask(0o077), open(self.builder.path, "w") as fp: | 145 | with Umask(0o077), open(self.builder.path, "w") as file: |
146 | self.cfg.write(fp) | 146 | self.cfg.write(file) |
147 | 147 | ||
148 | def configure(self): | 148 | def configure(self): |
149 | if self.builder.file_exists: | 149 | if self.builder.file_exists: |
diff --git a/pydora/mpg123.py b/pydora/mpg123.py index e60ab43..796a8ab 100644 --- a/pydora/mpg123.py +++ b/pydora/mpg123.py | |||
@@ -70,10 +70,10 @@ class Player(object): | |||
70 | readers, _, _ = select.select( | 70 | readers, _, _ = select.select( |
71 | [self._control_channel, self._process.stdout], [], [], 1) | 71 | [self._control_channel, self._process.stdout], [], [], 1) |
72 | 72 | ||
73 | for fd in readers: | 73 | for handle in readers: |
74 | value = fd.readline().strip() | 74 | value = handle.readline().strip() |
75 | 75 | ||
76 | if fd.fileno() == self._control_fd: | 76 | if handle.fileno() == self._control_fd: |
77 | self._callbacks.input(value, song) | 77 | self._callbacks.input(value, song) |
78 | else: | 78 | else: |
79 | if self._player_stopped(value): | 79 | if self._player_stopped(value): |
diff --git a/pydora/player.py b/pydora/player.py index 4561442..6e93df5 100755 --- a/pydora/player.py +++ b/pydora/player.py | |||
@@ -10,7 +10,7 @@ from __future__ import print_function | |||
10 | 10 | ||
11 | import os | 11 | import os |
12 | import sys | 12 | import sys |
13 | from pandora import APIClient, clientbuilder | 13 | from pandora import clientbuilder |
14 | 14 | ||
15 | from .mpg123 import Player | 15 | from .mpg123 import Player |
16 | from .utils import Colors, Screen | 16 | from .utils import Colors, Screen |
@@ -82,9 +82,9 @@ class PlayerApp(object): | |||
82 | """ | 82 | """ |
83 | Screen.clear() | 83 | Screen.clear() |
84 | 84 | ||
85 | for i, s in enumerate(self.stations): | 85 | for i, station in enumerate(self.stations): |
86 | i = "{:>3}".format(i) | 86 | i = "{:>3}".format(i) |
87 | print("{}: {}".format(Colors.yellow(i), s.name)) | 87 | print("{}: {}".format(Colors.yellow(i), station.name)) |
88 | 88 | ||
89 | return self.stations[Screen.get_integer("Station: ")] | 89 | return self.stations[Screen.get_integer("Station: ")] |
90 | 90 | ||
@@ -95,7 +95,7 @@ class PlayerApp(object): | |||
95 | print("{} ".format(Colors.cyan("Advertisement"))) | 95 | print("{} ".format(Colors.cyan("Advertisement"))) |
96 | else: | 96 | else: |
97 | print("{} by {}".format(Colors.cyan(song.song_name), | 97 | print("{} by {}".format(Colors.cyan(song.song_name), |
98 | Colors.yellow(song.artist_name))) | 98 | Colors.yellow(song.artist_name))) |
99 | 99 | ||
100 | def skip_song(self, song): | 100 | def skip_song(self, song): |
101 | if song.is_ad: | 101 | if song.is_ad: |
diff --git a/pydora/utils.py b/pydora/utils.py index 275c386..3c3aa39 100644 --- a/pydora/utils.py +++ b/pydora/utils.py | |||
@@ -5,8 +5,6 @@ import sys | |||
5 | import termios | 5 | import termios |
6 | import getpass | 6 | import getpass |
7 | import subprocess | 7 | import subprocess |
8 | from pandora.models.pandora import AdItem | ||
9 | from pandora import errors | ||
10 | 8 | ||
11 | 9 | ||
12 | def input(prompt): | 10 | def input(prompt): |
@@ -19,13 +17,13 @@ def input(prompt): | |||
19 | 17 | ||
20 | class Colors(object): | 18 | class Colors(object): |
21 | 19 | ||
22 | def __wrap_with(code): | 20 | def __wrap_with(raw_code): |
23 | @staticmethod | 21 | @staticmethod |
24 | def inner(text, bold=False): | 22 | def inner(text, bold=False): |
25 | c = code | 23 | code = raw_code |
26 | if bold: | 24 | if bold: |
27 | c = "1;{}".format(c) | 25 | code = "1;{}".format(code) |
28 | return "\033[{}m{}\033[0m".format(c, text) | 26 | return "\033[{}m{}\033[0m".format(code, text) |
29 | return inner | 27 | return inner |
30 | 28 | ||
31 | red = __wrap_with("31") | 29 | red = __wrap_with("31") |
@@ -41,20 +39,18 @@ class Screen(object): | |||
41 | 39 | ||
42 | @staticmethod | 40 | @staticmethod |
43 | def set_echo(enabled): | 41 | def set_echo(enabled): |
44 | fd = sys.stdin.fileno() | 42 | handle = sys.stdin.fileno() |
45 | if not os.isatty(fd): | 43 | if not os.isatty(handle): |
46 | return | 44 | return |
47 | 45 | ||
48 | (iflag, oflag, cflag, | 46 | attrs = termios.tcgetattr(handle) |
49 | lflag, ispeed, ospeed, cc) = termios.tcgetattr(fd) | ||
50 | 47 | ||
51 | if enabled: | 48 | if enabled: |
52 | lflag |= termios.ECHO | 49 | attrs[3] |= termios.ECHO |
53 | else: | 50 | else: |
54 | lflag &= ~termios.ECHO | 51 | attrs[3] &= ~termios.ECHO |
55 | 52 | ||
56 | termios.tcsetattr(fd, termios.TCSANOW, | 53 | termios.tcsetattr(handle, termios.TCSANOW, attrs) |
57 | [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]) | ||
58 | 54 | ||
59 | @staticmethod | 55 | @staticmethod |
60 | def clear(): | 56 | def clear(): |
@@ -120,9 +116,9 @@ def iterate_forever(func, *args, **kwargs): | |||
120 | 116 | ||
121 | while True: | 117 | while True: |
122 | try: | 118 | try: |
123 | playlistItem = next(output) | 119 | playlist_item = next(output) |
124 | playlistItem.prepare_playback() | 120 | playlist_item.prepare_playback() |
125 | yield playlistItem | 121 | yield playlist_item |
126 | except StopIteration: | 122 | except StopIteration: |
127 | output = func(*args, **kwargs) | 123 | output = func(*args, **kwargs) |
128 | 124 | ||