Add CLI flag --delete
This commit is contained in:
parent
37d418bda4
commit
bf828bbac5
@ -49,9 +49,12 @@ class imgrate:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
from os import remove
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
ap = ArgumentParser()
|
ap = ArgumentParser()
|
||||||
ap.add_argument('images', type=str, nargs='+', help='')
|
ap.add_argument('images', type=str, nargs='+', help='')
|
||||||
|
ap.add_argument('-d', '--delete', action='store_true', help='Delete all but the best quality image.')
|
||||||
return ap.parse_args()
|
return ap.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@ -63,4 +66,8 @@ if __name__ == '__main__':
|
|||||||
maxmark = '*' if rating == maximum and len(ratings) > 1 else ' '
|
maxmark = '*' if rating == maximum and len(ratings) > 1 else ' '
|
||||||
print('{}imgrate("{}") = {}'.format(maxmark, rating, ratings[rating]))
|
print('{}imgrate("{}") = {}'.format(maxmark, rating, ratings[rating]))
|
||||||
|
|
||||||
|
if args.delete:
|
||||||
|
[remove(image) for image in ratings if image != maximum]
|
||||||
|
|
||||||
|
|
||||||
run(parse_arguments())
|
run(parse_arguments())
|
||||||
|
Loading…
Reference in New Issue
Block a user