From 0f9cf875204a4d13da248c83d1737787948112b7 Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Sun, 18 Oct 2020 19:46:51 +0200 Subject: [PATCH] client.py: Extract searching pictures from show_pictures() --- playbook/templates/client.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/playbook/templates/client.py b/playbook/templates/client.py index 3cf4c6d..a83222a 100755 --- a/playbook/templates/client.py +++ b/playbook/templates/client.py @@ -14,19 +14,23 @@ binding_accept = [ord('l'), ord(' '), ord('\n')] binding_back = [ord('h'), ord('q'), curses.KEY_BACKSPACE] binding_exit = [ord('Q')] -def show_pictures(path): - files = sorted([str(f) for f in path.iterdir() if f.is_file() and f.suffix.lower() in ['.png', '.jpg', '.jpeg', '.gif']]) +def show_pictures(files): + files = list(files) # copy list files.insert(0, '/usr/bin/imvr') subprocess.call(files) return True +def search_pictures(win, path): + files = sorted([str(f) for f in path.iterdir() if f.is_file() and f.suffix.lower() in ['.png', '.jpg', '.jpeg', '.gif']]) + return show_pictures(files) + def show_select(win, path): if not path.is_dir(): raise Exception("'" + str(path) + "' is not a directory!") dirs = sorted([d for d in path.iterdir() if d.is_dir()]) win.clear() if len(dirs) <= 0: - return show_pictures(path) + return search_pictures(win, path) sel = 0 while True: for y, d in enumerate(dirs):