utils: raspberrypi: ctt: Fix pycodestyle E711 and E712

E711 comparison to None should be 'if cond is None:'
E711 comparison to None should be 'if cond is not None:'
E712 comparison to False should be 'if cond is False:' or 'if not cond:'
E712 comparison to True should be 'if cond is True:' or 'if cond:'

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
This commit is contained in:
Laurent Pinchart 2020-05-02 03:32:00 +03:00
parent 5f2160cc96
commit ca73168e75
6 changed files with 17 additions and 17 deletions

View file

@ -534,17 +534,17 @@ class Camera:
self.log_new_sec('User Arguments', cal=False) self.log_new_sec('User Arguments', cal=False)
self.log += '\nJson file output: ' + json_output self.log += '\nJson file output: ' + json_output
self.log += '\nCalibration images directory: ' + directory self.log += '\nCalibration images directory: ' + directory
if config == None: if config is None:
self.log += '\nNo configuration file input... using default options' self.log += '\nNo configuration file input... using default options'
elif config == False: elif config is False:
self.log += '\nWARNING: Invalid configuration file path...' self.log += '\nWARNING: Invalid configuration file path...'
self.log += ' using default options' self.log += ' using default options'
elif config == True: elif config is True:
self.log += '\nWARNING: Invalid syntax in configuration file...' self.log += '\nWARNING: Invalid syntax in configuration file...'
self.log += ' using default options' self.log += ' using default options'
else: else:
self.log += '\nConfiguration file: ' + config self.log += '\nConfiguration file: ' + config
if log_output == None: if log_output is None:
self.log += '\nNo log file path input... using default: ctt_log.txt' self.log += '\nNo log file path input... using default: ctt_log.txt'
else: else:
self.log += '\nLog file output: ' + log_output self.log += '\nLog file output: ' + log_output
@ -555,7 +555,7 @@ class Camera:
write log file write log file
""" """
def write_log(self, filename): def write_log(self, filename):
if filename == None: if filename is None:
filename = 'ctt_log.txt' filename = 'ctt_log.txt'
self.log += '\n' + self.log_separator self.log += '\n' + self.log_separator
with open(filename, 'w') as logfile: with open(filename, 'w') as logfile:
@ -604,7 +604,7 @@ class Camera:
""" """
check that image colour temperature has been successfuly obtained check that image colour temperature has been successfuly obtained
""" """
elif col != None: elif col is not None:
""" """
if successful, append to list and continue to next image if successful, append to list and continue to next image
""" """
@ -627,7 +627,7 @@ class Camera:
if image isn't an alsc correction then it must have a lux and a if image isn't an alsc correction then it must have a lux and a
colour temperature value to be useful colour temperature value to be useful
""" """
if lux == None: if lux is None:
print('DISCARDED') print('DISCARDED')
self.log += '\nWARNING: Error reading lux value' self.log += '\nWARNING: Error reading lux value'
self.log += '\nImage discarded!' self.log += '\nImage discarded!'
@ -707,7 +707,7 @@ def run_ctt(json_output, directory, config, log_output):
""" """
if json_output[-5:] != '.json': if json_output[-5:] != '.json':
raise ArgError('\n\nError: Output must be a json file!') raise ArgError('\n\nError: Output must be a json file!')
if config != None: if config is not None:
""" """
check if config file is actually a json check if config file is actually a json
""" """
@ -790,7 +790,7 @@ def run_ctt(json_output, directory, config, log_output):
Cam.write_json() Cam.write_json()
Cam.write_log(log_output) Cam.write_log(log_output)
print('\nCalibrations written to: '+json_output) print('\nCalibrations written to: '+json_output)
if log_output == None: if log_output is None:
log_output = 'ctt_log.txt' log_output = 'ctt_log.txt'
print('Log file written to: '+log_output) print('Log file written to: '+log_output)
pass pass

View file

@ -17,7 +17,7 @@ def awb(Cam, cal_cr_list, cal_cb_list, plot):
""" """
condense alsc calibration tables into one dictionary condense alsc calibration tables into one dictionary
""" """
if cal_cr_list == None: if cal_cr_list is None:
colour_cals = None colour_cals = None
else: else:
colour_cals = {} colour_cals = {}
@ -315,7 +315,7 @@ def get_alsc_patches(Img, colour_cals, grey=True):
b_patchs = patches[3] - Img.blacklevel_16 b_patchs = patches[3] - Img.blacklevel_16
g_patchs = (patches[1]+patches[2])/2 - Img.blacklevel_16 g_patchs = (patches[1]+patches[2])/2 - Img.blacklevel_16
if colour_cals == None: if colour_cals is None:
return r_patchs, b_patchs, g_patchs return r_patchs, b_patchs, g_patchs
""" """
find where image colour fits in alsc colour calibration tables find where image colour fits in alsc colour calibration tables

View file

@ -64,7 +64,7 @@ def ccm(Cam, cal_cr_list, cal_cb_list):
reformat alsc correction tables or set colour_cals to None if alsc is reformat alsc correction tables or set colour_cals to None if alsc is
deactivated deactivated
""" """
if cal_cr_list == None: if cal_cr_list is None:
colour_cals = None colour_cals = None
else: else:
colour_cals = {} colour_cals = {}

View file

@ -232,7 +232,7 @@ def brcm_load_image(Cam, im_str):
""" """
return error if problem reading file return error if problem reading file
""" """
if f == None: if f is None:
print('\nERROR:\nProblem reading file') print('\nERROR:\nProblem reading file')
Cam.log += '\nWARNING: Problem readin file' Cam.log += '\nWARNING: Problem readin file'
return 0 return 0
@ -376,7 +376,7 @@ def load_image(Cam, im_str, mac_config=None, show=False, mac=True, show_meta=Fal
""" """
if no macbeth found return error if no macbeth found return error
""" """
if macbeth == None: if macbeth is None:
print('\nERROR: No macbeth chart found') print('\nERROR: No macbeth chart found')
return 0 return 0
mac_cen_coords = macbeth[1] mac_cen_coords = macbeth[1]

View file

@ -258,7 +258,7 @@ def find_macbeth(Cam, img, mac_config=(0, 0)):
""" """
extract data from coords_fit and plot on original image extract data from coords_fit and plot on original image
""" """
if show and coords_fit != None: if show and coords_fit is not None:
copy = img.copy() copy = img.copy()
verts = coords_fit[0][0] verts = coords_fit[0][0]
cents = coords_fit[1][0] cents = coords_fit[1][0]

View file

@ -62,9 +62,9 @@ def parse_input():
directory = get_config(args_dict, '-i', None, 'string') directory = get_config(args_dict, '-i', None, 'string')
config = get_config(args_dict, '-c', None, 'string') config = get_config(args_dict, '-c', None, 'string')
log_path = get_config(args_dict, '-l', None, 'string') log_path = get_config(args_dict, '-l', None, 'string')
if directory == None: if directory is None:
raise ArgError('\n\nERROR! No input directory given.') raise ArgError('\n\nERROR! No input directory given.')
if json_output == None: if json_output is None:
raise ArgError('\n\nERROR! No output json given.') raise ArgError('\n\nERROR! No output json given.')
return json_output, directory, config, log_path return json_output, directory, config, log_path
""" """