Refactor __main__
This commit is contained in:
parent
461fd8e8f0
commit
37d418bda4
@ -49,13 +49,18 @@ class imgrate:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
def parse_arguments():
|
||||||
ap = ArgumentParser()
|
ap = ArgumentParser()
|
||||||
ap.add_argument('images', type=str, nargs='+', help='')
|
ap.add_argument('images', type=str, nargs='+', help='')
|
||||||
args = ap.parse_args()
|
return ap.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def run(args):
|
||||||
ratings = {image: imgrate(image).quality for image in args.images}
|
ratings = {image: imgrate(image).quality for image in args.images}
|
||||||
maximum = max(ratings, key=ratings.get)
|
maximum = max(ratings, key=ratings.get)
|
||||||
|
|
||||||
for rating in ratings.keys():
|
for rating in ratings.keys():
|
||||||
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]))
|
||||||
|
|
||||||
|
run(parse_arguments())
|
||||||
|
Loading…
Reference in New Issue
Block a user