Nicen coding style

This commit is contained in:
Kristóf Tóth 2018-04-14 18:26:56 +02:00
parent 4f82f5f8f0
commit ef37a30e7d

View File

@ -1,9 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import cv2
import numpy as np
from argparse import ArgumentParser from argparse import ArgumentParser
from functools import wraps from functools import wraps
import cv2
import numpy as np
def image_required(fun): def image_required(fun):
@ -16,11 +16,11 @@ def image_required(fun):
return wrapper return wrapper
class imgrate: class imgrate:
def __init__(self, imgfile=None): def __init__(self, imgfile=None):
self.image = None self.image = None
if imgfile: self.load_image(imgfile) if imgfile:
self.load_image(imgfile)
def load_image(self, imgfile): def load_image(self, imgfile):
image = cv2.imread(imgfile) image = cv2.imread(imgfile)
@ -47,7 +47,6 @@ class imgrate:
return Th / (F.shape[0] * F.shape[1]) return Th / (F.shape[0] * F.shape[1])
if __name__ == '__main__': if __name__ == '__main__':
from os import remove from os import remove
from sys import exit from sys import exit
@ -66,8 +65,10 @@ if __name__ == '__main__':
def run(args): def run(args):
try: ratings = {image: getattr(imgrate(image), args.method) for image in args.images} try:
except AttributeError: exit('Invalid --method option!') ratings = {image: getattr(imgrate(image), args.method) for image in args.images}
except AttributeError:
exit('Invalid --method option!')
maximum = max(ratings, key=ratings.get) maximum = max(ratings, key=ratings.get)
for rating in ratings.keys(): for rating in ratings.keys():