[libcamera-devel,15/24] utils: raspberrypi: ctt: Fix pycodestyle E711 and E712

Message ID 20200512000322.11753-16-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • utils: raspberrypi: ctt: Comply with pycodestyle
Related show

Commit Message

Laurent Pinchart May 12, 2020, 12:03 a.m. UTC
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>
---
 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(-)

Patch

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
 """