From patchwork Tue May 12 00:03:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3769 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C53F060DFF for ; Tue, 12 May 2020 02:03:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DwfIzeZ9"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8FC1911F3; Tue, 12 May 2020 02:03:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1589241821; bh=F/fY9K9F6nwFGE9kNSsCFFWxjlgTAsj6Aqo1FYCQKc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DwfIzeZ9Y0H+AbmK9YxSx9tN8z9GOr6h+I9X12panLVcbmcIezY/rUP12gwCpfzlp jV5eN4og3UnC/vUzeQQwAEguycGbZwqWzTzq6BIFImOS7AAavOwv6YNeUw/WrUYp3O yJDKOqxwPcjf6To4Jft9CV1uJPjaB7i7TZstk2DM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 12 May 2020 03:03:13 +0300 Message-Id: <20200512000322.11753-16-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512000322.11753-1-laurent.pinchart@ideasonboard.com> References: <20200512000322.11753-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 15/24] utils: raspberrypi: ctt: Fix pycodestyle E711 and E712 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 May 2020 00:03:42 -0000 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 --- utils/raspberrypi/ctt/ctt.py | 18 +++++++++--------- utils/raspberrypi/ctt/ctt_awb.py | 4 ++-- utils/raspberrypi/ctt/ctt_ccm.py | 2 +- utils/raspberrypi/ctt/ctt_image_load.py | 4 ++-- utils/raspberrypi/ctt/ctt_macbeth_locator.py | 2 +- utils/raspberrypi/ctt/ctt_tools.py | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py index f4cf37a03611..6a17e7898730 100755 --- a/utils/raspberrypi/ctt/ctt.py +++ b/utils/raspberrypi/ctt/ctt.py @@ -534,17 +534,17 @@ class Camera: self.log_new_sec('User Arguments', cal=False) self.log += '\nJson file output: ' + json_output self.log += '\nCalibration images directory: ' + directory - if config == None: + if config is None: 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 += ' using default options' - elif config == True: + elif config is True: self.log += '\nWARNING: Invalid syntax in configuration file...' self.log += ' using default options' else: 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' else: self.log += '\nLog file output: ' + log_output @@ -555,7 +555,7 @@ class Camera: write log file """ def write_log(self, filename): - if filename == None: + if filename is None: filename = 'ctt_log.txt' self.log += '\n' + self.log_separator with open(filename, 'w') as logfile: @@ -604,7 +604,7 @@ class Camera: """ 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 """ @@ -627,7 +627,7 @@ class Camera: if image isn't an alsc correction then it must have a lux and a colour temperature value to be useful """ - if lux == None: + if lux is None: print('DISCARDED') self.log += '\nWARNING: Error reading lux value' self.log += '\nImage discarded!' @@ -707,7 +707,7 @@ def run_ctt(json_output, directory, config, log_output): """ if json_output[-5:] != '.json': 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 """ @@ -790,7 +790,7 @@ def run_ctt(json_output, directory, config, log_output): Cam.write_json() Cam.write_log(log_output) print('\nCalibrations written to: '+json_output) - if log_output == None: + if log_output is None: log_output = 'ctt_log.txt' print('Log file written to: '+log_output) pass diff --git a/utils/raspberrypi/ctt/ctt_awb.py b/utils/raspberrypi/ctt/ctt_awb.py index 9b30115f53f4..c269b67a12c0 100644 --- a/utils/raspberrypi/ctt/ctt_awb.py +++ b/utils/raspberrypi/ctt/ctt_awb.py @@ -17,7 +17,7 @@ def awb(Cam, cal_cr_list, cal_cb_list, plot): """ condense alsc calibration tables into one dictionary """ - if cal_cr_list == None: + if cal_cr_list is None: colour_cals = None else: colour_cals = {} @@ -315,7 +315,7 @@ def get_alsc_patches(Img, colour_cals, grey=True): b_patchs = patches[3] - 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 """ find where image colour fits in alsc colour calibration tables diff --git a/utils/raspberrypi/ctt/ctt_ccm.py b/utils/raspberrypi/ctt/ctt_ccm.py index adc4d290ae7e..21be4d6fb1b1 100644 --- a/utils/raspberrypi/ctt/ctt_ccm.py +++ b/utils/raspberrypi/ctt/ctt_ccm.py @@ -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 deactivated """ - if cal_cr_list == None: + if cal_cr_list is None: colour_cals = None else: colour_cals = {} diff --git a/utils/raspberrypi/ctt/ctt_image_load.py b/utils/raspberrypi/ctt/ctt_image_load.py index 38026c7a93c0..787307508ba5 100644 --- a/utils/raspberrypi/ctt/ctt_image_load.py +++ b/utils/raspberrypi/ctt/ctt_image_load.py @@ -232,7 +232,7 @@ def brcm_load_image(Cam, im_str): """ return error if problem reading file """ - if f == None: + if f is None: print('\nERROR:\nProblem reading file') Cam.log += '\nWARNING: Problem readin file' 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 macbeth == None: + if macbeth is None: print('\nERROR: No macbeth chart found') return 0 mac_cen_coords = macbeth[1] diff --git a/utils/raspberrypi/ctt/ctt_macbeth_locator.py b/utils/raspberrypi/ctt/ctt_macbeth_locator.py index 94bbf580db84..05d1bd437001 100644 --- a/utils/raspberrypi/ctt/ctt_macbeth_locator.py +++ b/utils/raspberrypi/ctt/ctt_macbeth_locator.py @@ -258,7 +258,7 @@ def find_macbeth(Cam, img, mac_config=(0, 0)): """ 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() verts = coords_fit[0][0] cents = coords_fit[1][0] diff --git a/utils/raspberrypi/ctt/ctt_tools.py b/utils/raspberrypi/ctt/ctt_tools.py index e5871b60d6a2..27080de08cec 100644 --- a/utils/raspberrypi/ctt/ctt_tools.py +++ b/utils/raspberrypi/ctt/ctt_tools.py @@ -62,9 +62,9 @@ def parse_input(): directory = get_config(args_dict, '-i', None, 'string') config = get_config(args_dict, '-c', 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.') - if json_output == None: + if json_output is None: raise ArgError('\n\nERROR! No output json given.') return json_output, directory, config, log_path """