Static analysis session.
authorThomas Mansencal <thomas.mansencal@gmail.com>
Mon, 19 Jan 2015 16:25:15 +0000 (17:25 +0100)
committerThomas Mansencal <thomas.mansencal@gmail.com>
Mon, 19 Jan 2015 16:25:15 +0000 (17:25 +0100)
aces_1.0.0/python/aces_ocio/create_aces_config.py
aces_1.0.0/python/aces_ocio/create_sony_colorspaces.py
aces_1.0.0/python/aces_ocio/generate_lut.py
aces_1.0.0/python/aces_ocio/process.py
aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py

index befe6f2..e83896a 100755 (executable)
@@ -560,8 +560,7 @@ def generate_LUTs(odt_info,
             'type': 'matrix',
             'matrix': adx_to_cdd,
             'offset': offset,
             'type': 'matrix',
             'matrix': adx_to_cdd,
             'offset': offset,
-            'direction': 'forward'
-        })
+            'direction': 'forward'})
 
         # Convert from Channel-Dependent Density to Channel-Independent Density
         cs.to_reference_transforms.append({
 
         # Convert from Channel-Dependent Density to Channel-Independent Density
         cs.to_reference_transforms.append({
@@ -570,8 +569,7 @@ def generate_LUTs(odt_info,
                        0.05901, 0.96928, -0.02829, 0,
                        0.16134, 0.07406, 0.76460, 0,
                        0.0, 0.0, 0.0, 1.0],
                        0.05901, 0.96928, -0.02829, 0,
                        0.16134, 0.07406, 0.76460, 0,
                        0.0, 0.0, 0.0, 1.0],
-            'direction': 'forward'
-        })
+            'direction': 'forward'})
 
         # Copied from *Alex Fry*'s *adx_cid_to_rle.py*
         def create_CID_to_RLE_LUT():
 
         # Copied from *Alex Fry*'s *adx_cid_to_rle.py*
         def create_CID_to_RLE_LUT():
