Refactor __main__

This commit is contained in:
Kristóf Tóth 2018-02-24 21:03:36 +01:00
parent 461fd8e8f0
commit 37d418bda4

View File

@ -49,13 +49,18 @@ class imgrate:
if __name__ == '__main__': if __name__ == '__main__':
ap = ArgumentParser() def parse_arguments():
ap.add_argument('images', type=str, nargs='+', help='') ap = ArgumentParser()
args = ap.parse_args() ap.add_argument('images', type=str, nargs='+', help='')
return ap.parse_args()
ratings = {image: imgrate(image).quality for image in args.images}
maximum = max(ratings, key=ratings.get)
for rating in ratings.keys(): def run(args):
maxmark = '*' if rating == maximum and len(ratings) > 1 else ' ' ratings = {image: imgrate(image).quality for image in args.images}
print('{}imgrate("{}") = {}'.format(maxmark, rating, ratings[rating])) maximum = max(ratings, key=ratings.get)
for rating in ratings.keys():
maxmark = '*' if rating == maximum and len(ratings) > 1 else ' '
print('{}imgrate("{}") = {}'.format(maxmark, rating, ratings[rating]))
run(parse_arguments())