Add "create_aces_config" and "tests_aces_config" binaries.
[OpenColorIO-Configs.git] / aces_1.0.0 / python / aces_ocio / generate_lut.py
old mode 100644 (file)
new mode 100755 (executable)
index e8e78d8..bd2640a
@@ -99,19 +99,18 @@ def write_SPI_1d(filename, from_min, from_max, data, entries, channels):
          Return value description.
     """
 
-    f = file(filename, 'w')
-    f.write('Version 1\n')
-    f.write('From %f %f\n' % (from_min, from_max))
-    f.write('Length %d\n' % entries)
-    f.write('Components %d\n' % (min(3, channels)))
-    f.write('{\n')
-    for i in range(0, entries):
-        entry = ''
-        for j in range(0, min(3, channels)):
-            entry = '%s %s' % (entry, data[i * channels + j])
-        f.write('        %s\n' % entry)
-    f.write('}\n')
-    f.close()
+    with open(filename, 'w') as fp:
+        fp.write('Version 1\n')
+        fp.write('From %f %f\n' % (from_min, from_max))
+        fp.write('Length %d\n' % entries)
+        fp.write('Components %d\n' % (min(3, channels)))
+        fp.write('{\n')
+        for i in range(0, entries):
+            entry = ''
+            for j in range(0, min(3, channels)):
+                entry = '%s %s' % (entry, data[i * channels + j])
+            fp.write('        %s\n' % entry)
+        fp.write('}\n')
 
 
 def generate_1d_LUT_from_image(ramp_1d_path,
@@ -240,7 +239,7 @@ def apply_CTL_to_image(input_image,
         ctlenv = os.environ
         if aces_CTL_directory != None:
             if os.path.split(aces_CTL_directory)[1] != 'utilities':
-                ctl_module_path = '%s/utilities' % aces_CTL_directory
+                ctl_module_path = os.path.join(aces_CTL_directory, 'utilities')
             else:
                 ctl_module_path = aces_CTL_directory
             ctlenv['CTL_MODULE_PATH'] = ctl_module_path
@@ -535,8 +534,8 @@ def main():
 
     p.add_option('--lut', '-l', type='string', default='')
     p.add_option('--ctl', '-c', type='string', action='append')
-    p.add_option('--lut_resolution_1d', '', type='int', default=1024)
-    p.add_option('--lut_resolution_3d', '', type='int', default=33)
+    p.add_option('--lutResolution1d', '', type='int', default=1024)
+    p.add_option('--lutResolution3d', '', type='int', default=33)
     p.add_option('--ctlReleasePath', '-r', type='string', default='')
     p.add_option('--bitDepth', '-b', type='string', default='float')
     p.add_option('--keepTempImages', '', action='store_true')
@@ -566,7 +565,7 @@ def main():
     ctl_release_path = options.ctlReleasePath
     generate_1d = options.generate1d is True
     generate_3d = options.generate3d is True
-    bitdepth = options.bitDepth
+    bit_depth = options.bitDepth
     cleanup = not options.keepTempImages
 
     params = {}
@@ -601,14 +600,14 @@ def main():
     print('output scale        : %s' % output_scale)
     print('ctl render params   : %s' % params)
     print('ctl release path    : %s' % ctl_release_path)
-    print('bit depth of input  : %s' % bitdepth)
+    print('bit depth of input  : %s' % bit_depth)
     print('cleanup temp images : %s' % cleanup)
 
     if generate_1d:
         generate_1d_LUT_from_CTL(lut,
                                  ctls,
                                  lut_resolution_1d,
-                                 bitdepth,
+                                 bit_depth,
                                  input_scale,
                                  output_scale,
                                  params,
@@ -621,7 +620,7 @@ def main():
         generate_3d_LUT_from_CTL(lut,
                                  ctls,
                                  lut_resolution_3d,
-                                 bitdepth,
+                                 bit_depth,
                                  input_scale,
                                  output_scale,
                                  params,