@@ -1170,8 +1168,14 @@ def generate_LUTs(odt_info,
     # Generic Matrix transform
     # -------------------------------------------------------------------------
     def create_generic_matrix(name='matrix',
     # Generic Matrix transform
     # -------------------------------------------------------------------------
     def create_generic_matrix(name='matrix',
-                              from_reference_values=[],
-                              to_reference_values=[]):
+                              from_reference_values=None,
+                              to_reference_values=None):
+
+        if from_reference_values is None:
+             from_reference_values = []
+        if to_reference_values is None:
+             to_reference_values = []
+
         cs = ColorSpace(name)
         cs.description = 'The %s color space' % name
         cs.equality_group = name
         cs = ColorSpace(name)
         cs.description = 'The %s color space' % name
         cs.equality_group = name
@@ -1504,7 +1508,7 @@ def get_ODT_info(aces_CTL_directory):
         # Add to list of ODTs
         odts[odt_name] = {}
         odts[odt_name]['transformCTL'] = os.path.join(odt_dir, transform_CTL)
         # Add to list of ODTs
         odts[odt_name] = {}
         odts[odt_name]['transformCTL'] = os.path.join(odt_dir, transform_CTL)
-        if transform_CTL_inverse != None:
+        if transform_CTL_inverse is not None:
             odts[odt_name]['transformCTLInverse'] = os.path.join(
                 odt_dir, transform_CTL_inverse)
 
             odts[odt_name]['transformCTLInverse'] = os.path.join(
                 odt_dir, transform_CTL_inverse)
 
@@ -1590,7 +1594,7 @@ def get_LMT_info(aces_CTL_directory):
 
         lmts[lmt_name] = {}
         lmts[lmt_name]['transformCTL'] = os.path.join(lmt_dir, transform_CTL)
 
         lmts[lmt_name] = {}
         lmts[lmt_name]['transformCTL'] = os.path.join(lmt_dir, transform_CTL)
-        if transform_CTL_inverse != None:
+        if transform_CTL_inverse is not None:
             lmts[lmt_name]['transformCTLInverse'] = os.path.join(
                 lmt_dir, transform_CTL_inverse)
 
             lmts[lmt_name]['transformCTLInverse'] = os.path.join(
                 lmt_dir, transform_CTL_inverse)
 
index fba4c80..af334b8 100644 (file)
@@ -60,7 +60,7 @@ def create_s_log(gamut,
         ab = 90.
         w = 940.
 
         ab = 90.
         w = 940.
 
-        if (s_log >= ab):
+        if s_log >= ab:
             linear = ((pow(10.,
                            (((s_log - b) /
                              (w - b) - 0.616596 - 0.03) / 0.432699)) -
             linear = ((pow(10.,
                            (((s_log - b) /
                              (w - b) - 0.616596 - 0.03) / 0.432699)) -
@@ -75,7 +75,7 @@ def create_s_log(gamut,
         ab = 90.
         w = 940.
 
         ab = 90.
         w = 940.
 
-        if (s_log >= ab):
+        if s_log >= ab:
             linear = ((219. * (pow(10.,
                                    (((s_log - b) /
                                      (w - b) - 0.616596 - 0.03) / 0.432699)) -
             linear = ((219. * (pow(10.,
                                    (((s_log - b) /
                                      (w - b) - 0.616596 - 0.03) / 0.432699)) -
index 3ff606d..1f23b06 100755 (executable)
@@ -206,10 +206,10 @@ def generate_3d_LUT_from_image(ramp_3d_path, output_path=None, resolution=32):
 
 def apply_CTL_to_image(input_image,
                        output_image,
 
 def apply_CTL_to_image(input_image,
                        output_image,
-                       ctl_paths=[],
+                       ctl_paths=None,
                        input_scale=1.0,
                        output_scale=1.0,
                        input_scale=1.0,
                        output_scale=1.0,
-                       global_params={},
+                       global_params=None,
                        aces_CTL_directory=None):
     """
     Object description.
                        aces_CTL_directory=None):
     """
     Object description.
@@ -225,6 +225,11 @@ def apply_CTL_to_image(input_image,
          Return value description.
     """
 
          Return value description.
     """
 
+    if ctl_paths is None:
+        ctl_paths = []
+    if global_params is None:
+        global_params = {}
+
     if len(ctl_paths) > 0:
         ctlenv = os.environ
         if aces_CTL_directory is not None:
     if len(ctl_paths) > 0:
         ctlenv = os.environ
         if aces_CTL_directory is not None:
@@ -285,7 +290,7 @@ def generate_1d_LUT_from_CTL(lut_path,
                              identity_LUT_bit_depth='half',
                              input_scale=1.0,
                              output_scale=1.0,
                              identity_LUT_bit_depth='half',
                              input_scale=1.0,
                              output_scale=1.0,
-                             global_params={},
+                             global_params=None,
                              cleanup=True,
                              aces_CTL_directory=None,
                              min_value=0.0,
                              cleanup=True,
                              aces_CTL_directory=None,
                              min_value=0.0,
@@ -304,6 +309,9 @@ def generate_1d_LUT_from_CTL(lut_path,
          Return value description.
     """
 
          Return value description.
     """
 
+    if global_params is None:
+        global_params = {}
+
     lut_path_base = os.path.splitext(lut_path)[0]
 
     identity_LUT_image_float = '%s.%s.%s' % (lut_path_base, 'float', 'tiff')
     lut_path_base = os.path.splitext(lut_path)[0]
 
     identity_LUT_image_float = '%s.%s.%s' % (lut_path_base, 'float', 'tiff')
@@ -420,7 +428,7 @@ def generate_3d_LUT_from_CTL(lut_path,
                              identity_LUT_bit_depth='half',
                              input_scale=1.0,
                              output_scale=1.0,
                              identity_LUT_bit_depth='half',
                              input_scale=1.0,
                              output_scale=1.0,
-                             global_params={},
+                             global_params=None,
                              cleanup=True,
                              aces_CTL_directory=None):
     """
                              cleanup=True,
                              aces_CTL_directory=None):
     """
@@ -437,6 +445,9 @@ def generate_3d_LUT_from_CTL(lut_path,
          Return value description.
     """
 
          Return value description.
     """
 
+    if global_params is None:
+        global_params = {}
+
     lut_path_base = os.path.splitext(lut_path)[0]
 
     identity_LUT_image_float = '%s.%s.%s' % (lut_path_base, 'float', 'tiff')
     lut_path_base = os.path.splitext(lut_path)[0]
 
     identity_LUT_image_float = '%s.%s.%s' % (lut_path_base, 'float', 'tiff')
index db23fc3..062855e 100755 (executable)
@@ -74,7 +74,7 @@ class Process:
     def __init__(self,\r
                  description=None,\r
                  cmd=None,\r
     def __init__(self,\r
                  description=None,\r
                  cmd=None,\r
-                 args=[],\r
+                 args=None,\r
                  cwd=None,\r
                  env=None,\r
                  batch_wrapper=False):\r
                  cwd=None,\r
                  env=None,\r
                  batch_wrapper=False):\r
@@ -92,6 +92,9 @@ class Process:
              Return value description.\r
         """\r
 \r
              Return value description.\r
         """\r
 \r
+        if args is None:\r
+            args = []\r
+\r
         self.cmd = cmd\r
         if not description:\r
             self.description = cmd\r
         self.cmd = cmd\r
         if not description:\r
             self.description = cmd\r
@@ -148,7 +151,7 @@ class Process:
              Return value description.\r
         """\r
 \r
              Return value description.\r
         """\r
 \r
-        if key != None and (value != None or start_stop != None):\r
+        if key is not None and (value is not None or start_stop is not None):\r
             indent = '\t' * write_dict['indentationLevel']\r
             if write_dict['format'] == 'xml':\r
                 if start_stop == 'start':\r
             indent = '\t' * write_dict['indentationLevel']\r
             if write_dict['format'] == 'xml':\r
                 if start_stop == 'start':\r
@@ -413,7 +416,7 @@ class Process:
 \r
         # Using *subprocess*\r
         if sp:\r
 \r
         # Using *subprocess*\r
         if sp:\r
-            if process != None:\r
+            if process is not None:\r
                 # pid = process.pid\r
                 # log.logLine('process id %s\n' % pid)\r
 \r
                 # pid = process.pid\r
                 # log.logLine('process id %s\n' % pid)\r
 \r
@@ -431,14 +434,16 @@ class Process:
 \r
                     # This is now used to ensure that the process has finished.\r
                     line = ''\r
 \r
                     # This is now used to ensure that the process has finished.\r
                     line = ''\r
-                    while line != None and process.poll() is None:\r
+                    while line is not None and process.poll() is None:\r
                         try:\r
                             line = process.stdout.readline()\r
                         except:\r
                             break\r
                         # 3.1\r
                         try:\r
                         try:\r
                             line = process.stdout.readline()\r
                         except:\r
                             break\r
                         # 3.1\r
                         try:\r
-                            self.log_line(str(line, encoding='utf-8'))\r
+                            # TODO: Investigate previous eroneous statement.\r
+                            # self.log_line(str(line, encoding='utf-8'))\r
+                            self.log_line(str(line))\r
                         # 2.6\r
                         except:\r
                             self.log_line(line)\r
                         # 2.6\r
                         except:\r
                             self.log_line(line)\r
@@ -460,6 +465,8 @@ class Process:
             exit_code = -1\r
             try:\r
                 stdout_lines = stdout.readlines()\r
             exit_code = -1\r
             try:\r
                 stdout_lines = stdout.readlines()\r
+                # TODO: Investigate if this is the good behavior, close() does\r
+                # not return anything / None.\r
                 exit_code = stdout.close()\r
 \r
                 stdout.close()\r
                 exit_code = stdout.close()\r
 \r
                 stdout.close()\r
index 8814e90..229c880 100644 (file)
@@ -99,11 +99,12 @@ class TestACESConfig(unittest.TestCase):
         hashes = {}
         for path in files_walker(directory,
                                  filters_in=filters_in,
         hashes = {}
         for path in files_walker(directory,
                                  filters_in=filters_in,
-                                 filters_out=filters_out):
+                                 filters_out=filters_out,
+                                 flags=flags):
             with open(path) as file:
             with open(path) as file:
-                hash = hashlib.md5(
+                digest = hashlib.md5(
                     re.sub('\s', '', file.read())).hexdigest()
                     re.sub('\s', '', file.read())).hexdigest()
-            hashes[path.replace(directory, '')] = hash
+            hashes[path.replace(directory, '')] = digest
         return hashes
 
     def test_ACES_config(self):
         return hashes
 
     def test_ACES_config(self):