From ac0c61de98251dced70299e6bb9be1c304e091d5 Mon Sep 17 00:00:00 2001 From: Jesse Mullan Date: Tue, 25 Nov 2014 18:49:17 -0800 Subject: [PATCH] Enable C0303 and C0325, whitespace at end of line and unnecessary () after if checks --- headphones/__init__.py | 6 +++--- headphones/cuesplit.py | 2 +- headphones/helpers.py | 5 +++-- headphones/importer.py | 4 ++-- headphones/music_encoder.py | 8 ++++---- headphones/nzbget.py | 2 +- headphones/utorrent.py | 2 +- pylintrc | 4 +--- 8 files changed, 16 insertions(+), 17 deletions(-) diff --git a/headphones/__init__.py b/headphones/__init__.py index 2bb5e983..616c42a3 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -169,7 +169,7 @@ def initialize(config_file): fp.write(CURRENT_VERSION) except IOError as e: logger.error("Unable to write current version to file '%s': %s", - version_lock_file, e) + version_lock_file, e) # Check for new versions if CONFIG.CHECK_GITHUB_ON_STARTUP: @@ -297,8 +297,8 @@ def initialize_scheduler(): # Remove Torrent + data if Post Processed and finished Seeding if CONFIG.TORRENT_REMOVAL_INTERVAL > 0: SCHED.add_job(torrentfinished.checkTorrentFinished, - trigger=IntervalTrigger( - minutes=CONFIG.TORRENT_REMOVAL_INTERVAL)) + trigger=IntervalTrigger( + minutes=CONFIG.TORRENT_REMOVAL_INTERVAL)) # Start scheduler logger.info("(Re-)Scheduling background tasks") diff --git a/headphones/cuesplit.py b/headphones/cuesplit.py index 19414332..d2f9da7d 100755 --- a/headphones/cuesplit.py +++ b/headphones/cuesplit.py @@ -424,7 +424,7 @@ class CueFile(File): elif t >= 1: t_index = self.tracks[t]['index'] content += t_index[1] - if (t < len(self.tracks) - 1): + if t < (len(self.tracks) - 1): content += '\n' return content diff --git a/headphones/helpers.py b/headphones/helpers.py index 7823bd59..bc15b015 100644 --- a/headphones/helpers.py +++ b/headphones/helpers.py @@ -65,7 +65,8 @@ def latinToAscii(unicrap): """ From couch potato """ - xlate = {0xc0: 'A', 0xc1: 'A', 0xc2: 'A', 0xc3: 'A', 0xc4: 'A', 0xc5: 'A', + xlate = { + 0xc0: 'A', 0xc1: 'A', 0xc2: 'A', 0xc3: 'A', 0xc4: 'A', 0xc5: 'A', 0xc6: 'Ae', 0xc7: 'C', 0xc8: 'E', 0xc9: 'E', 0xca: 'E', 0xcb: 'E', 0x86: 'e', 0xcc: 'I', 0xcd: 'I', 0xce: 'I', 0xcf: 'I', @@ -90,7 +91,7 @@ def latinToAscii(unicrap): 0xb9: '{^1}', 0xba: '{^o}', 0xbb: '>>', 0xbc: '{1/4}', 0xbd: '{1/2}', 0xbe: '{3/4}', 0xbf: '?', 0xd7: '*', 0xf7: '/' - } + } r = '' for i in unicrap: diff --git a/headphones/importer.py b/headphones/importer.py index 758470ad..4730a8c7 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -48,7 +48,7 @@ def artistlist_to_mbids(artistlist, forced=False): for artist in artistlist: - if not artist and not (artist == ' '): + if not artist and artist != ' ': continue # If adding artists through Manage New Artists, they're coming through as non-unicode (utf-8?) @@ -466,7 +466,7 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): myDB.action('UPDATE albums SET Status=? WHERE AlbumID=?', ['Downloaded', rg['id']]) marked_as_downloaded = True else: - if ((have_track_count / float(total_track_count)) >= (headphones.CONFIG.ALBUM_COMPLETION_PCT / 100.0)): + if (have_track_count / float(total_track_count)) >= (headphones.CONFIG.ALBUM_COMPLETION_PCT / 100.0): myDB.action('UPDATE albums SET Status=? WHERE AlbumID=?', ['Downloaded', rg['id']]) marked_as_downloaded = True diff --git a/headphones/music_encoder.py b/headphones/music_encoder.py index 1612a695..286a47e0 100644 --- a/headphones/music_encoder.py +++ b/headphones/music_encoder.py @@ -66,7 +66,7 @@ def encode(albumPath): xldInfoMusic = MediaFile(xldMusicFile) encoderFormat = xldFormat - if (headphones.CONFIG.ENCODERLOSSLESS): + if headphones.CONFIG.ENCODERLOSSLESS: ext = os.path.normpath(os.path.splitext(music)[1].lstrip(".")).lower() if not use_xld and ext == 'flac' or use_xld and (ext != xldFormat and (xldInfoMusic.bitrate / 1000 > 400)): musicFiles.append(os.path.join(r, music)) @@ -118,7 +118,7 @@ def encode(albumPath): if not any(music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.' + x) for x in ["mp3", "wav"]): logger.warn('Lame cannot encode %s format for %s, use ffmpeg', os.path.splitext(music)[1], music) else: - if (music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.mp3') and (int(infoMusic.bitrate / 1000) <= headphones.CONFIG.BITRATE)): + if music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.mp3') and (int(infoMusic.bitrate / 1000) <= headphones.CONFIG.BITRATE): logger.info('%s has bitrate <= %skb, will not be re-encoded', music, headphones.CONFIG.BITRATE) else: encode = True @@ -128,8 +128,8 @@ def encode(albumPath): logger.warn('Cannot re-encode .ogg %s', music.decode(headphones.SYS_ENCODING, 'replace')) else: encode = True - elif (headphones.CONFIG.ENCODEROUTPUTFORMAT == 'mp3' or headphones.CONFIG.ENCODEROUTPUTFORMAT == 'm4a'): - if (music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.' + headphones.CONFIG.ENCODEROUTPUTFORMAT) and (int(infoMusic.bitrate / 1000) <= headphones.CONFIG.BITRATE)): + elif headphones.CONFIG.ENCODEROUTPUTFORMAT == 'mp3' or headphones.CONFIG.ENCODEROUTPUTFORMAT == 'm4a': + if music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.' + headphones.CONFIG.ENCODEROUTPUTFORMAT) and (int(infoMusic.bitrate / 1000) <= headphones.CONFIG.BITRATE): logger.info('%s has bitrate <= %skb, will not be re-encoded', music, headphones.CONFIG.BITRATE) else: encode = True diff --git a/headphones/nzbget.py b/headphones/nzbget.py index 50240f35..4ed18b7e 100644 --- a/headphones/nzbget.py +++ b/headphones/nzbget.py @@ -59,7 +59,7 @@ def sendNZB(nzb): return False except xmlrpclib.ProtocolError, e: - if (e.errmsg == "Unauthorized"): + if e.errmsg == "Unauthorized": logger.error(u"NZBget password is incorrect.") else: logger.error(u"Protocol Error: " + e.errmsg) diff --git a/headphones/utorrent.py b/headphones/utorrent.py index 67d9bad7..e74f6958 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -215,7 +215,7 @@ def dirTorrent(hash, cacheid=None, return_name=None): cacheid = torrentList['torrentc'] for torrent in torrents: - if (torrent[0].lower() == hash): + if torrent[0].lower() == hash: if not return_name: return torrent[26], cacheid else: diff --git a/pylintrc b/pylintrc index 3137b71b..62ee490f 100644 --- a/pylintrc +++ b/pylintrc @@ -38,8 +38,6 @@ load-plugins= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -#C0303 whitespace between the end of a line and the newline. -#C0325 a single item in parentheses follows an if, for, or other keyword #C0326 wrong number of spaces is used around an operator, bracket or block opener #I0011 an inline option disables a pylint message or a messages category #R0801 a set of similar lines has been detected among multiple file @@ -49,7 +47,7 @@ load-plugins= # C0330(bad-continuation) # E1205(logging-too-many-args) -disable=C0303,C0325,C0326,I0011,R0801,W0142,C0103,C0111,C0301,C0302,C0304,C0321,C1001,E0101,E0203,E0602,E1101,E1123,R0201,R0401,R0911,R0912,R0914,R0915,R0923,W0102,W0109,W0120,W0141,W0201,W0212,W0231,W0232,W0233,W0301,W0311,W0401,W0403,W0404,W0511,W0601,W0602,W0603,W0611,W0612,W0613,W0621,W0622,W0633,W0702,W0703,W1401,W1201,C0330 +disable=C0326,I0011,R0801,W0142,C0103,C0111,C0301,C0302,C0304,C0321,C1001,E0101,E0203,E0602,E1101,E1123,R0201,R0401,R0911,R0912,R0914,R0915,R0923,W0102,W0109,W0120,W0141,W0201,W0212,W0231,W0232,W0233,W0301,W0311,W0401,W0403,W0404,W0511,W0601,W0602,W0603,W0611,W0612,W0613,W0621,W0622,W0633,W0702,W0703,W1401,W1201,C0330 [REPORTS]