From fba95abb417e0907c6148b61acae791ae01adb28 Mon Sep 17 00:00:00 2001 From: Chandler J Date: Sat, 13 Apr 2024 13:44:44 -0600 Subject: more smarter and better --- src/get_args.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/get_args.py') diff --git a/src/get_args.py b/src/get_args.py index 9197995..5419fc4 100644 --- a/src/get_args.py +++ b/src/get_args.py @@ -17,19 +17,15 @@ def get_args(args, walls_dir, theme_dir) -> tuple: index = args.index('-p') isFile = os.path.isfile(args[index + 1]) if isFile == True: - print("reached") theme = manage_saves.load_theme(args[index + 1]) + img_path = grab_image(args) elif '-t' in args: theme = user_interface.themeSelector(theme_dir) img_path = theme['wallpaper'] elif '-r' in args: img_path = user_interface.pickRandomWallpaper(walls_dir) else: - img_path = f"{os.getcwd()}/{args[1]}" - if not os.path.exists(img_path) and\ - args[1] not in VALID_ARGS: - print(f'[bold red]ERROR: invalid image path {os.getcwd()}/{args[1]}') - exit(2) + img_path = grab_image(args) if '--initialize' in args: initialize = True @@ -38,6 +34,15 @@ def get_args(args, walls_dir, theme_dir) -> tuple: return img_path, initialize, reconfigure, theme +def grab_image(args): + img_path = f"{os.getcwd()}/{args[1]}" + if not os.path.exists(img_path): + print(f'[bold red]ERROR: invalid image path {os.getcwd()}/{args[1]}') + exit(2) + else: + return img_path + + def usage(args) -> None: print(f"""Instant Rice - An automatic theming utilitiy -- cgit v1.2.3