From 0ff205615f98490cf56e483f6414a3302097aec0 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 2 Feb 2019 00:28:56 +0100 Subject: [PATCH 1/3] This is not js is it? --- src/cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cli.py b/src/cli.py index 204d679..802d465 100755 --- a/src/cli.py +++ b/src/cli.py @@ -15,9 +15,9 @@ def tweet(video): def prompt(name): manual_name = input("Insufficient name: '{}'\nInput name manually: ".format(name)) - if manual_name is 'q': - assert KeyboardInterrupt - if manual_name is 's': + if manual_name == 'q': + raise KeyboardInterrupt + if manual_name == 's': return None From 2977ab53b2bb50b0186f2a555e09896f36fc34e7 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 2 Feb 2019 00:33:32 +0100 Subject: [PATCH 2/3] Allow a instuffient name to be thrown. Also, pop was not the correct way to remove elements from the list, del on a index is now used. --- src/cli.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/cli.py b/src/cli.py index 802d465..9ab67be 100755 --- a/src/cli.py +++ b/src/cli.py @@ -6,9 +6,6 @@ from core import scan_folder, moveHome from video import Video from exceptions import InsufficientNameError -def moveHome(video): - print('Would have moved: {}'.format(video)) - def tweet(video): pass @@ -25,7 +22,7 @@ def prompt(name): @click.command() @click.argument('path') -@click.option('--daemon', '-d', daemon) +@click.option('--daemon', '-d') def main(path, daemon): videos, insufficient_name = scan_folder(path) @@ -33,22 +30,18 @@ def main(path, daemon): moveHome(video) while len(insufficient_name) >= 1: - for file in insufficient_name: + for i, file in enumerate(insufficient_name): try: manual_name = prompt(file) if manual_name is None: - insufficient_name.pop() + del insufficient_name[i] continue - try: - video = Video.fromguess(file, guessit(manual_name)) - moveHome(video) - insufficient_name.pop() + video = Video.fromguess(file, guessit(manual_name)) + moveHome(video) + del insufficient_name[i] - except InsufficientNameError: - continue - except KeyboardInterrupt: # Logger: Received interrupt, exiting parser. # should the class objects be deleted ? From e3c1f18e3d28aa2577333adbf35edb9a5f39f80c Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 2 Feb 2019 00:34:40 +0100 Subject: [PATCH 3/3] Changed default logging level. --- src/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core.py b/src/core.py index 71eb0f8..16e00a7 100755 --- a/src/core.py +++ b/src/core.py @@ -25,7 +25,7 @@ from video import VIDEO_EXTENSIONS, Episode, Movie, Video from subtitle import SUBTITLE_EXTENSIONS, Subtitle, get_subtitle_path from utils import sanitize, refine -logging.basicConfig(filename=env.logfile, level=logging.DEBUG) +logging.basicConfig(filename=env.logfile, level=logging.INFO) logger = logging.getLogger('seasonedParser') fh = logging.FileHandler(env.logfile) fh.setLevel(logging.INFO) @@ -191,7 +191,7 @@ def scan_videos(path): if filename.endswith(VIDEO_EXTENSIONS): # video try: video = scan_video(filepath) - except InsufficientInfoError as e: + except InsufficientNameError as e: logger.info(e) insufficient_name.append(filepath) continue