From 037cec790aa30faa16ab85b305f8e61e46e0c904 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 14 Feb 2021 18:28:27 -0800 Subject: [PATCH] Let sole_subdir_lift take patterns for many directories. --- sole_subdir_lift.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sole_subdir_lift.py b/sole_subdir_lift.py index 6b67353..121cca7 100644 --- a/sole_subdir_lift.py +++ b/sole_subdir_lift.py @@ -10,6 +10,9 @@ import sys from voussoirkit import passwordy from voussoirkit import pathclass +from voussoirkit import pipeable +from voussoirkit import spinal +from voussoirkit import winglob def sole_lift(starting): starting = pathclass.Path(starting) @@ -32,15 +35,17 @@ def sole_lift(starting): os.rmdir(temp_dir.absolute_path) - return 0 - def sole_lift_argparse(args): - return sole_lift(args.starting) + patterns = pipeable.input_many(args.patterns, skip_blank=True, strip=True) + directories = (pathclass.Path(d) for pattern in patterns for d in winglob.glob(pattern)) + directories = (d for d in directories if d.is_dir) + for directory in directories: + sole_lift(directory) def main(argv): parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument('starting', nargs='?', default='.') + parser.add_argument('patterns', nargs='+', default='.') parser.set_defaults(func=sole_lift_argparse) args = parser.parse_args(argv)