Let sole_subdir_lift take patterns for many directories.

This commit is contained in:
voussoir 2021-02-14 18:28:27 -08:00
parent 7fdda50a13
commit 037cec790a
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -10,6 +10,9 @@ import sys
from voussoirkit import passwordy from voussoirkit import passwordy
from voussoirkit import pathclass from voussoirkit import pathclass
from voussoirkit import pipeable
from voussoirkit import spinal
from voussoirkit import winglob
def sole_lift(starting): def sole_lift(starting):
starting = pathclass.Path(starting) starting = pathclass.Path(starting)
@ -32,15 +35,17 @@ def sole_lift(starting):
os.rmdir(temp_dir.absolute_path) os.rmdir(temp_dir.absolute_path)
return 0
def sole_lift_argparse(args): 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): def main(argv):
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('starting', nargs='?', default='.') parser.add_argument('patterns', nargs='+', default='.')
parser.set_defaults(func=sole_lift_argparse) parser.set_defaults(func=sole_lift_argparse)
args = parser.parse_args(argv) args = parser.parse_args(argv)