From 8736642e78929be4ff00a3ef3c5189b83f4d1b11 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 12:19:35 -0400 Subject: [PATCH 01/17] Fix code quality checks to run on project root and custom libs Fixes #1600 Fixes #1601 --- tox.ini | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index cf22519c..e9a5bcc1 100644 --- a/tox.ini +++ b/tox.ini @@ -33,6 +33,15 @@ commands = max-line-length = 79 verbose = 2 statistics = True +exclude = + .github/ + .tox/ + .pytest_cache/ + htmlcov/ + logs/ + libs/common + libs/win + libs/py2 ignore = ; -- flake8 -- ; E501 line too long @@ -74,13 +83,13 @@ skip_install = true commands = ; ** PRIMARY TESTS ** ; Run flake8 tests (with plugins) using default test selections - flake8 core tests setup.py + flake8 ; ** SELECTIVE TESTS ** ; Run flake8 tests (with plugins) for specific optional codes defined below ; -- flake8-bugbear -- ; B902 Invalid first argument used for instance method. ; B903 Data class should be immutable or use __slots__ to save memory. - flake8 core tests setup.py --select=B902,B903 + flake8 --select=B902,B903 [coverage:run] omit = From 077f04bc53aadcc193c8032d0e15ef57357f725e Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 12:56:50 -0400 Subject: [PATCH 02/17] Fix flake8 E265 block comment should start with '# ' Ignore for NZBGET scripts --- TorrentToMedia.py | 24 ++++++++++++------------ tox.ini | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 06d36e1a..dd7c363a 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -60,13 +60,13 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp input_category = 'UNCAT' usercat = input_category - #try: + # try: # input_name = input_name.encode(core.SYS_ENCODING) - #except UnicodeError: + # except UnicodeError: # pass - #try: + # try: # input_directory = input_directory.encode(core.SYS_ENCODING) - #except UnicodeError: + # except UnicodeError: # pass logger.debug('Determined Directory: {0} | Name: {1} | Category: {2}'.format @@ -125,9 +125,9 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp else: output_destination = os.path.normpath( core.os.path.join(core.OUTPUT_DIRECTORY, input_category)) - #try: + # try: # output_destination = output_destination.encode(core.SYS_ENCODING) - #except UnicodeError: + # except UnicodeError: # pass if output_destination in input_directory: @@ -170,9 +170,9 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp core.os.path.join(output_destination, os.path.basename(file_path)), full_file_name) logger.debug('Setting outputDestination to {0} to preserve folder structure'.format (os.path.dirname(target_file))) - #try: + # try: # target_file = target_file.encode(core.SYS_ENCODING) - #except UnicodeError: + # except UnicodeError: # pass if root == 1: if not found_file: @@ -353,14 +353,14 @@ def main(args): if client_agent.lower() not in core.TORRENT_CLIENTS: continue - #try: + # try: # dir_name = dir_name.encode(core.SYS_ENCODING) - #except UnicodeError: + # except UnicodeError: # pass input_name = os.path.basename(dir_name) - #try: + # try: # input_name = input_name.encode(core.SYS_ENCODING) - #except UnicodeError: + # except UnicodeError: # pass results = process_torrent(dir_name, input_name, subsection, input_hash or None, input_id or None, diff --git a/tox.ini b/tox.ini index e9a5bcc1..f9ca222c 100644 --- a/tox.ini +++ b/tox.ini @@ -66,6 +66,7 @@ ignore = per-file-ignores = ; F401 imported but unused ; E402 module level import not at top of file + nzbTo*.py: E265 core/__init__.py: E402, F401 core/utils/__init__.py: F401 core/plugins/downloaders/configuration.py: F401 From 9dd25f96b2485794d0c8e66cd3b9c4cf5b62b514 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 12:58:31 -0400 Subject: [PATCH 03/17] Fix flake8 E266 too many leading '#' for block comment Ignore for NZBGET scripts --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index f9ca222c..97f17b47 100644 --- a/tox.ini +++ b/tox.ini @@ -66,7 +66,7 @@ ignore = per-file-ignores = ; F401 imported but unused ; E402 module level import not at top of file - nzbTo*.py: E265 + nzbTo*.py: E265, E266 core/__init__.py: E402, F401 core/utils/__init__.py: F401 core/plugins/downloaders/configuration.py: F401 From daa9819798b4747383d06e6f3a6172a989eabdac Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:06:25 -0400 Subject: [PATCH 04/17] Fix flake8 F401 item imported but unused --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 97f17b47..2230329e 100644 --- a/tox.ini +++ b/tox.ini @@ -71,6 +71,7 @@ per-file-ignores = core/utils/__init__.py: F401 core/plugins/downloaders/configuration.py: F401 core/plugins/downloaders/utils.py: F401 + libs/custom/synchronousdeluge/__init__.py: F401 [testenv:check] deps = From 98e8fd581ae9eff7d634a466b9961cece524376a Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:08:31 -0400 Subject: [PATCH 05/17] Fix flake8 E303 too many blank lines --- TorrentToMedia.py | 1 - 1 file changed, 1 deletion(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index dd7c363a..555b101d 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -259,7 +259,6 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp elif section_name == 'LazyLibrarian': result = books.process(section_name, output_destination, input_name, status, client_agent, input_category) - plex_update(input_category) if result.status_code != 0: From 9527a2bd677c400d4b5259db1c5625a469f20afe Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:16:35 -0400 Subject: [PATCH 06/17] Fix flake8 E402 module level import not at top of file --- TorrentToMedia.py | 17 ++++++++++------- nzbToMedia.py | 12 ++++++------ tox.ini | 3 ++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 555b101d..fcd3bac5 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -1,16 +1,15 @@ #!/usr/bin/env python # coding=utf-8 -import eol -eol.check() - -import cleanup -cleanup.clean(cleanup.FOLDER_STRUCTURE) - import datetime import os import sys +import eol +import cleanup +eol.check() +cleanup.clean(cleanup.FOLDER_STRUCTURE) + import core from core import logger, main_db from core.auto_process import comics, games, movies, music, tv, books @@ -18,7 +17,11 @@ from core.auto_process.common import ProcessResult from core.plugins.plex import plex_update from core.user_scripts import external_script from core.utils import char_replace, convert_to_ascii, replace_links -from six import text_type + +try: + text_type = unicode +except NameError: + text_type = str def process_torrent(input_directory, input_name, input_category, input_hash, input_id, client_agent): diff --git a/nzbToMedia.py b/nzbToMedia.py index 8d969d6a..4f43329c 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -657,16 +657,16 @@ from __future__ import print_function -import eol -eol.check() - -import cleanup -cleanup.clean(cleanup.FOLDER_STRUCTURE) - import datetime import os import sys +import eol +import cleanup + +eol.check() +cleanup.clean(cleanup.FOLDER_STRUCTURE) + import core from core import logger, main_db from core.auto_process import comics, games, movies, music, tv, books diff --git a/tox.ini b/tox.ini index 2230329e..fd7a997b 100644 --- a/tox.ini +++ b/tox.ini @@ -66,7 +66,8 @@ ignore = per-file-ignores = ; F401 imported but unused ; E402 module level import not at top of file - nzbTo*.py: E265, E266 + nzbTo*.py: E265, E266, E402 + TorrentToMedia.py: E402 core/__init__.py: E402, F401 core/utils/__init__.py: F401 core/plugins/downloaders/configuration.py: F401 From 90602bf154aa20355466f2bc7d4bcb3d7d866a56 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:17:55 -0400 Subject: [PATCH 07/17] Fix flake8 W293 blank line contains whitespace --- libs/custom/synchronousdeluge/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/custom/synchronousdeluge/__init__.py b/libs/custom/synchronousdeluge/__init__.py index fbafe6fe..e658debc 100644 --- a/libs/custom/synchronousdeluge/__init__.py +++ b/libs/custom/synchronousdeluge/__init__.py @@ -1,7 +1,7 @@ # coding=utf-8 """A synchronous implementation of the Deluge RPC protocol based on gevent-deluge by Christopher Rosell. - + https://github.com/chrippa/gevent-deluge Example usage: From 181675722d7dad38bb08751c896de8ac75253e9e Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:23:24 -0400 Subject: [PATCH 08/17] Fix flake8 W291 trailing whitespace --- libs/custom/utorrent/upload.py | 2 +- nzbToCouchPotato.py | 8 ++++---- nzbToHeadPhones.py | 2 +- nzbToLidarr.py | 14 +++++++------- nzbToMedia.py | 8 ++++---- nzbToMylar.py | 2 +- nzbToNzbDrone.py | 14 +++++++------- nzbToRadarr.py | 14 +++++++------- nzbToSickBeard.py | 8 ++++---- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/libs/custom/utorrent/upload.py b/libs/custom/utorrent/upload.py index 03d58bcc..1ccbcd37 100644 --- a/libs/custom/utorrent/upload.py +++ b/libs/custom/utorrent/upload.py @@ -36,7 +36,7 @@ class MultiPartForm(object): # Build a list of lists, each containing "lines" of the # request. Each part is separated by a boundary string. # Once the list is built, return a string where each - # line is separated by '\r\n'. + # line is separated by '\r\n'. parts = [] part_boundary = '--' + self.boundary diff --git a/nzbToCouchPotato.py b/nzbToCouchPotato.py index be7fb4f3..9869b0e1 100755 --- a/nzbToCouchPotato.py +++ b/nzbToCouchPotato.py @@ -99,7 +99,7 @@ # # Enter Mount points as LocalPath,RemotePath and separate each pair with '|' # e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ -#mountPoints= +#mountPoints= ## Extensions @@ -134,7 +134,7 @@ # subLanguages. # -# subLanguages. create a list of languages in the order you want them in your subtitles. +# subLanguages. create a list of languages in the order you want them in your subtitles. #subLanguages=eng,spa,fra # Transcode (0, 1). @@ -216,7 +216,7 @@ # ffmpeg output settings. #outputVideoExtension=.mp4 #outputVideoCodec=libx264 -#VideoCodecAllow= +#VideoCodecAllow= #outputVideoResolution=720:-1 #outputVideoPreset=medium #outputVideoFramerate=24 @@ -227,7 +227,7 @@ #outputAudioBitrate=640k #outputQualityPercent= #outputAudioTrack2Codec=libfaac -#AudioCodec2Allow= +#AudioCodec2Allow= #outputAudioTrack2Channels=2 #outputAudioTrack2Bitrate=160k #outputAudioOtherCodec=libmp3lame diff --git a/nzbToHeadPhones.py b/nzbToHeadPhones.py index 34103b0c..34fac2e3 100755 --- a/nzbToHeadPhones.py +++ b/nzbToHeadPhones.py @@ -101,7 +101,7 @@ # # Enter Mount points as LocalPath,RemotePath and separate each pair with '|' # e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ -#mountPoints= +#mountPoints= ## WakeOnLan diff --git a/nzbToLidarr.py b/nzbToLidarr.py index d8a20dc8..230d8b9d 100755 --- a/nzbToLidarr.py +++ b/nzbToLidarr.py @@ -84,7 +84,7 @@ # # Enter Mount points as LocalPath,RemotePath and separate each pair with '|' # e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ -#mountPoints= +#mountPoints= ## Extensions @@ -119,7 +119,7 @@ # subLanguages. # -# subLanguages. create a list of languages in the order you want them in your subtitles. +# subLanguages. create a list of languages in the order you want them in your subtitles. #subLanguages = eng,spa,fra # Transcode (0, 1). @@ -145,7 +145,7 @@ # outputVideoPath. # # outputVideoPath. Set path you want transcoded videos moved to. Leave blank to disable. -#outputVideoPath = +#outputVideoPath = # processOutput (0,1). # @@ -201,20 +201,20 @@ # ffmpeg output settings. #outputVideoExtension=.mp4 #outputVideoCodec=libx264 -#VideoCodecAllow = +#VideoCodecAllow = #outputVideoResolution=720:-1 #outputVideoPreset=medium #outputVideoFramerate=24 #outputVideoBitrate=800k #outputAudioCodec=libmp3lame -#AudioCodecAllow = +#AudioCodecAllow = #outputAudioBitrate=128k #outputQualityPercent = 0 #outputAudioTrack2Codec = libfaac -#AudioCodec2Allow = +#AudioCodec2Allow = #outputAudioTrack2Bitrate = 128k #outputAudioOtherCodec = libmp3lame -#AudioOtherCodecAllow = +#AudioOtherCodecAllow = #outputAudioOtherBitrate = 128k #outputSubtitleCodec = diff --git a/nzbToMedia.py b/nzbToMedia.py index 4f43329c..1d479d95 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -450,7 +450,7 @@ # # Enter Mount points as LocalPath,RemotePath and separate each pair with '|' # e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ -#mountPoints= +#mountPoints= ## Extensions @@ -485,7 +485,7 @@ # subLanguages. # -# subLanguages. create a list of languages in the order you want them in your subtitles. +# subLanguages. create a list of languages in the order you want them in your subtitles. #subLanguages=eng,spa,fra # Transcode (0, 1). @@ -567,7 +567,7 @@ # ffmpeg output settings. #outputVideoExtension=.mp4 #outputVideoCodec=libx264 -#VideoCodecAllow= +#VideoCodecAllow= #outputVideoResolution=720:-1 #outputVideoPreset=medium #outputVideoFramerate=24 @@ -578,7 +578,7 @@ #outputAudioBitrate=640k #outputQualityPercent= #outputAudioTrack2Codec=libfaac -#AudioCodec2Allow= +#AudioCodec2Allow= #outputAudioTrack2Channels=2 #outputAudioTrack2Bitrate=160k #outputAudioOtherCodec=libmp3lame diff --git a/nzbToMylar.py b/nzbToMylar.py index 8fe166e3..d16b357a 100755 --- a/nzbToMylar.py +++ b/nzbToMylar.py @@ -92,7 +92,7 @@ # # Enter Mount points as LocalPath,RemotePath and separate each pair with '|' # e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ -#mountPoints= +#mountPoints= ## WakeOnLan diff --git a/nzbToNzbDrone.py b/nzbToNzbDrone.py index b7d0ac33..df551472 100755 --- a/nzbToNzbDrone.py +++ b/nzbToNzbDrone.py @@ -89,7 +89,7 @@ # # Enter Mount points as LocalPath,RemotePath and separate each pair with '|' # e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ -#mountPoints= +#mountPoints= ## Extensions @@ -124,7 +124,7 @@ # subLanguages. # -# subLanguages. create a list of languages in the order you want them in your subtitles. +# subLanguages. create a list of languages in the order you want them in your subtitles. #subLanguages = eng,spa,fra # Transcode (0, 1). @@ -150,7 +150,7 @@ # outputVideoPath. # # outputVideoPath. Set path you want transcoded videos moved to. Leave blank to disable. -#outputVideoPath = +#outputVideoPath = # processOutput (0,1). # @@ -206,20 +206,20 @@ # ffmpeg output settings. #outputVideoExtension=.mp4 #outputVideoCodec=libx264 -#VideoCodecAllow = +#VideoCodecAllow = #outputVideoResolution=720:-1 #outputVideoPreset=medium #outputVideoFramerate=24 #outputVideoBitrate=800k #outputAudioCodec=libmp3lame -#AudioCodecAllow = +#AudioCodecAllow = #outputAudioBitrate=128k #outputQualityPercent = 0 #outputAudioTrack2Codec = libfaac -#AudioCodec2Allow = +#AudioCodec2Allow = #outputAudioTrack2Bitrate = 128k #outputAudioOtherCodec = libmp3lame -#AudioOtherCodecAllow = +#AudioOtherCodecAllow = #outputAudioOtherBitrate = 128k #outputSubtitleCodec = diff --git a/nzbToRadarr.py b/nzbToRadarr.py index 446585bc..fa2aa26e 100755 --- a/nzbToRadarr.py +++ b/nzbToRadarr.py @@ -94,7 +94,7 @@ # # Enter Mount points as LocalPath,RemotePath and separate each pair with '|' # e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ -#mountPoints= +#mountPoints= ## Extensions @@ -129,7 +129,7 @@ # subLanguages. # -# subLanguages. create a list of languages in the order you want them in your subtitles. +# subLanguages. create a list of languages in the order you want them in your subtitles. #subLanguages = eng,spa,fra # Transcode (0, 1). @@ -155,7 +155,7 @@ # outputVideoPath. # # outputVideoPath. Set path you want transcoded videos moved to. Leave blank to disable. -#outputVideoPath = +#outputVideoPath = # processOutput (0,1). # @@ -211,20 +211,20 @@ # ffmpeg output settings. #outputVideoExtension=.mp4 #outputVideoCodec=libx264 -#VideoCodecAllow = +#VideoCodecAllow = #outputVideoResolution=720:-1 #outputVideoPreset=medium #outputVideoFramerate=24 #outputVideoBitrate=800k #outputAudioCodec=libmp3lame -#AudioCodecAllow = +#AudioCodecAllow = #outputAudioBitrate=128k #outputQualityPercent = 0 #outputAudioTrack2Codec = libfaac -#AudioCodec2Allow = +#AudioCodec2Allow = #outputAudioTrack2Bitrate = 128k #outputAudioOtherCodec = libmp3lame -#AudioOtherCodecAllow = +#AudioOtherCodecAllow = #outputAudioOtherBitrate = 128k #outputSubtitleCodec = diff --git a/nzbToSickBeard.py b/nzbToSickBeard.py index 3f1b300d..d342cf0d 100755 --- a/nzbToSickBeard.py +++ b/nzbToSickBeard.py @@ -100,7 +100,7 @@ # # Enter Mount points as LocalPath,RemotePath and separate each pair with '|' # e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ -#mountPoints= +#mountPoints= ## Extensions @@ -135,7 +135,7 @@ # subLanguages. # -# subLanguages. create a list of languages in the order you want them in your subtitles. +# subLanguages. create a list of languages in the order you want them in your subtitles. #subLanguages=eng,spa,fra # Transcode (0, 1). @@ -217,7 +217,7 @@ # ffmpeg output settings. #outputVideoExtension=.mp4 #outputVideoCodec=libx264 -#VideoCodecAllow= +#VideoCodecAllow= #outputVideoResolution=720:-1 #outputVideoPreset=medium #outputVideoFramerate=24 @@ -228,7 +228,7 @@ #outputAudioBitrate=640k #outputQualityPercent= #outputAudioTrack2Codec=libfaac -#AudioCodec2Allow= +#AudioCodec2Allow= #outputAudioTrack2Channels=2 #outputAudioTrack2Bitrate=160k #outputAudioOtherCodec=libmp3lame From 70fa47394ee3abffdf0ce0985d358550737886d7 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:26:13 -0400 Subject: [PATCH 09/17] Fix flake8-docstrings D202 No blank lines allowed after function docstring --- libs/custom/synchronousdeluge/client.py | 1 - libs/custom/utorrent/client.py | 1 - 2 files changed, 2 deletions(-) diff --git a/libs/custom/synchronousdeluge/client.py b/libs/custom/synchronousdeluge/client.py index aa180bf7..ec519687 100644 --- a/libs/custom/synchronousdeluge/client.py +++ b/libs/custom/synchronousdeluge/client.py @@ -141,7 +141,6 @@ class DelugeClient(object): :param username: str, the username to login with :param password: str, the password to login with """ - # Connect transport self.transfer.connect((host, port)) diff --git a/libs/custom/utorrent/client.py b/libs/custom/utorrent/client.py index 2be51c6d..613d94a7 100644 --- a/libs/custom/utorrent/client.py +++ b/libs/custom/utorrent/client.py @@ -32,7 +32,6 @@ class UTorrentClient(object): def _make_opener(self, realm, base_url, username, password): """uTorrent API need HTTP Basic Auth and cookie support for token verify.""" - auth_handler = HTTPBasicAuthHandler() auth_handler.add_password(realm=realm, uri=base_url, From f98b39cdbb0d5bdaa2f49651e21ccc446f155f00 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:27:31 -0400 Subject: [PATCH 10/17] Fix flake8-docstrings D204 1 blank line required after class docstring --- cleanup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cleanup.py b/cleanup.py index d313f2b4..b4cf650e 100644 --- a/cleanup.py +++ b/cleanup.py @@ -25,6 +25,7 @@ FOLDER_STRUCTURE = { class WorkingDirectory(object): """Context manager for changing current working directory.""" + def __init__(self, new, original=None): self.working_directory = new self.original_directory = os.getcwd() if original is None else original From 73e47466b4b86ffc19ec117da2184b40c99419eb Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:30:40 -0400 Subject: [PATCH 11/17] Fix flake8-docstrings D205 1 blank line required between summary line and description --- libs/custom/synchronousdeluge/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/custom/synchronousdeluge/__init__.py b/libs/custom/synchronousdeluge/__init__.py index e658debc..b0283e83 100644 --- a/libs/custom/synchronousdeluge/__init__.py +++ b/libs/custom/synchronousdeluge/__init__.py @@ -1,7 +1,8 @@ # coding=utf-8 -"""A synchronous implementation of the Deluge RPC protocol - based on gevent-deluge by Christopher Rosell. +""" +A synchronous implementation of the Deluge RPC protocol. +Based on gevent-deluge by Christopher Rosell: https://github.com/chrippa/gevent-deluge Example usage: From 093f49d5aab84d0319dde02cbeb47887329f6af2 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:32:06 -0400 Subject: [PATCH 12/17] Fix flake8-docstrings D401 First line should be in imperative mood --- libs/custom/synchronousdeluge/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/custom/synchronousdeluge/client.py b/libs/custom/synchronousdeluge/client.py index ec519687..817aeba1 100644 --- a/libs/custom/synchronousdeluge/client.py +++ b/libs/custom/synchronousdeluge/client.py @@ -18,7 +18,7 @@ RPC_EVENT = 3 class DelugeClient(object): def __init__(self): - """A deluge client session.""" + """Create a deluge client session.""" self.transfer = DelugeTransfer() self.modules = [] self._request_counter = 0 @@ -134,7 +134,7 @@ class DelugeClient(object): return response def connect(self, host="127.0.0.1", port=58846, username="", password=""): - """Connects to a daemon process. + """Connect to a daemon process. :param host: str, the hostname of the daemon :param port: int, the port of the daemon From eec977d9096becd66b58afb257a165ad79f8d30e Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:33:20 -0400 Subject: [PATCH 13/17] Fix flake8-docstrings D403 First word of the first line should be properly capitalized --- libs/custom/utorrent/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/custom/utorrent/client.py b/libs/custom/utorrent/client.py index 613d94a7..fe7e53da 100644 --- a/libs/custom/utorrent/client.py +++ b/libs/custom/utorrent/client.py @@ -31,7 +31,7 @@ class UTorrentClient(object): # TODO refresh token, when necessary def _make_opener(self, realm, base_url, username, password): - """uTorrent API need HTTP Basic Auth and cookie support for token verify.""" + """HTTP Basic Auth and cookie support for token verification.""" auth_handler = HTTPBasicAuthHandler() auth_handler.add_password(realm=realm, uri=base_url, From 81c50efcd6b22651a2b8109a9d1b9367964d77b7 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:37:17 -0400 Subject: [PATCH 14/17] Fix flake8-commas C813 missing trailing comma in Python 3 --- cleanup.py | 2 +- eol.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cleanup.py b/cleanup.py index b4cf650e..f0d4e6d1 100644 --- a/cleanup.py +++ b/cleanup.py @@ -44,7 +44,7 @@ class WorkingDirectory(object): original_directory=self.original_directory, error=error, working_directory=self.working_directory, - ) + ), ) diff --git a/eol.py b/eol.py index a67bfc9e..5504df7e 100644 --- a/eol.py +++ b/eol.py @@ -157,7 +157,7 @@ def print_statuses(show_expired=False): major=python_version[0], minor=python_version[1], remaining=days_left, - ) + ), ) if not show_expired: return @@ -171,7 +171,7 @@ def print_statuses(show_expired=False): major=python_version[0], minor=python_version[1], remaining=-days_left, - ) + ), ) From d608000345f8d6f8a899ca394e0865c8e514bb91 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:38:27 -0400 Subject: [PATCH 15/17] Fix flake8-commas C819 trailing comma prohibited --- libs/custom/utorrent/client.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/custom/utorrent/client.py b/libs/custom/utorrent/client.py index fe7e53da..5d3e1fec 100644 --- a/libs/custom/utorrent/client.py +++ b/libs/custom/utorrent/client.py @@ -60,25 +60,25 @@ class UTorrentClient(object): return self._action(params) def start(self, *hashes): - params = [('action', 'start'), ] + params = [('action', 'start')] for cur_hash in hashes: params.append(('hash', cur_hash)) return self._action(params) def stop(self, *hashes): - params = [('action', 'stop'), ] + params = [('action', 'stop')] for cur_hash in hashes: params.append(('hash', cur_hash)) return self._action(params) def pause(self, *hashes): - params = [('action', 'pause'), ] + params = [('action', 'pause')] for cur_hash in hashes: params.append(('hash', cur_hash)) return self._action(params) def forcestart(self, *hashes): - params = [('action', 'forcestart'), ] + params = [('action', 'forcestart')] for cur_hash in hashes: params.append(('hash', cur_hash)) return self._action(params) @@ -124,13 +124,13 @@ class UTorrentClient(object): self._action(params) def remove(self, *hashes): - params = [('action', 'remove'), ] + params = [('action', 'remove')] for cur_hash in hashes: params.append(('hash', cur_hash)) return self._action(params) def removedata(self, *hashes): - params = [('action', 'removedata'), ] + params = [('action', 'removedata')] for cur_hash in hashes: params.append(('hash', cur_hash)) return self._action(params) From 99159acd8033a22dc518479cc7aaf31c480ce840 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:39:48 -0400 Subject: [PATCH 16/17] Fix flake8-bugbear B007 Loop control variable not used within the loop body. --- TorrentToMedia.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index fcd3bac5..e3665c5e 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -281,7 +281,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp # remove torrent if core.USE_LINK == 'move-sym' and not core.DELETE_ORIGINAL == 1: logger.debug('Checking for sym-links to re-direct in: {0}'.format(input_directory)) - for dirpath, dirs, files in os.walk(input_directory): + for dirpath, _, files in os.walk(input_directory): for file in files: logger.debug('Checking symlink: {0}'.format(os.path.join(dirpath, file))) replace_links(os.path.join(dirpath, file)) From 9f52406d45c4a9830190f87b13ea95ef6baf411c Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 7 Apr 2019 13:44:33 -0400 Subject: [PATCH 17/17] Fix flake8-quotes Q000 Remove bad quotes --- libs/custom/synchronousdeluge/__init__.py | 6 ++-- libs/custom/synchronousdeluge/client.py | 36 ++++++++++----------- libs/custom/synchronousdeluge/exceptions.py | 2 +- libs/custom/synchronousdeluge/transfer.py | 4 +-- libs/custom/utorrent/client.py | 4 +-- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/libs/custom/synchronousdeluge/__init__.py b/libs/custom/synchronousdeluge/__init__.py index b0283e83..ad90cfe8 100644 --- a/libs/custom/synchronousdeluge/__init__.py +++ b/libs/custom/synchronousdeluge/__init__.py @@ -19,6 +19,6 @@ Example usage: from .exceptions import DelugeRPCError -__title__ = "synchronous-deluge" -__version__ = "0.1" -__author__ = "Christian Dale" +__title__ = 'synchronous-deluge' +__version__ = '0.1' +__author__ = 'Christian Dale' diff --git a/libs/custom/synchronousdeluge/client.py b/libs/custom/synchronousdeluge/client.py index 817aeba1..9194ebe8 100644 --- a/libs/custom/synchronousdeluge/client.py +++ b/libs/custom/synchronousdeluge/client.py @@ -9,7 +9,7 @@ from .exceptions import DelugeRPCError from .protocol import DelugeRPCRequest, DelugeRPCResponse from .transfer import DelugeTransfer -__all__ = ["DelugeClient"] +__all__ = ['DelugeClient'] RPC_RESPONSE = 1 RPC_ERROR = 2 @@ -24,35 +24,35 @@ class DelugeClient(object): self._request_counter = 0 def _get_local_auth(self): - username = password = "" + username = password = '' if platform.system() in ('Windows', 'Microsoft'): - app_data_path = os.environ.get("APPDATA") + app_data_path = os.environ.get('APPDATA') if not app_data_path: from six.moves import winreg hkey = winreg.OpenKey( winreg.HKEY_CURRENT_USER, - "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", + 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders', ) - app_data_reg = winreg.QueryValueEx(hkey, "AppData") + app_data_reg = winreg.QueryValueEx(hkey, 'AppData') app_data_path = app_data_reg[0] winreg.CloseKey(hkey) - auth_file = os.path.join(app_data_path, "deluge", "auth") + auth_file = os.path.join(app_data_path, 'deluge', 'auth') else: from xdg.BaseDirectory import save_config_path try: - auth_file = os.path.join(save_config_path("deluge"), "auth") + auth_file = os.path.join(save_config_path('deluge'), 'auth') except OSError: return username, password if os.path.exists(auth_file): for line in open(auth_file): - if line.startswith("#"): + if line.startswith('#'): # This is a comment line continue line = line.strip() try: - lsplit = line.split(":") + lsplit = line.split(':') except Exception: continue @@ -63,13 +63,13 @@ class DelugeClient(object): else: continue - if username == "localclient": + if username == 'localclient': return username, password - return "", "" + return '', '' def _create_module_method(self, module, method): - fullname = "{0}.{1}".format(module, method) + fullname = '{0}.{1}'.format(module, method) def func(obj, *args, **kwargs): return self.remote_call(fullname, *args, **kwargs) @@ -80,18 +80,18 @@ class DelugeClient(object): def _introspect(self): def splitter(value): - return value.split(".") + return value.split('.') self.modules = [] - methods = self.remote_call("daemon.get_method_list").get() + methods = self.remote_call('daemon.get_method_list').get() methodmap = defaultdict(dict) for module, method in imap(splitter, methods): methodmap[module][method] = self._create_module_method(module, method) for module, methods in methodmap.items(): - clsname = "DelugeModule{0}".format(module.capitalize()) + clsname = 'DelugeModule{0}'.format(module.capitalize()) cls = type(clsname, (), methods) setattr(self, module, cls()) self.modules.append(module) @@ -133,7 +133,7 @@ class DelugeClient(object): self._request_counter += 1 return response - def connect(self, host="127.0.0.1", port=58846, username="", password=""): + def connect(self, host='127.0.0.1', port=58846, username='', password=''): """Connect to a daemon process. :param host: str, the hostname of the daemon @@ -145,11 +145,11 @@ class DelugeClient(object): self.transfer.connect((host, port)) # Attempt to fetch local auth info if needed - if not username and host in ("127.0.0.1", "localhost"): + if not username and host in ('127.0.0.1', 'localhost'): username, password = self._get_local_auth() # Authenticate - self.remote_call("daemon.login", username, password).get() + self.remote_call('daemon.login', username, password).get() # Introspect available methods self._introspect() diff --git a/libs/custom/synchronousdeluge/exceptions.py b/libs/custom/synchronousdeluge/exceptions.py index 6da4bdde..dcb23009 100644 --- a/libs/custom/synchronousdeluge/exceptions.py +++ b/libs/custom/synchronousdeluge/exceptions.py @@ -8,4 +8,4 @@ class DelugeRPCError(Exception): self.traceback = traceback def __str__(self): - return "{0}: {1}: {2}".format(self.__class__.__name__, self.name, self.msg) + return '{0}: {1}: {2}'.format(self.__class__.__name__, self.name, self.msg) diff --git a/libs/custom/synchronousdeluge/transfer.py b/libs/custom/synchronousdeluge/transfer.py index 42863b83..cbf49100 100644 --- a/libs/custom/synchronousdeluge/transfer.py +++ b/libs/custom/synchronousdeluge/transfer.py @@ -6,7 +6,7 @@ import zlib import rencode -__all__ = ["DelugeTransfer"] +__all__ = ['DelugeTransfer'] class DelugeTransfer(object): @@ -33,7 +33,7 @@ class DelugeTransfer(object): payload = zlib.compress(rencode.dumps(data)) self.conn.sendall(payload) - buf = b"" + buf = b'' while True: data = self.conn.recv(1024) diff --git a/libs/custom/utorrent/client.py b/libs/custom/utorrent/client.py index 5d3e1fec..ee9ef983 100644 --- a/libs/custom/utorrent/client.py +++ b/libs/custom/utorrent/client.py @@ -94,8 +94,8 @@ class UTorrentClient(object): def setprops(self, cur_hash, **kvpairs): params = [('action', 'setprops'), ('hash', cur_hash)] for k, v in iteritems(kvpairs): - params.append(("s", k)) - params.append(("v", v)) + params.append(('s', k)) + params.append(('v', v)) return self._action(params)