Refactor __main__
This commit is contained in:
parent
461fd8e8f0
commit
37d418bda4
21
imgrate.py
21
imgrate.py
@ -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())
|
||||||
|
Loading…
Reference in New Issue
Block a user