2021-02-15 02:45:21 +00:00
|
|
|
import argparse
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from voussoirkit import pathclass
|
|
|
|
from voussoirkit import pipeable
|
|
|
|
|
|
|
|
def empty_directories_argparse(args):
|
2021-08-11 08:04:41 +00:00
|
|
|
patterns = pipeable.input_many(args.patterns, skip_blank=True, strip=True)
|
2021-09-24 06:42:34 +00:00
|
|
|
directories = pathclass.glob_many(patterns, directories=True)
|
2021-02-21 05:01:55 +00:00
|
|
|
|
2021-02-15 02:45:21 +00:00
|
|
|
for directory in directories:
|
|
|
|
if len(directory.listdir()) == 0:
|
|
|
|
pipeable.stdout(directory.absolute_path)
|
|
|
|
|
2021-09-24 06:42:34 +00:00
|
|
|
return 0
|
|
|
|
|
2021-02-15 02:45:21 +00:00
|
|
|
def main(argv):
|
|
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
|
|
|
2021-08-11 08:04:41 +00:00
|
|
|
parser.add_argument('patterns', nargs='*', default=['*'])
|
2021-02-15 02:45:21 +00:00
|
|
|
parser.set_defaults(func=empty_directories_argparse)
|
|
|
|
|
|
|
|
args = parser.parse_args(argv)
|
|
|
|
return args.func(args)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
raise SystemExit(main(sys.argv[1:]))
|