From a5ba8fbbe21abe3af735831c68290af94266db75 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 28 Aug 2021 22:51:21 +0700 Subject: [PATCH] some linting and readability improvements --- interface.py | 10 +++++----- src/config.py | 2 +- src/db_export.py | 4 ++-- src/trailers.py | 5 +++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/interface.py b/interface.py index e1c4120..8bd548d 100755 --- a/interface.py +++ b/interface.py @@ -8,11 +8,11 @@ from time import sleep from src.config import get_config -import src.tvsort as tvsort -import src.moviesort as moviesort -import src.db_export as db_export -import src.trailers as trailers -import src.id_fix as id_fix +from src import tvsort +from src import moviesort +from src import db_export +from src import trailers +from src import id_fix class Interface: diff --git a/src/config.py b/src/config.py index 4867493..29f7847 100644 --- a/src/config.py +++ b/src/config.py @@ -16,7 +16,7 @@ def get_config(): else: config_path = path.join(root_folder, 'config.json') # parse - with open(config_path, 'r') as config_file: + with open(config_path, 'r', encoding='utf-8') as config_file: data = config_file.read() config = json.loads(data) return config diff --git a/src/db_export.py b/src/db_export.py index 8135ea2..553e6e6 100644 --- a/src/db_export.py +++ b/src/db_export.py @@ -126,7 +126,7 @@ class DatabaseExport: file_path = path.join(log_folder, filename) # open and write - with open(file_path, 'w') as f: + with open(file_path, 'w', encoding='utf-8') as f: # take fieldnames from first line fieldnames = to_write[0].keys() csv_writer = csv.DictWriter(f, fieldnames) @@ -138,7 +138,7 @@ class DatabaseExport: log_folder = self.CONFIG['media']['log_folder'] file_path = path.join(log_folder, filename) # movie by new - with open(file_path, 'w') as f: + with open(file_path, 'w', encoding='utf-8') as f: for line in to_write: f.write(line + '\n') diff --git a/src/trailers.py b/src/trailers.py index 0a4d5c6..82e58d4 100644 --- a/src/trailers.py +++ b/src/trailers.py @@ -67,7 +67,7 @@ class TrailerHandler: """ read log file to get list of trailers to ignore """ log_folder = self.CONFIG['media']['log_folder'] log_file = os.path.join(log_folder, 'trailers') - with open(log_file, 'r') as log_file: + with open(log_file, 'r', encoding='utf-8') as log_file: trailer_lines = log_file.readlines() ignore_trailer_list = [] for trailer_line in trailer_lines: @@ -97,6 +97,7 @@ class TrailerHandler: return pending def dl_pending(self): + # pylint: disable=broad-except """ download pending trailers """ sortpath = self.CONFIG['media']['sortpath'] log_folder = self.CONFIG['media']['log_folder'] @@ -121,7 +122,7 @@ class TrailerHandler: if i == 4: # giving up log_file = os.path.join(log_folder, 'trailers') - with open(log_file, 'a') as f: + with open(log_file, 'a', encoding='utf-8') as f: f.write(f'{youtube_id} {movie_name}\n') break sleep((i + 1) ** 2)