Apply first pass package wide code formatting.
authorThomas Mansencal <thomas.mansencal@gmail.com>
Thu, 15 Jan 2015 17:52:17 +0000 (18:52 +0100)
committerThomas Mansencal <thomas.mansencal@gmail.com>
Thu, 15 Jan 2015 17:52:17 +0000 (18:52 +0100)
aces_1.0.0/python/aces_ocio/createARRIColorSpaces.py
aces_1.0.0/python/aces_ocio/createCanonColorSpaces.py
aces_1.0.0/python/aces_ocio/createREDColorSpaces.py
aces_1.0.0/python/aces_ocio/createSonyColorSpaces.py
aces_1.0.0/python/aces_ocio/create_aces_config.py
aces_1.0.0/python/aces_ocio/generateLUT.py
aces_1.0.0/python/aces_ocio/process.py
aces_1.0.0/python/aces_ocio/util.py

index 0c15318..3f5591c 100644 (file)
@@ -11,7 +11,12 @@ from aces_ocio.util import ColorSpace, mat44FromMat33
 #
 # LogC to ACES
 #
-def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResolution1d):
+def createLogC(gamut,
+               transferFunction,
+               exposureIndex,
+               name,
+               lutDir,
+               lutResolution1d):
     name = "%s (EI%s) - %s" % (transferFunction, exposureIndex, gamut)
     if transferFunction == "":
         name = "Linear - %s" % gamut
@@ -22,7 +27,7 @@ def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResoluti
     cs.description = name
     cs.equalityGroup = ''
     cs.family = 'ARRI'
-    cs.isData=False
+    cs.isData = False
 
     # Globals
     IDT_maker_version = "0.08"
@@ -33,10 +38,11 @@ def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResoluti
     encodingGain = 0.256598
     encodingOffset = 0.391007
 
-    def gainForEI(EI) :
-        return (math.log(EI/nominalEI)/math.log(2) * (0.89 - 1) / 3 + 1) * encodingGain
+    def gainForEI(EI):
+        return (math.log(EI / nominalEI) / math.log(2) * (
+            0.89 - 1) / 3 + 1) * encodingGain
 
-    def LogCInverseParametersForEI(EI) :
+    def LogCInverseParametersForEI(EI):
         cut = 1.0 / 9.0
         slope = 1.0 / (cut * math.log(10))
         offset = math.log10(cut) - slope * cut
@@ -45,7 +51,7 @@ def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResoluti
         # The higher the EI, the lower the gamma
         encGain = gainForEI(EI)
         encOffset = encodingOffset
-        for i in range(0,3) :
+        for i in range(0, 3):
             nz = ((95.0 / 1023.0 - encOffset) / encGain - offset) / slope
             encOffset = encodingOffset - math.log10(1 + nz) * encGain
         # Calculate some intermediate values
@@ -60,23 +66,24 @@ def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResoluti
         a = a * s
         f = f + e * t
         e = e * s
-        return { 'a' : a,
-                 'b' : b,
-                 'cut' : (cut - b) / a,
-                 'c' : encGain,
-                 'd' : encOffset,
-                 'e' : e,
-                 'f' : f }
+        return {'a': a,
+                'b': b,
+                'cut': (cut - b) / a,
+                'c': encGain,
+                'd': encOffset,
+                'e': e,
+                'f': f}
 
     def logCtoLinear(codeValue, exposureIndex):
         p = LogCInverseParametersForEI(exposureIndex)
         breakpoint = p['e'] * p['cut'] + p['f']
         if (codeValue > breakpoint):
-            linear = (pow(10,(codeValue/1023.0 - p['d']) / p['c']) - p['b']) / p['a']
+            linear = ((pow(10, (codeValue / 1023.0 - p['d']) / p['c']) -
+                       p['b']) / p['a'])
         else:
-            linear = (codeValue/1023.0 - p['f']) / p['e']
+            linear = (codeValue / 1023.0 - p['f']) / p['e']
 
-        #print( codeValue, linear )
+        # print(codeValue, linear)
         return linear
 
 
@@ -85,56 +92,69 @@ def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResoluti
     if transferFunction == "V3 LogC":
         data = array.array('f', "\0" * lutResolution1d * 4)
         for c in range(lutResolution1d):
-            data[c] = logCtoLinear(1023.0*c/(lutResolution1d-1), int(exposureIndex))
+            data[c] = logCtoLinear(1023.0 * c / (lutResolution1d - 1),
+                                   int(exposureIndex))
 
-        lut = "%s_to_linear.spi1d" % ("%s_%s" % (transferFunction, exposureIndex))
+        lut = "%s_to_linear.spi1d" % (
+            "%s_%s" % (transferFunction, exposureIndex))
 
         # Remove spaces and parentheses
         lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
 
-        genlut.writeSPI1D(lutDir + "/" + lut, 0.0, 1.0, data, lutResolution1d, 1)
-
-        #print( "Writing %s" % lut)
-        cs.toReferenceTransforms.append( {
-            'type':'lutFile', 
-            'path':lut, 
-            'interpolation':'linear', 
-            'direction':'forward'
-        } )
+        genlut.writeSPI1D(lutDir + "/" + lut,
+                          0.0,
+                          1.0,
+                          data,
+                          lutResolution1d,
+                          1)
+
+        # print("Writing %s" % lut)
+        cs.toReferenceTransforms.append({
+            'type': 'lutFile',
+            'path': lut,
+            'interpolation': 'linear',
+            'direction': 'forward'
+        })
 
     if gamut == 'Wide Gamut':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':mat44FromMat33([0.680206, 0.236137, 0.083658, 
-                        0.085415, 1.017471, -0.102886, 
-                        0.002057, -0.062563, 1.060506]),
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': mat44FromMat33([0.680206, 0.236137, 0.083658,
+                                      0.085415, 1.017471, -0.102886,
+                                      0.002057, -0.062563, 1.060506]),
+            'direction': 'forward'
         })
 
     cs.fromReferenceTransforms = []
     return cs
 
+
 def createColorSpaces(lutDir, lutResolution1d):
     colorspaces = []
 
     transferFunction = "V3 LogC"
     gamut = "Wide Gamut"
-    #EIs = [160.0, 200.0, 250.0, 320.0, 400.0, 500.0, 640.0, 800.0, 1000.0, 1280.0, 1600.0, 2000.0, 2560.0, 3200.0]
-    EIs = [160, 200, 250, 320, 400, 500, 640, 800, 1000, 1280, 1600, 2000, 2560, 3200]
+    # EIs = [160.0, 200.0, 250.0, 320.0, 400.0, 500.0, 640.0, 800.0,
+    # 1000.0, 1280.0, 1600.0, 2000.0, 2560.0, 3200.0]
+    EIs = [160, 200, 250, 320, 400, 500, 640, 800,
+           1000, 1280, 1600, 2000, 2560, 3200]
     defaultEI = 800
 
     # Full conversion
     for EI in EIs:
-        LogCEIfull = createLogC(gamut, transferFunction, EI, "LogC", lutDir, lutResolution1d)
+        LogCEIfull = createLogC(
+            gamut, transferFunction, EI, "LogC", lutDir, lutResolution1d)
         colorspaces.append(LogCEIfull)
 
     # Linearization only
     for EI in [800]:
-        LogCEIlinearization = createLogC("", transferFunction, EI, "LogC", lutDir, lutResolution1d)
+        LogCEIlinearization = createLogC(
+            "", transferFunction, EI, "LogC", lutDir, lutResolution1d)
         colorspaces.append(LogCEIlinearization)
 
     # Primaries
-    LogCEIprimaries = createLogC(gamut, "", defaultEI, "LogC", lutDir, lutResolution1d)
+    LogCEIprimaries = createLogC(
+        gamut, "", defaultEI, "LogC", lutDir, lutResolution1d)
     colorspaces.append(LogCEIprimaries)
 
     return colorspaces
index d782295..6a1bf3a 100644 (file)
@@ -4,7 +4,7 @@
 import array
 
 import aces_ocio.generateLUT as genlut
-from aces_ocio.util import ColorSpace, mat44FromMat33
+from aces_ocio.util import ColorSpace
 
 #
 # Canon-Log to ACES
@@ -20,10 +20,10 @@ def createCanonLog(gamut, transferFunction, name, lutDir, lutResolution1d):
     cs.description = name
     cs.equalityGroup = ''
     cs.family = 'Canon'
-    cs.isData=False
+    cs.isData = False
 
     def legalToFull(codeValue):
-        return (codeValue - 64.0)/(940.0 - 64.0)
+        return (codeValue - 64.0) / (940.0 - 64.0)
 
     def canonLogToLinear(codeValue):
         # log = fullToLegal(c1 * log10(c2*linear + 1) + c3)
@@ -32,9 +32,9 @@ def createCanonLog(gamut, transferFunction, name, lutDir, lutResolution1d):
         c2 = 10.1596
         c3 = 0.0730597
 
-        linear = (pow(10.0, (legalToFull(codeValue) - c3)/c1) -1.0)/c2
+        linear = (pow(10.0, (legalToFull(codeValue) - c3) / c1) - 1.0) / c2
         linear = 0.9 * linear
-        #print( codeValue, linear )
+        # print(codeValue, linear)
         return linear
 
     cs.toReferenceTransforms = []
@@ -42,120 +42,141 @@ def createCanonLog(gamut, transferFunction, name, lutDir, lutResolution1d):
     if transferFunction == "Canon-Log":
         data = array.array('f', "\0" * lutResolution1d * 4)
         for c in range(lutResolution1d):
-            data[c] = canonLogToLinear(1023.0*c/(lutResolution1d-1))
+            data[c] = canonLogToLinear(1023.0 * c / (lutResolution1d - 1))
 
         lut = "%s_to_linear.spi1d" % transferFunction
-        genlut.writeSPI1D(lutDir + "/" + lut, 0.0, 1.0, data, lutResolution1d, 1)
-
-        cs.toReferenceTransforms.append( {
-            'type':'lutFile', 
-            'path':lut, 
-            'interpolation':'linear', 
-            'direction':'forward'
-        } )
+        genlut.writeSPI1D(lutDir + "/" + lut,
+                          0.0,
+                          1.0,
+                          data,
+                          lutResolution1d,
+                          1)
+
+        cs.toReferenceTransforms.append({
+            'type': 'lutFile',
+            'path': lut,
+            'interpolation': 'linear',
+            'direction': 'forward'
+        })
 
     if gamut == 'Rec. 709 Daylight':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':[0.561538969, 0.402060105, 0.036400926, 0.0, 
-                        0.092739623, 0.924121198, -0.016860821, 0.0, 
-                        0.084812961, 0.006373835, 0.908813204, 0.0, 
-                        0,0,0,1.0],
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': [0.561538969, 0.402060105, 0.036400926, 0.0,
+                       0.092739623, 0.924121198, -0.016860821, 0.0,
+                       0.084812961, 0.006373835, 0.908813204, 0.0,
+                       0, 0, 0, 1.0],
+            'direction': 'forward'
         })
     elif gamut == 'Rec. 709 Tungsten':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':[0.566996399, 0.365079418, 0.067924183, 0.0, 
-                        0.070901044, 0.880331008, 0.048767948, 0.0, 
-                        0.073013542, -0.066540862, 0.99352732, 0.0, 
-                        0,0,0,1.0],
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': [0.566996399, 0.365079418, 0.067924183, 0.0,
+                       0.070901044, 0.880331008, 0.048767948, 0.0,
+                       0.073013542, -0.066540862, 0.99352732, 0.0,
+                       0, 0, 0, 1.0],
+            'direction': 'forward'
         })
     elif gamut == 'DCI-P3 Daylight':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':[0.607160575, 0.299507286, 0.093332140, 0.0, 
-                        0.004968120, 1.050982224, -0.055950343, 0.0, 
-                        -0.007839939, 0.000809127, 1.007030813, 0.0, 
-                        0,0,0,1.0],
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': [0.607160575, 0.299507286, 0.093332140, 0.0,
+                       0.004968120, 1.050982224, -0.055950343, 0.0,
+                       -0.007839939, 0.000809127, 1.007030813, 0.0,
+                       0, 0, 0, 1.0],
+            'direction': 'forward'
         })
     elif gamut == 'DCI-P3 Tungsten':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':[0.650279125, 0.253880169, 0.095840706, 0.0, 
-                        -0.026137986, 1.017900530, 0.008237456, 0.0, 
-                        0.007757558, -0.063081669, 1.055324110, 0.0, 
-                        0,0,0,1.0],
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': [0.650279125, 0.253880169, 0.095840706, 0.0,
+                       -0.026137986, 1.017900530, 0.008237456, 0.0,
+                       0.007757558, -0.063081669, 1.055324110, 0.0,
+                       0, 0, 0, 1.0],
+            'direction': 'forward'
         })
     elif gamut == 'Cinema Gamut Daylight':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':[0.763064455, 0.149021161, 0.087914384, 0.0, 
-                        0.003657457, 1.10696038, -0.110617837, 0.0, 
-                        -0.009407794,-0.218383305, 1.227791099, 0.0, 
-                        0,0,0,1.0],
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': [0.763064455, 0.149021161, 0.087914384, 0.0,
+                       0.003657457, 1.10696038, -0.110617837, 0.0,
+                       -0.009407794, -0.218383305, 1.227791099, 0.0,
+                       0, 0, 0, 1.0],
+            'direction': 'forward'
         })
     elif gamut == 'Cinema Gamut Tungsten':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':[0.817416293, 0.090755698, 0.091828009, 0.0, 
-                        -0.035361374, 1.065690585, -0.030329211, 0.0, 
-                        0.010390366, -0.299271107, 1.288880741, 0.0, 
-                        0,0,0,1.0],
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': [0.817416293, 0.090755698, 0.091828009, 0.0,
+                       -0.035361374, 1.065690585, -0.030329211, 0.0,
+                       0.010390366, -0.299271107, 1.288880741, 0.0,
+                       0, 0, 0, 1.0],
+            'direction': 'forward'
         })
 
     cs.fromReferenceTransforms = []
     return cs
 
+
 # Generate all color spaces conversion
 def createColorSpaces(lutDir, lutResolution1d):
     colorspaces = []
 
     # Full conversion
-    CanonLog1 = createCanonLog("Rec. 709 Daylight", "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog1 = createCanonLog(
+        "Rec. 709 Daylight", "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
     colorspaces.append(CanonLog1)
 
-    CanonLog2 = createCanonLog("Rec. 709 Tungsten", "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog2 = createCanonLog(
+        "Rec. 709 Tungsten", "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
     colorspaces.append(CanonLog2)
 
-    CanonLog3 = createCanonLog("DCI-P3 Daylight", "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog3 = createCanonLog(
+        "DCI-P3 Daylight", "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
     colorspaces.append(CanonLog3)
 
-    CanonLog4 = createCanonLog("DCI-P3 Tungsten", "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog4 = createCanonLog(
+        "DCI-P3 Tungsten", "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
     colorspaces.append(CanonLog4)
 
-    CanonLog5 = createCanonLog("Cinema Gamut Daylight", "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog5 = createCanonLog(
+        "Cinema Gamut Daylight", "Canon-Log", "Canon-Log",
+        lutDir, lutResolution1d)
     colorspaces.append(CanonLog5)
 
-    CanonLog6 = createCanonLog("Cinema Gamut Tungsten", "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog6 = createCanonLog(
+        "Cinema Gamut Tungsten", "Canon-Log", "Canon-Log",
+        lutDir, lutResolution1d)
     colorspaces.append(CanonLog6)
 
     # Linearization only
-    CanonLog7 = createCanonLog('', "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog7 = createCanonLog(
+        '', "Canon-Log", "Canon-Log", lutDir, lutResolution1d)
     colorspaces.append(CanonLog7)
 
     # Primaries only
-    CanonLog8 = createCanonLog("Rec. 709 Daylight", "", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog8 = createCanonLog(
+        "Rec. 709 Daylight", "", "Canon-Log", lutDir, lutResolution1d)
     colorspaces.append(CanonLog8)
 
-    CanonLog9 = createCanonLog("Rec. 709 Tungsten", "", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog9 = createCanonLog(
+        "Rec. 709 Tungsten", "", "Canon-Log", lutDir, lutResolution1d)
     colorspaces.append(CanonLog9)
 
-    CanonLog10 = createCanonLog("DCI-P3 Daylight", "", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog10 = createCanonLog(
+        "DCI-P3 Daylight", "", "Canon-Log", lutDir, lutResolution1d)
     colorspaces.append(CanonLog10)
 
-    CanonLog11 = createCanonLog("DCI-P3 Tungsten", "", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog11 = createCanonLog("DCI-P3 Tungsten", "", "Canon-Log", lutDir,
+                                lutResolution1d)
     colorspaces.append(CanonLog11)
 
-    CanonLog12 = createCanonLog("Cinema Gamut Daylight", "", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog12 = createCanonLog(
+        "Cinema Gamut Daylight", "", "Canon-Log", lutDir, lutResolution1d)
     colorspaces.append(CanonLog12)
 
-    CanonLog13 = createCanonLog("Cinema Gamut Tungsten", "", "Canon-Log", lutDir, lutResolution1d)
+    CanonLog13 = createCanonLog(
+        "Cinema Gamut Tungsten", "", "Canon-Log", lutDir, lutResolution1d)
     colorspaces.append(CanonLog13)
 
     return colorspaces
index 934fec5..097a5c0 100644 (file)
@@ -20,7 +20,7 @@ def createREDlogFilm(gamut, transferFunction, name, lutDir, lutResolution1d):
     cs.description = name
     cs.equalityGroup = ''
     cs.family = 'RED'
-    cs.isData=False
+    cs.isData = False
 
     def cineonToLinear(codeValue):
         nGamma = 0.6
@@ -28,110 +28,129 @@ def createREDlogFilm(gamut, transferFunction, name, lutDir, lutResolution1d):
         whitePoint = 685.0
         codeValueToDensity = 0.002
 
-        blackLinear = pow(10.0, (blackPoint - whitePoint) * (codeValueToDensity / nGamma))
-        codeLinear = pow(10.0, (codeValue - whitePoint) * (codeValueToDensity / nGamma))
+        blackLinear = pow(10.0, (blackPoint - whitePoint) * (
+            codeValueToDensity / nGamma))
+        codeLinear = pow(10.0, (codeValue - whitePoint) * (
+            codeValueToDensity / nGamma))
 
-        return (codeLinear - blackLinear)/(1.0 - blackLinear)
+        return (codeLinear - blackLinear) / (1.0 - blackLinear)
 
     cs.toReferenceTransforms = []
 
     if transferFunction == 'REDlogFilm':
         data = array.array('f', "\0" * lutResolution1d * 4)
         for c in range(lutResolution1d):
-            data[c] = cineonToLinear(1023.0*c/(lutResolution1d-1))
+            data[c] = cineonToLinear(1023.0 * c / (lutResolution1d - 1))
 
         lut = "CineonLog_to_linear.spi1d"
-        genlut.writeSPI1D(lutDir + "/" + lut, 0.0, 1.0, data, lutResolution1d, 1)
-
-        cs.toReferenceTransforms.append( {
-            'type':'lutFile', 
-            'path':lut, 
-            'interpolation':'linear', 
-            'direction':'forward'
-        } )
+        genlut.writeSPI1D(lutDir + "/" + lut,
+                          0.0,
+                          1.0,
+                          data,
+                          lutResolution1d,
+                          1)
+
+        cs.toReferenceTransforms.append({
+            'type': 'lutFile',
+            'path': lut,
+            'interpolation': 'linear',
+            'direction': 'forward'
+        })
 
     if gamut == 'DRAGONcolor':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':mat44FromMat33([0.532279,  0.376648,  0.091073, 
-                                     0.046344,  0.974513, -0.020860, 
-                                    -0.053976, -0.000320, 1.054267]),
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': mat44FromMat33([0.532279, 0.376648, 0.091073,
+                                      0.046344, 0.974513, -0.020860,
+                                      -0.053976, -0.000320, 1.054267]),
+            'direction': 'forward'
         })
     elif gamut == 'DRAGONcolor2':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':mat44FromMat33([0.468452,  0.331484,  0.200064, 
-                                     0.040787,  0.857658,  0.101553, 
-                                    -0.047504, -0.000282, 1.047756]),
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': mat44FromMat33([0.468452, 0.331484, 0.200064,
+                                      0.040787, 0.857658, 0.101553,
+                                      -0.047504, -0.000282, 1.047756]),
+            'direction': 'forward'
         })
     elif gamut == 'REDcolor2':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':mat44FromMat33([0.480997, 0.402289, 0.116714, 
-                                    -0.004938, 1.000154, 0.004781, 
-                                    -0.105257, 0.025320, 1.079907]),
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': mat44FromMat33([0.480997, 0.402289, 0.116714,
+                                      -0.004938, 1.000154, 0.004781,
+                                      -0.105257, 0.025320, 1.079907]),
+            'direction': 'forward'
         })
     elif gamut == 'REDcolor3':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':mat44FromMat33([0.512136, 0.360370, 0.127494, 
-                                     0.070377, 0.903884, 0.025737, 
-                                    -0.020824, 0.017671, 1.003123]),
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': mat44FromMat33([0.512136, 0.360370, 0.127494,
+                                      0.070377, 0.903884, 0.025737,
+                                      -0.020824, 0.017671, 1.003123]),
+            'direction': 'forward'
         })
     elif gamut == 'REDcolor4':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':mat44FromMat33([0.474202, 0.333677, 0.192121, 
-                                     0.065164, 0.836932, 0.097901, 
-                                    -0.019281, 0.016362, 1.002889]),
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': mat44FromMat33([0.474202, 0.333677, 0.192121,
+                                      0.065164, 0.836932, 0.097901,
+                                      -0.019281, 0.016362, 1.002889]),
+            'direction': 'forward'
         })
 
     cs.fromReferenceTransforms = []
     return cs
 
+
 # Generate all color spaces conversion
 def createColorSpaces(lutDir, lutResolution1d):
     colorspaces = []
 
     # Full conversion
-    REDlogFilmDRAGON = createREDlogFilm("DRAGONcolor", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
+    REDlogFilmDRAGON = createREDlogFilm(
+        "DRAGONcolor", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
     colorspaces.append(REDlogFilmDRAGON)
 
-    REDlogFilmDRAGON2 = createREDlogFilm("DRAGONcolor2", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
+    REDlogFilmDRAGON2 = createREDlogFilm(
+        "DRAGONcolor2", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
     colorspaces.append(REDlogFilmDRAGON2)
 
-    REDlogFilmREDcolor2 = createREDlogFilm("REDcolor2", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
+    REDlogFilmREDcolor2 = createREDlogFilm(
+        "REDcolor2", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
     colorspaces.append(REDlogFilmREDcolor2)
 
-    REDlogFilmREDcolor3 = createREDlogFilm("REDcolor3", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
+    REDlogFilmREDcolor3 = createREDlogFilm(
+        "REDcolor3", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
     colorspaces.append(REDlogFilmREDcolor3)
 
-    REDlogFilmREDcolor4 = createREDlogFilm("REDcolor4", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
+    REDlogFilmREDcolor4 = createREDlogFilm(
+        "REDcolor4", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
     colorspaces.append(REDlogFilmREDcolor4)
 
     # Linearization only
-    REDlogFilmDRAGON = createREDlogFilm("", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
+    REDlogFilmDRAGON = createREDlogFilm(
+        "", "REDlogFilm", "REDlogFilm", lutDir, lutResolution1d)
     colorspaces.append(REDlogFilmDRAGON)
 
     # Primaries only
-    REDlogFilmDRAGON = createREDlogFilm("DRAGONcolor", "", "REDlogFilm", lutDir, lutResolution1d)
+    REDlogFilmDRAGON = createREDlogFilm(
+        "DRAGONcolor", "", "REDlogFilm", lutDir, lutResolution1d)
     colorspaces.append(REDlogFilmDRAGON)
 
-    REDlogFilmDRAGON2 = createREDlogFilm("DRAGONcolor2", "", "REDlogFilm", lutDir, lutResolution1d)
+    REDlogFilmDRAGON2 = createREDlogFilm(
+        "DRAGONcolor2", "", "REDlogFilm", lutDir, lutResolution1d)
     colorspaces.append(REDlogFilmDRAGON2)
 
-    REDlogFilmREDcolor2 = createREDlogFilm("REDcolor2", "", "REDlogFilm", lutDir, lutResolution1d)
+    REDlogFilmREDcolor2 = createREDlogFilm(
+        "REDcolor2", "", "REDlogFilm", lutDir, lutResolution1d)
     colorspaces.append(REDlogFilmREDcolor2)
 
-    REDlogFilmREDcolor3 = createREDlogFilm("REDcolor3", "", "REDlogFilm", lutDir, lutResolution1d)
+    REDlogFilmREDcolor3 = createREDlogFilm(
+        "REDcolor3", "", "REDlogFilm", lutDir, lutResolution1d)
     colorspaces.append(REDlogFilmREDcolor3)
 
-    REDlogFilmREDcolor4 = createREDlogFilm("REDcolor4", "", "REDlogFilm", lutDir, lutResolution1d)
+    REDlogFilmREDcolor4 = createREDlogFilm(
+        "REDcolor4", "", "REDlogFilm", lutDir, lutResolution1d)
     colorspaces.append(REDlogFilmREDcolor4)
 
     return colorspaces
index c1e1bb3..2352e58 100644 (file)
@@ -20,7 +20,7 @@ def createSlog(gamut, transferFunction, name, lutDir, lutResolution1d):
     cs.description = name
     cs.equalityGroup = ''
     cs.family = 'Sony'
-    cs.isData=False
+    cs.isData = False
 
     def sLog1ToLinear(SLog):
         b = 64.
@@ -28,9 +28,13 @@ def createSlog(gamut, transferFunction, name, lutDir, lutResolution1d):
         w = 940.
 
         if (SLog >= ab):
-            lin = ( pow(10., ( ( ( SLog - b) / ( w - b) - 0.616596 - 0.03) / 0.432699)) - 0.037584) * 0.9
+            lin = ((pow(10.,
+                        ((((SLog - b) /
+                           (w - b) - 0.616596 - 0.03) / 0.432699)) -
+                        0.037584) * 0.9))
         else:
-            lin = ( ( ( SLog - b) / ( w - b) - 0.030001222851889303) / 5.) * 0.9 
+            lin = (
+                      ((SLog - b) / (w - b) - 0.030001222851889303) / 5.) * 0.9
         return lin
 
     def sLog2ToLinear(SLog):
@@ -39,17 +43,22 @@ def createSlog(gamut, transferFunction, name, lutDir, lutResolution1d):
         w = 940.
 
         if (SLog >= ab):
-            lin = ( 219. * ( pow(10., ( ( ( SLog - b) / ( w - b) - 0.616596 - 0.03) / 0.432699)) - 0.037584) / 155.) * 0.9
+            lin = (219. * (pow(10.,
+                               ((((SLog - b) /
+                                  (w - b) - 0.616596 - 0.03) / 0.432699)) -
+                               0.037584) / 155.) * 0.9)
         else:
-            lin = ( ( ( SLog - b) / ( w - b) - 0.030001222851889303) / 3.53881278538813) * 0.9
+            lin = (((SLog - b) / (
+                w - b) - 0.030001222851889303) / 3.53881278538813) * 0.9
         return lin
 
     def sLog3ToLinear(codeValue):
         if codeValue >= (171.2102946929):
-            linear = pow(10.0, ((codeValue - 420.0) / 261.5)) * (0.18 + 0.01) - 0.01
+            linear = (pow(10.0, ((codeValue - 420.0) / 261.5)) *
+                      (0.18 + 0.01) - 0.01)
         else:
-            linear = (codeValue - 95.0)*0.01125000/(171.2102946929 - 95.0)
-        #print( codeValue, linear )
+            linear = (codeValue - 95.0) * 0.01125000 / (171.2102946929 - 95.0)
+        # print(codeValue, linear)
         return linear
 
     cs.toReferenceTransforms = []
@@ -57,118 +66,147 @@ def createSlog(gamut, transferFunction, name, lutDir, lutResolution1d):
     if transferFunction == "S-Log1":
         data = array.array('f', "\0" * lutResolution1d * 4)
         for c in range(lutResolution1d):
-            data[c] = sLog1ToLinear(1023.0*c/(lutResolution1d-1))
+            data[c] = sLog1ToLinear(1023.0 * c / (lutResolution1d - 1))
 
         lut = "%s_to_linear.spi1d" % transferFunction
-        genlut.writeSPI1D(lutDir + "/" + lut, 0.0, 1.0, data, lutResolution1d, 1)
-
-        #print( "Writing %s" % lut)
-
-        cs.toReferenceTransforms.append( {
-            'type':'lutFile', 
-            'path':lut, 
-            'interpolation':'linear', 
-            'direction':'forward'
-        } )
+        genlut.writeSPI1D(
+            lutDir + "/" + lut,
+            0.0,
+            1.0,
+            data,
+            lutResolution1d,
+            1)
+
+        # print("Writing %s" % lut)
+
+        cs.toReferenceTransforms.append({
+            'type': 'lutFile',
+            'path': lut,
+            'interpolation': 'linear',
+            'direction': 'forward'
+        })
     elif transferFunction == "S-Log2":
         data = array.array('f', "\0" * lutResolution1d * 4)
         for c in range(lutResolution1d):
-            data[c] = sLog2ToLinear(1023.0*c/(lutResolution1d-1))
+            data[c] = sLog2ToLinear(1023.0 * c / (lutResolution1d - 1))
 
         lut = "%s_to_linear.spi1d" % transferFunction
-        genlut.writeSPI1D(lutDir + "/" + lut, 0.0, 1.0, data, lutResolution1d, 1)
-
-        #print( "Writing %s" % lut)
-
-        cs.toReferenceTransforms.append( {
-            'type':'lutFile', 
-            'path':lut, 
-            'interpolation':'linear', 
-            'direction':'forward'
-        } )
+        genlut.writeSPI1D(
+            lutDir + "/" + lut,
+            0.0,
+            1.0,
+            data,
+            lutResolution1d,
+            1)
+
+        # print("Writing %s" % lut)
+
+        cs.toReferenceTransforms.append({
+            'type': 'lutFile',
+            'path': lut,
+            'interpolation': 'linear',
+            'direction': 'forward'
+        })
     elif transferFunction == "S-Log3":
         data = array.array('f', "\0" * lutResolution1d * 4)
         for c in range(lutResolution1d):
-            data[c] = sLog3ToLinear(1023.0*c/(lutResolution1d-1))
+            data[c] = sLog3ToLinear(1023.0 * c / (lutResolution1d - 1))
 
         lut = "%s_to_linear.spi1d" % transferFunction
-        genlut.writeSPI1D(lutDir + "/" + lut, 0.0, 1.0, data, lutResolution1d, 1)
-
-        #print( "Writing %s" % lut)
-
-        cs.toReferenceTransforms.append( {
-            'type':'lutFile', 
-            'path':lut, 
-            'interpolation':'linear', 
-            'direction':'forward'
-        } )
+        genlut.writeSPI1D(
+            lutDir + "/" + lut,
+            0.0,
+            1.0,
+            data,
+            lutResolution1d,
+            1)
+
+        # print("Writing %s" % lut)
+
+        cs.toReferenceTransforms.append({
+            'type': 'lutFile',
+            'path': lut,
+            'interpolation': 'linear',
+            'direction': 'forward'
+        })
 
     if gamut == 'S-Gamut':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':mat44FromMat33([0.754338638, 0.133697046, 0.111968437,
-                                    0.021198141, 1.005410934, -0.026610548, 
-                                    -0.009756991, 0.004508563, 1.005253201]),
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': mat44FromMat33([0.754338638, 0.133697046, 0.111968437,
+                                      0.021198141, 1.005410934, -0.026610548,
+                                      -0.009756991, 0.004508563, 1.005253201]),
+            'direction': 'forward'
         })
     elif gamut == 'S-Gamut Daylight':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':mat44FromMat33([0.8764457030, 0.0145411681, 0.1090131290,
-                                    0.0774075345, 0.9529571767, -0.0303647111, 
-                                    0.0573564351, -0.1151066335, 1.0577501984]),
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': mat44FromMat33(
+                [0.8764457030, 0.0145411681, 0.1090131290,
+                 0.0774075345, 0.9529571767, -0.0303647111,
+                 0.0573564351, -0.1151066335, 1.0577501984]),
+            'direction': 'forward'
         })
     elif gamut == 'S-Gamut Tungsten':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':mat44FromMat33([1.0110238740, -0.1362526051, 0.1252287310, 
-                        0.1011994504, 0.9562196265, -0.0574190769,
-                        0.0600766530, -0.1010185315, 1.0409418785]),
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': mat44FromMat33(
+                [1.0110238740, -0.1362526051, 0.1252287310,
+                 0.1011994504, 0.9562196265, -0.0574190769,
+                 0.0600766530, -0.1010185315, 1.0409418785]),
+            'direction': 'forward'
         })
     elif gamut == 'S-Gamut3.Cine':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':mat44FromMat33([0.6387886672, 0.2723514337, 0.0888598992, 
-                                    -0.0039159061, 1.0880732308, -0.0841573249, 
-                                    -0.0299072021, -0.0264325799, 1.0563397820]),
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': mat44FromMat33(
+                [0.6387886672, 0.2723514337, 0.0888598992,
+                 -0.0039159061, 1.0880732308, -0.0841573249,
+                 -0.0299072021, -0.0264325799, 1.0563397820]),
+            'direction': 'forward'
         })
     elif gamut == 'S-Gamut3':
-        cs.toReferenceTransforms.append( {
-            'type':'matrix',
-            'matrix':mat44FromMat33([0.7529825954, 0.1433702162, 0.1036471884, 
-                        0.0217076974, 1.0153188355, -0.0370265329, 
-                        -0.0094160528, 0.0033704179, 1.0060456349]),
-            'direction':'forward'
+        cs.toReferenceTransforms.append({
+            'type': 'matrix',
+            'matrix': mat44FromMat33(
+                [0.7529825954, 0.1433702162, 0.1036471884,
+                 0.0217076974, 1.0153188355, -0.0370265329,
+                 -0.0094160528, 0.0033704179, 1.0060456349]),
+            'direction': 'forward'
         })
 
     cs.fromReferenceTransforms = []
     return cs
 
+
 def createColorSpaces(lutDir, lutResolution1d):
     colorspaces = []
 
     # SLog1
-    SLog1SGamut = createSlog("S-Gamut", "S-Log1", "S-Log", lutDir, lutResolution1d)
+    SLog1SGamut = createSlog(
+        "S-Gamut", "S-Log1", "S-Log", lutDir, lutResolution1d)
     colorspaces.append(SLog1SGamut)
 
     # SLog2
-    SLog2SGamut = createSlog("S-Gamut", "S-Log2", "S-Log2", lutDir, lutResolution1d)
+    SLog2SGamut = createSlog(
+        "S-Gamut", "S-Log2", "S-Log2", lutDir, lutResolution1d)
     colorspaces.append(SLog2SGamut)
 
-    SLog2SGamutDaylight = createSlog("S-Gamut Daylight", "S-Log2", "S-Log2", lutDir, lutResolution1d)
+    SLog2SGamutDaylight = createSlog(
+        "S-Gamut Daylight", "S-Log2", "S-Log2", lutDir, lutResolution1d)
     colorspaces.append(SLog2SGamutDaylight)
 
-    SLog2SGamutTungsten = createSlog("S-Gamut Tungsten", "S-Log2", "S-Log2", lutDir, lutResolution1d)
+    SLog2SGamutTungsten = createSlog(
+        "S-Gamut Tungsten", "S-Log2", "S-Log2", lutDir, lutResolution1d)
     colorspaces.append(SLog2SGamutTungsten)
 
     # SLog3
-    SLog3SGamut3Cine = createSlog("S-Gamut3.Cine", "S-Log3", "S-Log3", lutDir, lutResolution1d)
+    SLog3SGamut3Cine = createSlog(
+        "S-Gamut3.Cine", "S-Log3", "S-Log3", lutDir, lutResolution1d)
     colorspaces.append(SLog3SGamut3Cine)
 
-    SLog3SGamut3 = createSlog("S-Gamut3", "S-Log3", "S-Log3", lutDir, lutResolution1d)
+    SLog3SGamut3 = createSlog(
+        "S-Gamut3", "S-Log3", "S-Log3", lutDir, lutResolution1d)
     colorspaces.append(SLog3SGamut3)
 
     # Linearization only
@@ -185,13 +223,16 @@ def createColorSpaces(lutDir, lutResolution1d):
     SGamut = createSlog("S-Gamut", "", "S-Log", lutDir, lutResolution1d)
     colorspaces.append(SGamut)
 
-    SGamutDaylight = createSlog("S-Gamut Daylight", "", "S-Log2", lutDir, lutResolution1d)
+    SGamutDaylight = createSlog(
+        "S-Gamut Daylight", "", "S-Log2", lutDir, lutResolution1d)
     colorspaces.append(SGamutDaylight)
 
-    SGamutTungsten = createSlog("S-Gamut Tungsten", "", "S-Log2", lutDir, lutResolution1d)
+    SGamutTungsten = createSlog(
+        "S-Gamut Tungsten", "", "S-Log2", lutDir, lutResolution1d)
     colorspaces.append(SGamutTungsten)
 
-    SGamut3Cine = createSlog("S-Gamut3.Cine", "", "S-Log3", lutDir, lutResolution1d)
+    SGamut3Cine = createSlog(
+        "S-Gamut3.Cine", "", "S-Log3", lutDir, lutResolution1d)
     colorspaces.append(SGamut3Cine)
 
     SGamut3 = createSlog("S-Gamut3", "", "S-Log3", lutDir, lutResolution1d)
index 230fde4..18f2d8d 100755 (executable)
@@ -1,11 +1,11 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-'''
+"""
 usage from python
 
 import sys
-sys.path.append( "/path/to/script" )
+sys.path.append("/path/to/script")
 import create_aces_config as cac
 acesReleaseCTLDir = "/path/to/github/checkout/releases/v0.7.1/transforms/ctl"
 configDir = "/path/to/config/dir"
@@ -37,8 +37,7 @@ brew install -vd CTL
 # this time, 'ociolutimage' will build because openimageio is installed
 brew uninstall -vd opencolorio
 brew install -vd opencolorio --with-python
-'''
-
+"""
 
 import math
 import numpy
@@ -79,21 +78,24 @@ def setConfigDefaultRoles(config,
                           scene_linear="",
                           texture_paint=""):
     # Add Roles
-    if color_picking: config.setRole(OCIO.Constants.ROLE_COLOR_PICKING,
-                                     color_picking)
-    if color_timing: config.setRole(OCIO.Constants.ROLE_COLOR_TIMING,
-                                    color_timing)
-    if compositing_log: config.setRole(OCIO.Constants.ROLE_COMPOSITING_LOG,
-                                       compositing_log)
-    if data: config.setRole(OCIO.Constants.ROLE_DATA, data)
-    if default: config.setRole(OCIO.Constants.ROLE_DEFAULT, default)
-    if matte_paint: config.setRole(OCIO.Constants.ROLE_MATTE_PAINT,
-                                   matte_paint)
-    if reference: config.setRole(OCIO.Constants.ROLE_REFERENCE, reference)
-    if scene_linear: config.setRole(OCIO.Constants.ROLE_SCENE_LINEAR,
-                                    scene_linear)
-    if texture_paint: config.setRole(OCIO.Constants.ROLE_TEXTURE_PAINT,
-                                     texture_paint)
+    if color_picking:
+        config.setRole(OCIO.Constants.ROLE_COLOR_PICKING, color_picking)
+    if color_timing:
+        config.setRole(OCIO.Constants.ROLE_COLOR_TIMING, color_timing)
+    if compositing_log:
+        config.setRole(OCIO.Constants.ROLE_COMPOSITING_LOG, compositing_log)
+    if data:
+        config.setRole(OCIO.Constants.ROLE_DATA, data)
+    if default:
+        config.setRole(OCIO.Constants.ROLE_DEFAULT, default)
+    if matte_paint:
+        config.setRole(OCIO.Constants.ROLE_MATTE_PAINT, matte_paint)
+    if reference:
+        config.setRole(OCIO.Constants.ROLE_REFERENCE, reference)
+    if scene_linear:
+        config.setRole(OCIO.Constants.ROLE_SCENE_LINEAR, scene_linear)
+    if texture_paint:
+        config.setRole(OCIO.Constants.ROLE_TEXTURE_PAINT, texture_paint)
 
 
 # Write config to disk
@@ -113,7 +115,7 @@ def writeConfig(config, configPath, sanityCheck=True):
 
 
 def generateOCIOTransform(transforms):
-    # print( "Generating transforms")
+    # print("Generating transforms")
 
     interpolationOptions = {
         'linear': OCIO.Constants.INTERP_LINEAR,
@@ -129,22 +131,20 @@ def generateOCIOTransform(transforms):
 
     for transform in transforms:
         if transform['type'] == 'lutFile':
-
-            ocioTransform = OCIO.FileTransform(src=transform['path'],
-                                               interpolation=
-                                               interpolationOptions[
-                                                   transform['interpolation']],
-                                               direction=directionOptions[
-                                                   transform['direction']])
-
+            ocioTransform = OCIO.FileTransform(
+                src=transform['path'],
+                interpolation=interpolationOptions[transform['interpolation']],
+                direction=directionOptions[transform['direction']])
             ocioTransforms.append(ocioTransform)
         elif transform['type'] == 'matrix':
             ocioTransform = OCIO.MatrixTransform()
-            # MatrixTransform member variables can't be initialized directly. Each must be set individually
+            # MatrixTransform member variables can't be initialized directly.
+            # Each must be set individually.
             ocioTransform.setMatrix(transform['matrix'])
 
             if 'offset' in transform:
                 ocioTransform.setOffset(transform['offset'])
+
             if 'direction' in transform:
                 ocioTransform.setDirection(
                     directionOptions[transform['direction']])
@@ -153,16 +153,15 @@ def generateOCIOTransform(transforms):
         elif transform['type'] == 'exponent':
             ocioTransform = OCIO.ExponentTransform()
             ocioTransform.setValue(transform['value'])
-
             ocioTransforms.append(ocioTransform)
         elif transform['type'] == 'log':
-            ocioTransform = OCIO.LogTransform(base=transform['base'],
-                                              direction=directionOptions[
-                                                  transform['direction']])
+            ocioTransform = OCIO.LogTransform(
+                base=transform['base'],
+                direction=directionOptions[transform['direction']])
 
             ocioTransforms.append(ocioTransform)
         else:
-            print( "Ignoring unknown transform type : %s" % transform['type'] )
+            print("Ignoring unknown transform type : %s" % transform['type'])
 
     # Build a group transform if necessary
     if len(ocioTransforms) > 1:
@@ -192,17 +191,18 @@ def createConfig(configData, nuke=False):
     # Define the reference color space
     #
     referenceData = configData['referenceColorSpace']
-    print( "Adding the reference color space : %s" % referenceData.name)
+    print("Adding the reference color space : %s" % referenceData.name)
 
     # Create a color space
-    reference = OCIO.ColorSpace(name=referenceData.name,
-                                bitDepth=referenceData.bitDepth,
-                                description=referenceData.description,
-                                equalityGroup=referenceData.equalityGroup,
-                                family=referenceData.family,
-                                isData=referenceData.isData,
-                                allocation=referenceData.allocationType,
-                                allocationVars=referenceData.allocationVars)
+    reference = OCIO.ColorSpace(
+        name=referenceData.name,
+        bitDepth=referenceData.bitDepth,
+        description=referenceData.description,
+        equalityGroup=referenceData.equalityGroup,
+        family=referenceData.family,
+        isData=referenceData.isData,
+        allocation=referenceData.allocationType,
+        allocationVars=referenceData.allocationVars)
 
     # Add to config
     config.addColorSpace(reference)
@@ -211,34 +211,37 @@ def createConfig(configData, nuke=False):
     # Create the rest of the color spaces
     #
     for colorspace in sorted(configData['colorSpaces']):
-        print( "Creating new color space : %s" % colorspace.name)
-
-        ocioColorspace = OCIO.ColorSpace(name=colorspace.name,
-                                         bitDepth=colorspace.bitDepth,
-                                         description=colorspace.description,
-                                         equalityGroup=colorspace.equalityGroup,
-                                         family=colorspace.family,
-                                         isData=colorspace.isData,
-                                         allocation=colorspace.allocationType,
-                                         allocationVars=colorspace.allocationVars)
+        print("Creating new color space : %s" % colorspace.name)
+
+        ocioColorspace = OCIO.ColorSpace(
+            name=colorspace.name,
+            bitDepth=colorspace.bitDepth,
+            description=colorspace.description,
+            equalityGroup=colorspace.equalityGroup,
+            family=colorspace.family,
+            isData=colorspace.isData,
+            allocation=colorspace.allocationType,
+            allocationVars=colorspace.allocationVars)
 
         if colorspace.toReferenceTransforms != []:
-            print( "Generating To-Reference transforms")
+            print("Generating To-Reference transforms")
             ocioTransform = generateOCIOTransform(
                 colorspace.toReferenceTransforms)
-            ocioColorspace.setTransform(ocioTransform,
-                                        OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
+            ocioColorspace.setTransform(
+                ocioTransform,
+                OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
 
         if colorspace.fromReferenceTransforms != []:
-            print( "Generating From-Reference transforms")
+            print("Generating From-Reference transforms")
             ocioTransform = generateOCIOTransform(
                 colorspace.fromReferenceTransforms)
-            ocioColorspace.setTransform(ocioTransform,
-                                        OCIO.Constants.COLORSPACE_DIR_FROM_REFERENCE)
+            ocioColorspace.setTransform(
+                ocioTransform,
+                OCIO.Constants.COLORSPACE_DIR_FROM_REFERENCE)
 
         config.addColorSpace(ocioColorspace)
 
-        print( "" )
+        print("")
 
     #
     # Define the views and displays
@@ -257,12 +260,13 @@ def createConfig(configData, nuke=False):
     # A Nuke specific set of views and displays
     #
     # XXX
-    # A few names: Output Transform, ACES, ACEScc, are hard-coded here. Would be better to automate
+    # A few names: Output Transform, ACES, ACEScc, are hard-coded here.
+    # Would be better to automate.
     #
     else:
         for display, viewList in configData['displays'].iteritems():
             for viewName, colorspace in viewList.iteritems():
-                if ( viewName == 'Output Transform'):
+                if (viewName == 'Output Transform'):
                     viewName = 'View'
                     config.addDisplay(display, viewName, colorspace.name)
                     if not (viewName in views):
@@ -301,21 +305,29 @@ def createConfig(configData, nuke=False):
 
 
 #
-# Functions to generate color space definitions and LUTs for transforms for a specific ACES release
+# Functions to generate color space definitions and LUTs for transforms for a
+# specific ACES release.
 #
 
 # Output is a list of colorspaces and transforms that convert between those
 # colorspaces and reference color space, ACES
-def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
-                 lutResolution1d=4096, lutResolution3d=64, cleanup=True):
-    print( "generateLUTs - begin" )
+def generateLUTs(odtInfo,
+                 lmtInfo,
+                 shaperName,
+                 acesCTLReleaseDir,
+                 lutDir,
+                 lutResolution1d=4096,
+                 lutResolution3d=64,
+                 cleanup=True):
+    print("generateLUTs - begin")
     configData = {}
 
     #
     # Define the reference color space
     #
     ACES = ColorSpace('ACES2065-1')
-    ACES.description = "The Academy Color Encoding System reference color space"
+    ACES.description = (
+        'The Academy Color Encoding System reference color space')
     ACES.equalityGroup = ''
     ACES.family = 'ACES'
     ACES.isData = False
@@ -347,7 +359,9 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
     #
     # ACEScc
     #
-    def createACEScc(name='ACEScc', minValue=0.0, maxValue=1.0,
+    def createACEScc(name='ACEScc',
+                     minValue=0.0,
+                     maxValue=1.0,
                      inputScale=1.0):
         cs = ColorSpace(name)
         cs.description = "The %s color space" % name
@@ -367,17 +381,18 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
         # Remove spaces and parentheses
         lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
 
-        genlut.generate1dLUTFromCTL(lutDir + "/" + lut,
-                                    ctls,
-                                    lutResolution1d,
-                                    'float',
-                                    inputScale,
-                                    1.0,
+        genlut.generate1dLUTFromCTL(
+            lutDir + "/" + lut,
+            ctls,
+            lutResolution1d,
+            'float',
+            inputScale,
+            1.0,
             {},
-                                    cleanup,
-                                    acesCTLReleaseDir,
-                                    minValue,
-                                    maxValue)
+            cleanup,
+            acesCTLReleaseDir,
+            minValue,
+            maxValue)
 
         cs.toReferenceTransforms = []
         cs.toReferenceTransforms.append({
@@ -411,7 +426,8 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
         cs.isData = False
 
         ctls = [
-            '%s/ACESproxy/ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl' % acesCTLReleaseDir,
+            '%s/ACESproxy/ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl' % (
+                acesCTLReleaseDir),
             # This transform gets back to the AP1 primaries
             # Useful as the 1d LUT is only covering the transfer function
             # The primaries switch is covered by the matrix below
@@ -422,15 +438,16 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
         # Remove spaces and parentheses
         lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
 
-        genlut.generate1dLUTFromCTL(lutDir + "/" + lut,
-                                    ctls,
-                                    lutResolution1d,
-                                    'uint16',
-                                    64.0,
-                                    1.0,
+        genlut.generate1dLUTFromCTL(
+            lutDir + "/" + lut,
+            ctls,
+            lutResolution1d,
+            'uint16',
+            64.0,
+            1.0,
             {},
-                                    cleanup,
-                                    acesCTLReleaseDir)
+            cleanup,
+            acesCTLReleaseDir)
 
         cs.toReferenceTransforms = []
         cs.toReferenceTransforms.append({
@@ -554,8 +571,8 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
                          -1.121718645000000,
                          -0.926545676714876]
 
-            REF_PT = (7120.0 - 1520.0) / 8000.0 * (100.0 / 55.0) - math.log(
-                0.18, 10.0)
+            REF_PT = ((7120.0 - 1520.0) / 8000.0 * (100.0 / 55.0) -
+                      math.log(0.18, 10.0))
 
             def cid_to_rle(x):
                 if x <= 0.6:
@@ -582,7 +599,8 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
 
             return lut
 
-        # Convert Channel Independent Density values to Relative Log Exposure values
+        # Convert Channel Independent Density values to Relative Log Exposure
+        # values.
         lut = createCIDtoRLELUT()
         cs.toReferenceTransforms.append({
             'type': 'lutFile',
@@ -659,28 +677,30 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
         cs.isData = False
 
         ctls = [
-            '%s/utilities/ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl' % acesCTLReleaseDir
+            '%s/utilities/ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl' % (
+                acesCTLReleaseDir)
         ]
         lut = "%s_to_aces.spi1d" % name
 
         # Remove spaces and parentheses
         lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
 
-        genlut.generate1dLUTFromCTL(lutDir + "/" + lut,
-                                    ctls,
-                                    lutResolution1d,
-                                    'float',
-                                    inputScale,
-                                    1.0,
-                                    {
-                                        'middleGrey': middleGrey,
-                                        'minExposure': minExposure,
-                                        'maxExposure': maxExposure
-                                    },
-                                    cleanup,
-                                    acesCTLReleaseDir,
-                                    minValue,
-                                    maxValue)
+        genlut.generate1dLUTFromCTL(
+            lutDir + "/" + lut,
+            ctls,
+            lutResolution1d,
+            'float',
+            inputScale,
+            1.0,
+            {
+                'middleGrey': middleGrey,
+                'minExposure': minExposure,
+                'maxExposure': maxExposure
+            },
+            cleanup,
+            acesCTLReleaseDir,
+            minValue,
+            maxValue)
 
         cs.toReferenceTransforms = []
         cs.toReferenceTransforms.append({
@@ -715,28 +735,32 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
         #
         # Generate the shaper transform
         #
-        (shaperName, shaperToACESCTL, shaperFromACESCTL, shaperInputScale,
+        (shaperName,
+         shaperToACESCTL,
+         shaperFromACESCTL,
+         shaperInputScale,
          shaperParams) = shaperInfo
 
         shaperLut = "%s_to_aces.spi1d" % shaperName
-        if ( not os.path.exists(lutDir + "/" + shaperLut) ):
+        if (not os.path.exists(lutDir + "/" + shaperLut)):
             ctls = [
                 shaperToACESCTL % acesCTLReleaseDir
             ]
 
             # Remove spaces and parentheses
-            shaperLut = shaperLut.replace(' ', '_').replace(')', '_').replace(
-                '(', '_')
+            shaperLut = shaperLut.replace(
+                ' ', '_').replace(')', '_').replace('(', '_')
 
-            genlut.generate1dLUTFromCTL(lutDir + "/" + shaperLut,
-                                        ctls,
-                                        lutResolution1d,
-                                        'float',
-                                        1.0 / shaperInputScale,
-                                        1.0,
-                                        shaperParams,
-                                        cleanup,
-                                        acesCTLReleaseDir)
+            genlut.generate1dLUTFromCTL(
+                lutDir + "/" + shaperLut,
+                ctls,
+                lutResolution1d,
+                'float',
+                1.0 / shaperInputScale,
+                1.0,
+                shaperParams,
+                cleanup,
+                acesCTLReleaseDir)
 
         shaperOCIOTransform = {
             'type': 'lutFile',
@@ -760,15 +784,16 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
             # Remove spaces and parentheses
             lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
 
-            genlut.generate3dLUTFromCTL(lutDir + "/" + lut,
-                                        ctls,
-                                        lutResolution3d,
-                                        'float',
-                                        1.0 / shaperInputScale,
-                                        1.0,
-                                        shaperParams,
-                                        cleanup,
-                                        acesCTLReleaseDir)
+            genlut.generate3dLUTFromCTL(
+                lutDir + "/" + lut,
+                ctls,
+                lutResolution3d,
+                'float',
+                1.0 / shaperInputScale,
+                1.0,
+                shaperParams,
+                cleanup,
+                acesCTLReleaseDir)
 
             cs.fromReferenceTransforms.append(shaperOCIOTransform)
             cs.fromReferenceTransforms.append({
@@ -794,15 +819,16 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
             # Remove spaces and parentheses
             lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
 
-            genlut.generate3dLUTFromCTL(lutDir + "/" + lut,
-                                        ctls,
-                                        lutResolution3d,
-                                        'half',
-                                        1.0,
-                                        shaperInputScale,
-                                        shaperParams,
-                                        cleanup,
-                                        acesCTLReleaseDir)
+            genlut.generate3dLUTFromCTL(
+                lutDir + "/" + lut,
+                ctls,
+                lutResolution3d,
+                'half',
+                1.0,
+                shaperInputScale,
+                shaperParams,
+                cleanup,
+                acesCTLReleaseDir)
 
             cs.toReferenceTransforms.append({
                 'type': 'lutFile',
@@ -850,7 +876,7 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
     ]
 
     sortedLMTs = sorted(lmtInfo.iteritems(), key=lambda x: x[1])
-    print( sortedLMTs )
+    print(sortedLMTs)
     for lmt in sortedLMTs:
         (lmtName, lmtValues) = lmt
         cs = createACESLMT(
@@ -886,7 +912,10 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
         # Generate the shaper transform
         #
         # if 'shaperCTL' in odtValues:
-        (shaperName, shaperToACESCTL, shaperFromACESCTL, shaperInputScale,
+        (shaperName,
+         shaperToACESCTL,
+         shaperFromACESCTL,
+         shaperInputScale,
          shaperParams) = shaperInfo
 
         if 'legalRange' in odtValues:
@@ -895,24 +924,25 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
             shaperParams['legalRange'] = 0
 
         shaperLut = "%s_to_aces.spi1d" % shaperName
-        if ( not os.path.exists(lutDir + "/" + shaperLut) ):
+        if (not os.path.exists(lutDir + "/" + shaperLut)):
             ctls = [
                 shaperToACESCTL % acesCTLReleaseDir
             ]
 
             # Remove spaces and parentheses
-            shaperLut = shaperLut.replace(' ', '_').replace(')', '_').replace(
-                '(', '_')
+            shaperLut = shaperLut.replace(
+                ' ', '_').replace(')', '_').replace('(', '_')
 
-            genlut.generate1dLUTFromCTL(lutDir + "/" + shaperLut,
-                                        ctls,
-                                        lutResolution1d,
-                                        'float',
-                                        1.0 / shaperInputScale,
-                                        1.0,
-                                        shaperParams,
-                                        cleanup,
-                                        acesCTLReleaseDir)
+            genlut.generate1dLUTFromCTL(
+                lutDir + "/" + shaperLut,
+                ctls,
+                lutResolution1d,
+                'float',
+                1.0 / shaperInputScale,
+                1.0,
+                shaperParams,
+                cleanup,
+                acesCTLReleaseDir)
 
         shaperOCIOTransform = {
             'type': 'lutFile',
@@ -1005,16 +1035,17 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
             # Remove spaces and parentheses
             lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
 
-            genlut.generate3dLUTFromCTL(lutDir + "/" + lut,
-                                        # None,
-                                        ctls,
-                                        lutResolution3d,
-                                        'half',
-                                        1.0,
-                                        shaperInputScale,
-                                        shaperParams,
-                                        cleanup,
-                                        acesCTLReleaseDir)
+            genlut.generate3dLUTFromCTL(
+                lutDir + "/" + lut,
+                # None,
+                ctls,
+                lutResolution3d,
+                'half',
+                1.0,
+                shaperInputScale,
+                shaperParams,
+                cleanup,
+                acesCTLReleaseDir)
 
             cs.toReferenceTransforms.append({
                 'type': 'lutFile',
@@ -1087,7 +1118,7 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
     # RRT + ODT Combinations
     #
     sortedOdts = sorted(odtInfo.iteritems(), key=lambda x: x[1])
-    print( sortedOdts )
+    print(sortedOdts)
     for odt in sortedOdts:
         (odtName, odtValues) = odt
 
@@ -1120,7 +1151,7 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
         if odtName in ['Academy.Rec2020_100nits_dim.a1.0.0',
                        'Academy.Rec709_100nits_dim.a1.0.0',
                        'Academy.Rec709_D60sim_100nits_dim.a1.0.0']:
-            print( "Generating full range ODT for %s" % odtName)
+            print("Generating full range ODT for %s" % odtName)
 
             odtNameFull = "%s - Full" % odtValues['transformUserName']
             odtFull = odtValues.copy()
@@ -1215,12 +1246,16 @@ def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
                              fromReferenceValues=[acesAP0toXYZ, xyzToRec2020])
     configData['colorSpaces'].append(cs)
 
-    print( "generateLUTs - end" )
+    print("generateLUTs - end")
     return configData
 
 
-def generateBakedLUTs(odtInfo, shaperName, bakedDir, configPath,
-                      lutResolution1d, lutResolution3d,
+def generateBakedLUTs(odtInfo,
+                      shaperName,
+                      bakedDir,
+                      configPath,
+                      lutResolution1d,
+                      lutResolution3d,
                       lutResolutionShaper=1024):
     # Add the legal and full variations into this list
     odtInfoC = dict(odtInfo)
@@ -1238,7 +1273,7 @@ def generateBakedLUTs(odtInfo, shaperName, bakedDir, configPath,
             odtValuesFull["transformUserName"] = "%s - Full" % odtName
             odtInfoC["%s - Full" % odtCTLName] = odtValuesFull
 
-            del ( odtInfoC[odtCTLName] )
+            del (odtInfoC[odtCTLName])
 
     for odtCTLName, odtValues in odtInfoC.iteritems():
         odtPrefix = odtValues["transformUserNamePrefix"]
@@ -1334,17 +1369,17 @@ def getTransformInfo(ctlTransform):
 
     # Grab transform ID and User Name
     transformID = lines[1][3:].split('<')[1].split('>')[1].lstrip().rstrip()
-    # print( transformID )
+    # print(transformID)
     transformUserName = '-'.join(
         lines[2][3:].split('<')[1].split('>')[1].split('-')[
         1:]).lstrip().rstrip()
     transformUserNamePrefix = \
         lines[2][3:].split('<')[1].split('>')[1].split('-')[
             0].lstrip().rstrip()
-    # print( transformUserName )
+    # print(transformUserName)
     fp.close()
 
-    return (transformID, transformUserName, transformUserNamePrefix)
+    return transformID, transformUserName, transformUserNamePrefix
 
 
 # For versions after WGR9
@@ -1365,7 +1400,7 @@ def getODTInfo(acesCTLReleaseDir):
 
     for odtCTL in odtCTLs:
         odtTokens = os.path.split(odtCTL)
-        # print( odtTokens )
+        # print(odtTokens)
 
         # Handle nested directories
         odtPathTokens = os.path.split(odtTokens[-2])
@@ -1375,11 +1410,11 @@ def getODTInfo(acesCTLReleaseDir):
             odtDir = os.path.join(odtPathTokens[-1], odtDir)
 
         # Build full name
-        # print( "odtDir : %s" % odtDir )
+        # print("odtDir : %s" % odtDir)
         transformCTL = odtTokens[-1]
-        # print( transformCTL )
+        # print(transformCTL)
         odtName = string.join(transformCTL.split('.')[1:-1], '.')
-        # print( odtName )
+        # print(odtName)
 
         # Find id, user name and user name prefix
         (transformID, transformUserName,
@@ -1391,33 +1426,32 @@ def getODTInfo(acesCTLReleaseDir):
         if not os.path.exists(
                 os.path.join(odtTokens[-2], transformCTLInverse)):
             transformCTLInverse = None
-        #print( transformCTLInverse )
+        # print(transformCTLInverse)
 
         # Add to list of ODTs
         odts[odtName] = {}
         odts[odtName]['transformCTL'] = os.path.join(odtDir, transformCTL)
         if transformCTLInverse != None:
-            odts[odtName]['transformCTLInverse'] = os.path.join(odtDir,
-                                                                transformCTLInverse)
+            odts[odtName]['transformCTLInverse'] = os.path.join(
+                odtDir, transformCTLInverse)
 
         odts[odtName]['transformID'] = transformID
         odts[odtName]['transformUserNamePrefix'] = transformUserNamePrefix
         odts[odtName]['transformUserName'] = transformUserName
 
-        print( "ODT : %s" % odtName )
-        print( "\tTransform ID               : %s" % transformID )
-        print( "\tTransform User Name Prefix : %s" % transformUserNamePrefix )
-        print( "\tTransform User Name        : %s" % transformUserName )
-        print(
-            "\tForward ctl                : %s" % odts[odtName][
-                'transformCTL'])
+        print("ODT : %s" % odtName)
+        print("\tTransform ID               : %s" % transformID)
+        print("\tTransform User Name Prefix : %s" % transformUserNamePrefix)
+        print("\tTransform User Name        : %s" % transformUserName)
+        print("\tForward ctl                : %s" % (
+            odts[odtName]['transformCTL']))
         if 'transformCTLInverse' in odts[odtName]:
-            print("\tInverse ctl                : %s" % odts[odtName][
-                'transformCTLInverse'])
+            print("\tInverse ctl                : %s" % (
+                odts[odtName]['transformCTLInverse']))
         else:
-            print( "\tInverse ctl                : %s" % "None" )
+            print("\tInverse ctl                : %s" % "None")
 
-    print( "\n" )
+    print("\n")
 
     return odts
 
@@ -1441,7 +1475,7 @@ def getLMTInfo(acesCTLReleaseDir):
 
     for lmtCTL in lmtCTLs:
         lmtTokens = os.path.split(lmtCTL)
-        # print( lmtTokens )
+        # print(lmtTokens)
 
         # Handle nested directories
         lmtPathTokens = os.path.split(lmtTokens[-2])
@@ -1451,11 +1485,11 @@ def getLMTInfo(acesCTLReleaseDir):
             lmtDir = os.path.join(lmtPathTokens[-1], lmtDir)
 
         # Build full name
-        # print( "lmtDir : %s" % lmtDir )
+        # print("lmtDir : %s" % lmtDir)
         transformCTL = lmtTokens[-1]
-        # print( transformCTL )
+        # print(transformCTL)
         lmtName = string.join(transformCTL.split('.')[1:-1], '.')
-        # print( lmtName )
+        # print(lmtName)
 
         # Find id, user name and user name prefix
         (transformID, transformUserName,
@@ -1467,32 +1501,32 @@ def getLMTInfo(acesCTLReleaseDir):
         if not os.path.exists(
                 os.path.join(lmtTokens[-2], transformCTLInverse)):
             transformCTLInverse = None
-        #print( transformCTLInverse )
+        # print(transformCTLInverse)
 
         # Add to list of LMTs
         lmts[lmtName] = {}
         lmts[lmtName]['transformCTL'] = os.path.join(lmtDir, transformCTL)
         if transformCTLInverse != None:
             # TODO: Check unresolved *odtName* referemce.
-            lmts[odtName]['transformCTLInverse'] = os.path.join(lmtDir,
-                                                                transformCTLInverse)
+            lmts[odtName]['transformCTLInverse'] = os.path.join(
+                lmtDir, transformCTLInverse)
 
         lmts[lmtName]['transformID'] = transformID
         lmts[lmtName]['transformUserNamePrefix'] = transformUserNamePrefix
         lmts[lmtName]['transformUserName'] = transformUserName
 
-        print( "LMT : %s" % lmtName )
-        print( "\tTransform ID               : %s" % transformID )
-        print( "\tTransform User Name Prefix : %s" % transformUserNamePrefix )
-        print( "\tTransform User Name        : %s" % transformUserName )
-        print( "\t Forward ctl : %s" % lmts[lmtName]['transformCTL'])
+        print("LMT : %s" % lmtName)
+        print("\tTransform ID               : %s" % transformID)
+        print("\tTransform User Name Prefix : %s" % transformUserNamePrefix)
+        print("\tTransform User Name        : %s" % transformUserName)
+        print("\t Forward ctl : %s" % lmts[lmtName]['transformCTL'])
         if 'transformCTLInverse' in lmts[lmtName]:
-            print(
-                "\t Inverse ctl : %s" % lmts[lmtName]['transformCTLInverse'])
+            print("\t Inverse ctl : %s" % (
+                lmts[lmtName]['transformCTLInverse']))
         else:
-            print( "\t Inverse ctl : %s" % "None" )
+            print("\t Inverse ctl : %s" % "None")
 
-    print( "\n" )
+    print("\n")
 
     return lmts
 
@@ -1518,31 +1552,41 @@ def createACESConfig(acesCTLReleaseDir,
     # Generate config data and LUTs for different transforms
     lutDir = "%s/luts" % configDir
     shaperName = 'Output Shaper'
-    configData = generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir,
-                              lutDir, lutResolution1d, lutResolution3d,
+    configData = generateLUTs(odtInfo,
+                              lmtInfo,
+                              shaperName,
+                              acesCTLReleaseDir,
+                              lutDir,
+                              lutResolution1d,
+                              lutResolution3d,
                               cleanup)
 
     # Create the config using the generated LUTs
-    print( "Creating generic config")
+    print("Creating generic config")
     config = createConfig(configData)
-    print( "\n\n\n" )
+    print("\n\n\n")
 
     # Write the config to disk
     writeConfig(config, "%s/config.ocio" % configDir)
 
-    # Create a config that will work well with Nuke using the previously generated LUTs
-    print( "Creating Nuke-specific config")
+    # Create a config that will work well with Nuke using the previously
+    # generated LUTs.
+    print("Creating Nuke-specific config")
     nuke_config = createConfig(configData, nuke=True)
-    print( "\n\n\n" )
+    print("\n\n\n")
 
     # Write the config to disk
     writeConfig(nuke_config, "%s/nuke_config.ocio" % configDir)
 
     # Bake secondary LUTs using the config
     if bakeSecondaryLUTs:
-        generateBakedLUTs(odtInfo, shaperName, "%s/baked" % configDir,
-                          "%s/config.ocio" % configDir, lutResolution1d,
-                          lutResolution3d, lutResolution1d)
+        generateBakedLUTs(odtInfo,
+                          shaperName,
+                          "%s/baked" % configDir,
+                          "%s/config.ocio" % configDir,
+                          lutResolution1d,
+                          lutResolution3d,
+                          lutResolution1d)
 
     return True
 
@@ -1585,20 +1629,24 @@ def main():
         argsStart = len(sys.argv) + 1
         args = []
 
-    print( "command line : \n%s\n" % " ".join(sys.argv) )
+    print("command line : \n%s\n" % " ".join(sys.argv))
 
     # TODO: Use assertion and mention environment variables.
     if not acesCTLDir:
-        print( "process: No ACES CTL directory specified" )
+        print("process: No ACES CTL directory specified")
         return
     if not configDir:
-        print( "process: No configuration directory specified" )
+        print("process: No configuration directory specified")
         return
     #
     # Generate the configuration
     #
-    createACESConfig(acesCTLDir, configDir, lutResolution1d, lutResolution3d,
-                     bakeSecondaryLUTs, cleanupTempImages)
+    return createACESConfig(acesCTLDir,
+                            configDir,
+                            lutResolution1d,
+                            lutResolution3d,
+                            bakeSecondaryLUTs,
+                            cleanupTempImages)
 
 # main
 
index 58777e5..74c1554 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-'''
+"""
 build instructions for osx for needed packages.
 
 #opencolorio
@@ -23,7 +23,7 @@ brew install -vd CTL
 # this time, 'ociolutimage' will build because openimageio is installed
 brew uninstall -vd opencolorio
 brew install -vd opencolorio --with-python
-'''
+"""
 
 import array
 import os
@@ -37,8 +37,11 @@ from aces_ocio.process import Process
 #
 # Functions used to generate LUTs using CTL transforms
 #
-def generate1dLUTImage(ramp1dPath, resolution=1024, minValue=0.0, maxValue=1.0):
-    #print( "Generate 1d LUT image - %s" % ramp1dPath)
+def generate1dLUTImage(ramp1dPath,
+                       resolution=1024,
+                       minValue=0.0,
+                       maxValue=1.0):
+    # print("Generate 1d LUT image - %s" % ramp1dPath)
 
     # open image
     format = os.path.splitext(ramp1dPath)[1]
@@ -46,46 +49,53 @@ def generate1dLUTImage(ramp1dPath, resolution=1024, minValue=0.0, maxValue=1.0):
 
     # set image specs
     spec = oiio.ImageSpec()
-    spec.set_format( oiio.FLOAT )
-    #spec.format.basetype = oiio.FLOAT
+    spec.set_format(oiio.FLOAT)
+    # spec.format.basetype = oiio.FLOAT
     spec.width = resolution
     spec.height = 1
     spec.nchannels = 3
 
-    ramp.open (ramp1dPath, spec, oiio.Create)
+    ramp.open(ramp1dPath, spec, oiio.Create)
 
-    data = array.array("f", "\0" * spec.width * spec.height * spec.nchannels * 4)
+    data = array.array("f",
+                       "\0" * spec.width * spec.height * spec.nchannels * 4)
     for i in range(resolution):
-        value = float(i)/(resolution-1) * (maxValue - minValue) + minValue
-        data[i*spec.nchannels +0] = value
-        data[i*spec.nchannels +1] = value
-        data[i*spec.nchannels +2] = value
+        value = float(i) / (resolution - 1) * (maxValue - minValue) + minValue
+        data[i * spec.nchannels + 0] = value
+        data[i * spec.nchannels + 1] = value
+        data[i * spec.nchannels + 2] = value
 
     ramp.write_image(spec.format, data)
     ramp.close()
 
-# Credit to Alex Fry for the original single channel version of the spi1d writer
+
+# Credit to Alex Fry for the original single channel version of the spi1d
+# writer
 def writeSPI1D(filename, fromMin, fromMax, data, entries, channels):
-    f = file(filename,'w')
+    f = file(filename, 'w')
     f.write("Version 1\n")
     f.write("From %f %f\n" % (fromMin, fromMax))
     f.write("Length %d\n" % entries)
-    f.write("Components %d\n" % (min(3, channels)) )
+    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])
+            entry = "%s %s" % (entry, data[i * channels + j])
         f.write("        %s\n" % entry)
     f.write("}\n")
     f.close()
 
-def generate1dLUTFromImage(ramp1dPath, outputPath=None, minValue=0.0, maxValue=1.0):
+
+def generate1dLUTFromImage(ramp1dPath,
+                           outputPath=None,
+                           minValue=0.0,
+                           maxValue=1.0):
     if outputPath == None:
         outputPath = ramp1dPath + ".spi1d"
 
     # open image
-    ramp = oiio.ImageInput.open( ramp1dPath )
+    ramp = oiio.ImageInput.open(ramp1dPath)
 
     # get image specs
     spec = ramp.spec()
@@ -95,32 +105,54 @@ def generate1dLUTFromImage(ramp1dPath, outputPath=None, minValue=0.0, maxValue=1
     channels = spec.nchannels
 
     # get data
-    # Force data to be read as float. The Python API doesn't handle half-floats well yet.
+    # Force data to be read as float. The Python API doesn't handle
+    # half-floats well yet.
     type = oiio.FLOAT
     data = ramp.read_image(type)
 
     writeSPI1D(outputPath, minValue, maxValue, data, width, channels)
 
+
 def generate3dLUTImage(ramp3dPath, resolution=32):
-    args = ["--generate", "--cubesize", str(resolution), "--maxwidth", str(resolution*resolution), "--output", ramp3dPath]
-    lutExtract = Process(description="generate a 3d LUT image", cmd="ociolutimage", args=args)
-    lutExtract.execute()    
+    args = ["--generate",
+            "--cubesize",
+            str(resolution),
+            "--maxwidth",
+            str(resolution * resolution),
+            "--output",
+            ramp3dPath]
+    lutExtract = Process(description="generate a 3d LUT image",
+                         cmd="ociolutimage",
+                         args=args)
+    lutExtract.execute()
+
 
 def generate3dLUTFromImage(ramp3dPath, outputPath=None, resolution=32):
     if outputPath == None:
         outputPath = ramp3dPath + ".spi3d"
 
-    args = ["--extract", "--cubesize", str(resolution), "--maxwidth", str(resolution*resolution), "--input", ramp3dPath, "--output", outputPath]
-    lutExtract = Process(description="extract a 3d LUT", cmd="ociolutimage", args=args)
-    lutExtract.execute()    
-
-def applyCTLToImage(inputImage, 
-    outputImage, 
-    ctlPaths=[], 
-    inputScale=1.0, 
-    outputScale=1.0, 
-    globalParams={},
-    acesCTLReleaseDir=None):
+    args = ["--extract",
+            "--cubesize",
+            str(resolution),
+            "--maxwidth",
+            str(resolution * resolution),
+            "--input",
+            ramp3dPath,
+            "--output",
+            outputPath]
+    lutExtract = Process(description="extract a 3d LUT",
+                         cmd="ociolutimage",
+                         args=args)
+    lutExtract.execute()
+
+
+def applyCTLToImage(inputImage,
+                    outputImage,
+                    ctlPaths=[],
+                    inputScale=1.0,
+                    outputScale=1.0,
+                    globalParams={},
+                    acesCTLReleaseDir=None):
     if len(ctlPaths) > 0:
         ctlenv = os.environ
         if acesCTLReleaseDir != None:
@@ -134,7 +166,7 @@ def applyCTLToImage(inputImage,
         for ctl in ctlPaths:
             args += ['-ctl', ctl]
         args += ["-force"]
-        #args += ["-verbose"]
+        # args += ["-verbose"]
         args += ["-input_scale", str(inputScale)]
         args += ["-output_scale", str(outputScale)]
         args += ["-global_param1", "aIn", "1.0"]
@@ -143,44 +175,65 @@ def applyCTLToImage(inputImage,
         args += [inputImage]
         args += [outputImage]
 
-        #print( "args : %s" % args )
+        # print("args : %s" % args)
 
-        ctlp = Process(description="a ctlrender process", cmd="ctlrender", args=args, env=ctlenv )
+        ctlp = Process(description="a ctlrender process",
+                       cmd="ctlrender",
+                       args=args, env=ctlenv)
 
         ctlp.execute()
 
+
 def convertBitDepth(inputImage, outputImage, depth):
-    args = [inputImage, "-d", depth, "-o", outputImage]
-    convert = Process(description="convert image bit depth", cmd="oiiotool", args=args)
-    convert.execute()    
-
-def generate1dLUTFromCTL(lutPath, 
-    ctlPaths, 
-    lutResolution=1024, 
-    identityLutBitDepth='half', 
-    inputScale=1.0, 
-    outputScale=1.0,
-    globalParams={},
-    cleanup=True,
-    acesCTLReleaseDir=None,
-    minValue=0.0,
-    maxValue=1.0):
-    #print( lutPath )
-    #print( ctlPaths )
+    args = [inputImage,
+            "-d",
+            depth,
+            "-o",
+            outputImage]
+    convert = Process(description="convert image bit depth",
+                      cmd="oiiotool",
+                      args=args)
+    convert.execute()
+
+
+def generate1dLUTFromCTL(lutPath,
+                         ctlPaths,
+                         lutResolution=1024,
+                         identityLutBitDepth='half',
+                         inputScale=1.0,
+                         outputScale=1.0,
+                         globalParams={},
+                         cleanup=True,
+                         acesCTLReleaseDir=None,
+                         minValue=0.0,
+                         maxValue=1.0):
+    # print(lutPath)
+    # print(ctlPaths)
 
     lutPathBase = os.path.splitext(lutPath)[0]
 
     identityLUTImageFloat = lutPathBase + ".float.tiff"
-    generate1dLUTImage(identityLUTImageFloat, lutResolution, minValue, maxValue)
+    generate1dLUTImage(identityLUTImageFloat,
+                       lutResolution,
+                       minValue,
+                       maxValue)
 
     if identityLutBitDepth != 'half':
         identityLUTImage = lutPathBase + ".uint16.tiff"
-        convertBitDepth(identityLUTImageFloat, identityLUTImage, identityLutBitDepth)
+        convertBitDepth(identityLUTImageFloat,
+                        identityLUTImage,
+                        identityLutBitDepth)
     else:
         identityLUTImage = identityLUTImageFloat
 
     transformedLUTImage = lutPathBase + ".transformed.exr"
-    applyCTLToImage(identityLUTImage, transformedLUTImage, ctlPaths, inputScale, outputScale, globalParams, acesCTLReleaseDir)
+    applyCTLToImage(identityLUTImage,
+                    transformedLUTImage,
+                    ctlPaths,
+                    inputScale,
+                    outputScale,
+                    globalParams,
+                    acesCTLReleaseDir)
 
     generate1dLUTFromImage(transformedLUTImage, lutPath, minValue, maxValue)
 
@@ -190,9 +243,10 @@ def generate1dLUTFromCTL(lutPath,
             os.remove(identityLUTImageFloat)
         os.remove(transformedLUTImage)
 
+
 def correctLUTImage(transformedLUTImage, correctedLUTImage, lutResolution):
     # open image
-    transformed = oiio.ImageInput.open( transformedLUTImage )
+    transformed = oiio.ImageInput.open(transformedLUTImage)
 
     # get image specs
     transformedSpec = transformed.spec()
@@ -203,15 +257,18 @@ def correctLUTImage(transformedLUTImage, correctedLUTImage, lutResolution):
 
     # rotate or not
     if width != lutResolution * lutResolution or height != lutResolution:
-        print( "Correcting image as resolution is off. Found %d x %d. Expected %d x %d" % (width, height, lutResolution * lutResolution, lutResolution) )
-        print( "Generating %s" % correctedLUTImage)
+        print(("Correcting image as resolution is off. "
+               "Found %d x %d. Expected %d x %d") % (
+                  width, height, lutResolution * lutResolution, lutResolution))
+        print("Generating %s" % correctedLUTImage)
 
         #
         # We're going to generate a new correct image
         #
 
         # Get the source data
-        # Force data to be read as float. The Python API doesn't handle half-floats well yet.
+        # Force data to be read as float. The Python API doesn't handle
+        # half-floats well yet.
         type = oiio.FLOAT
         sourceData = transformed.read_image(type)
 
@@ -220,59 +277,77 @@ def correctLUTImage(transformedLUTImage, correctedLUTImage, lutResolution):
 
         # set image specs
         correctSpec = oiio.ImageSpec()
-        correctSpec.set_format( oiio.FLOAT )
+        correctSpec.set_format(oiio.FLOAT)
         correctSpec.width = height
         correctSpec.height = width
         correctSpec.nchannels = channels
 
-        correct.open (correctedLUTImage, correctSpec, oiio.Create)
+        correct.open(correctedLUTImage, correctSpec, oiio.Create)
 
-        destData = array.array("f", "\0" * correctSpec.width * correctSpec.height * correctSpec.nchannels * 4)
+        destData = array.array("f",
+                               ("\0" * correctSpec.width *
+                                correctSpec.height *
+                                correctSpec.nchannels * 4))
         for j in range(0, correctSpec.height):
             for i in range(0, correctSpec.width):
                 for c in range(0, correctSpec.nchannels):
-                    #print( i, j, c )
-                    destData[correctSpec.nchannels*correctSpec.width*j + correctSpec.nchannels*i + c] = sourceData[correctSpec.nchannels*correctSpec.width*j + correctSpec.nchannels*i + c]
+                    # print(i, j, c)
+                    destData[(correctSpec.nchannels *
+                              correctSpec.width * j +
+                              correctSpec.nchannels * i + c)] = (
+                        sourceData[correctSpec.nchannels *
+                                   correctSpec.width * j +
+                                   correctSpec.nchannels * i + c])
 
         correct.write_image(correctSpec.format, destData)
         correct.close()
     else:
-        #shutil.copy(transformedLUTImage, correctedLUTImage)
+        # shutil.copy(transformedLUTImage, correctedLUTImage)
         correctedLUTImage = transformedLUTImage
 
     transformed.close()
 
     return correctedLUTImage
 
-def generate3dLUTFromCTL(lutPath, 
-    ctlPaths, 
-    lutResolution=64, 
-    identityLutBitDepth='half', 
-    inputScale=1.0,
-    outputScale=1.0, 
-    globalParams={},
-    cleanup=True,
-    acesCTLReleaseDir=None):
-    #print( lutPath )
-    #print( ctlPaths )
+
+def generate3dLUTFromCTL(lutPath,
+                         ctlPaths,
+                         lutResolution=64,
+                         identityLutBitDepth='half',
+                         inputScale=1.0,
+                         outputScale=1.0,
+                         globalParams={},
+                         cleanup=True,
+                         acesCTLReleaseDir=None):
+    # print(lutPath)
+    # print(ctlPaths)
 
     lutPathBase = os.path.splitext(lutPath)[0]
 
     identityLUTImageFloat = lutPathBase + ".float.tiff"
     generate3dLUTImage(identityLUTImageFloat, lutResolution)
 
-
     if identityLutBitDepth != 'half':
         identityLUTImage = lutPathBase + "." + identityLutBitDepth + ".tiff"
-        convertBitDepth(identityLUTImageFloat, identityLUTImage, identityLutBitDepth)
+        convertBitDepth(identityLUTImageFloat,
+                        identityLUTImage,
+                        identityLutBitDepth)
     else:
         identityLUTImage = identityLUTImageFloat
 
     transformedLUTImage = lutPathBase + ".transformed.exr"
-    applyCTLToImage(identityLUTImage, transformedLUTImage, ctlPaths, inputScale, outputScale, globalParams, acesCTLReleaseDir)
+    applyCTLToImage(identityLUTImage,
+                    transformedLUTImage,
+                    ctlPaths,
+                    inputScale,
+                    outputScale,
+                    globalParams,
+                    acesCTLReleaseDir)
 
     correctedLUTImage = lutPathBase + ".correct.exr"
-    correctedLUTImage = correctLUTImage(transformedLUTImage, correctedLUTImage, lutResolution)    
+    correctedLUTImage = correctLUTImage(transformedLUTImage,
+                                        correctedLUTImage,
+                                        lutResolution)
 
     generate3dLUTFromImage(correctedLUTImage, lutPath, lutResolution)
 
@@ -283,15 +358,17 @@ def generate3dLUTFromCTL(lutPath,
         os.remove(transformedLUTImage)
         if correctedLUTImage != transformedLUTImage:
             os.remove(correctedLUTImage)
-        #os.remove(correctedLUTImage)
+            # os.remove(correctedLUTImage)
+
 
 def main():
     import optparse
 
-    p = optparse.OptionParser(description='A utility to generate LUTs from CTL',
-                                prog='generateLUT',
-                                version='0.01',
-                                usage='%prog [options]')
+    p = optparse.OptionParser(
+        description='A utility to generate LUTs from CTL',
+        prog='generateLUT',
+        version='0.01',
+        usage='%prog [options]')
 
     p.add_option('--lut', '-l', type="string", default="")
     p.add_option('--ctl', '-c', type="string", action="append")
@@ -304,7 +381,8 @@ def main():
     p.add_option('--maxValue', '', type="float", default=1.0)
     p.add_option('--inputScale', '', type="float", default=1.0)
     p.add_option('--outputScale', '', type="float", default=1.0)
-    p.add_option('--ctlRenderParam', '-p', type="string", nargs=2, action="append")
+    p.add_option('--ctlRenderParam', '-p', type="string", nargs=2,
+                 action="append")
 
     p.add_option('--generate1d', '', action="store_true")
     p.add_option('--generate3d', '', action="store_true")
@@ -337,57 +415,59 @@ def main():
         argsStart = sys.argv.index('--') + 1
         args = sys.argv[argsStart:]
     except:
-        argsStart = len(sys.argv)+1
+        argsStart = len(sys.argv) + 1
         args = []
 
-    #print( "command line : \n%s\n" % " ".join(sys.argv) )
+    # print("command line : \n%s\n" % " ".join(sys.argv))
 
     #
     # Generate LUTs
     #
     if generate1d:
-        print( "1D LUT generation options")
+        print("1D LUT generation options")
     else:
-        print( "3D LUT generation options")
-
-    print( "lut                 : %s" % lut )
-    print( "ctls                : %s" % ctls )
-    print( "lut res 1d          : %s" % lutResolution1d )
-    print( "lut res 3d          : %s" % lutResolution3d )
-    print( "min value           : %s" % minValue )
-    print( "max value           : %s" % maxValue )
-    print( "input scale         : %s" % inputScale )
-    print( "output scale        : %s" % outputScale )
-    print( "ctl render params   : %s" % params )
-    print( "ctl release path    : %s" % ctlReleasePath )
-    print( "bit depth of input  : %s" % bitDepth )
-    print( "cleanup temp images : %s" % cleanup)
+        print("3D LUT generation options")
+
+    print("lut                 : %s" % lut)
+    print("ctls                : %s" % ctls)
+    print("lut res 1d          : %s" % lutResolution1d)
+    print("lut res 3d          : %s" % lutResolution3d)
+    print("min value           : %s" % minValue)
+    print("max value           : %s" % maxValue)
+    print("input scale         : %s" % inputScale)
+    print("output scale        : %s" % outputScale)
+    print("ctl render params   : %s" % params)
+    print("ctl release path    : %s" % ctlReleasePath)
+    print("bit depth of input  : %s" % bitDepth)
+    print("cleanup temp images : %s" % cleanup)
 
     if generate1d:
-        generate1dLUTFromCTL( lut, 
-            ctls, 
-            lutResolution1d, 
-            bitDepth, 
-            inputScale,
-            outputScale, 
-            params,
-            cleanup, 
-            ctlReleasePath,
-            minValue,
-            maxValue)
+        generate1dLUTFromCTL(lut,
+                             ctls,
+                             lutResolution1d,
+                             bitDepth,
+                             inputScale,
+                             outputScale,
+                             params,
+                             cleanup,
+                             ctlReleasePath,
+                             minValue,
+                             maxValue)
 
     elif generate3d:
-        generate3dLUTFromCTL( lut, 
-            ctls, 
-            lutResolution3d, 
-            bitDepth, 
-            inputScale,
-            outputScale, 
-            params,
-            cleanup, 
-            ctlReleasePath)
+        generate3dLUTFromCTL(lut,
+                             ctls,
+                             lutResolution3d,
+                             bitDepth,
+                             inputScale,
+                             outputScale,
+                             params,
+                             cleanup,
+                             ctlReleasePath)
     else:
-        print( "\n\nNo LUT generated. You must choose either 1D or 3D LUT generation\n\n")
+        print(("\n\nNo LUT generated. "
+               "You must choose either 1D or 3D LUT generation\n\n"))
+
 # main
 
 if __name__ == '__main__':
index 766a5c8..76213c3 100755 (executable)
@@ -1,36 +1,51 @@
 #!/usr/bin/env python\r
 # -*- coding: utf-8 -*-\r
 \r
-'''A process wrapper class that maintains the text output and execution status of a process\r
-or a list of other process wrappers which carry such data.'''\r
+"""\r
+A process wrapper class that maintains the text output and execution status\r
+of a process or a list of other process wrappers which carry such data.\r
+"""\r
 \r
 import os\r
 import sys\r
 import traceback\r
 \r
+\r
 def readText(textFile):\r
-    if( textFile != "" ):\r
+    if (textFile != ""):\r
         fp = open(textFile, 'rb')\r
         # Create a text/plain message\r
         text = (fp.read())\r
         fp.close()\r
     return text\r
+\r
+\r
 # readText\r
 \r
 def writeText(text, textFile):\r
-    if( textFile != "" ):\r
+    if (textFile != ""):\r
         fp = open(textFile, 'wb')\r
         # Create a text/plain message\r
         fp.write(text)\r
         fp.close()\r
     return text\r
+\r
+\r
 # readText\r
 \r
 class Process:\r
-    "A process with logged output"\r
-\r
-    def __init__(self, description=None, cmd=None, args=[], cwd=None, env=None, batchWrapper=False):\r
-        "Initialize the standard class variables"\r
+    """\r
+    A process with logged output\r
+    """\r
+\r
+    def __init__(self,\r
+                 description=None,\r
+                 cmd=None,\r
+                 args=[],\r
+                 cwd=None,\r
+                 env=None,\r
+                 batchWrapper=False):\r
+        """Initialize the standard class variables"""\r
         self.cmd = cmd\r
         if not description:\r
             self.description = cmd\r
@@ -46,31 +61,37 @@ class Process:
         self.env = env\r
         self.batchWrapper = batchWrapper\r
         self.processKeys = []\r
+\r
     # __init__\r
 \r
     def getElapsedSeconds(self):\r
         import math\r
+\r
         if self.end and self.start:\r
             delta = (self.end - self.start)\r
-            formatted = "%s.%s" % (delta.days * 86400 + delta.seconds, int(math.floor(delta.microseconds/1e3)))\r
+            formatted = "%s.%s" % (delta.days * 86400 + delta.seconds,\r
+                                   int(math.floor(delta.microseconds / 1e3)))\r
         else:\r
             formatted = None\r
         return formatted\r
+\r
     # getElapsedtime\r
 \r
     def writeKey(self, writeDict, key=None, value=None, startStop=None):\r
         "Write a key, value pair in a supported format"\r
         if key != None and (value != None or startStop != None):\r
-            indent = '\t'*writeDict['indentationLevel']\r
+            indent = '\t' * writeDict['indentationLevel']\r
             if writeDict['format'] == 'xml':\r
                 if startStop == 'start':\r
-                    writeDict['logHandle'].write( "%s<%s>\n" % (indent, key) )\r
+                    writeDict['logHandle'].write("%s<%s>\n" % (indent, key))\r
                 elif startStop == 'stop':\r
-                    writeDict['logHandle'].write( "%s</%s>\n" % (indent, key) )\r
+                    writeDict['logHandle'].write("%s</%s>\n" % (indent, key))\r
                 else:\r
-                    writeDict['logHandle'].write( "%s<%s>%s</%s>\n" % (indent, key, value, key) )\r
-            else: # writeDict['format'] == 'txt':\r
-                writeDict['logHandle'].write( "%s%40s : %s\n" % (indent, key, value) )\r
+                    writeDict['logHandle'].write(\r
+                        "%s<%s>%s</%s>\n" % (indent, key, value, key))\r
+            else:  # writeDict['format'] == 'txt':\r
+                writeDict['logHandle'].write(\r
+                    "%s%40s : %s\n" % (indent, key, value))\r
 \r
     def writeLogHeader(self, writeDict):\r
         import platform\r
@@ -87,111 +108,123 @@ class Process:
             except:\r
                 user = "unknown_user"\r
         try:\r
-            (sysname, nodename, release, version, machine, processor) = platform.uname()\r
+            (sysname, nodename, release, version, machine,\r
+             processor) = platform.uname()\r
         except:\r
-            (sysname, nodename, release, version, machine, processor) = ("unknown_sysname", "unknown_nodename", "unknown_release", "unknown_version", "unknown_machine", "unknown_processor")\r
+            (sysname, nodename, release, version, machine, processor) = (\r
+                "unknown_sysname", "unknown_nodename", "unknown_release",\r
+                "unknown_version", "unknown_machine", "unknown_processor")\r
         try:\r
             hostname = platform.node()\r
         except:\r
             hostname = "unknown_hostname"\r
 \r
-        self.writeKey(writeDict, 'process', None, 'start' )\r
+        self.writeKey(writeDict, 'process', None, 'start')\r
         writeDict['indentationLevel'] += 1\r
 \r
-        self.writeKey(writeDict, 'description', self.description )\r
-        self.writeKey(writeDict, 'cmd', self.cmd )\r
-        if self.args: self.writeKey(writeDict, 'args', ' '.join(self.args) )\r
-        self.writeKey(writeDict, 'start', self.start )\r
-        self.writeKey(writeDict, 'end', self.end )\r
-        self.writeKey(writeDict, 'elapsed', self.getElapsedSeconds() )\r
-\r
-        self.writeKey(writeDict, 'user', user )\r
-        self.writeKey(writeDict, 'sysname', sysname )\r
-        self.writeKey(writeDict, 'nodename', nodename )\r
-        self.writeKey(writeDict, 'release', release )\r
-        self.writeKey(writeDict, 'version', version )\r
-        self.writeKey(writeDict, 'machine', machine )\r
-        self.writeKey(writeDict, 'processor', processor )\r
+        self.writeKey(writeDict, 'description', self.description)\r
+        self.writeKey(writeDict, 'cmd', self.cmd)\r
+        if self.args: self.writeKey(writeDict, 'args', ' '.join(self.args))\r
+        self.writeKey(writeDict, 'start', self.start)\r
+        self.writeKey(writeDict, 'end', self.end)\r
+        self.writeKey(writeDict, 'elapsed', self.getElapsedSeconds())\r
+\r
+        self.writeKey(writeDict, 'user', user)\r
+        self.writeKey(writeDict, 'sysname', sysname)\r
+        self.writeKey(writeDict, 'nodename', nodename)\r
+        self.writeKey(writeDict, 'release', release)\r
+        self.writeKey(writeDict, 'version', version)\r
+        self.writeKey(writeDict, 'machine', machine)\r
+        self.writeKey(writeDict, 'processor', processor)\r
 \r
         if len(self.processKeys) > 0:\r
-            self.writeKey(writeDict, 'processKeys', None, 'start' )\r
+            self.writeKey(writeDict, 'processKeys', None, 'start')\r
             for pair in self.processKeys:\r
                 (key, value) = pair\r
                 writeDict['indentationLevel'] += 1\r
-                self.writeKey(writeDict, key, value )\r
+                self.writeKey(writeDict, key, value)\r
                 writeDict['indentationLevel'] -= 1\r
-            self.writeKey(writeDict, 'processKeys', None, 'stop' )\r
+            self.writeKey(writeDict, 'processKeys', None, 'stop')\r
+\r
+        self.writeKey(writeDict, 'status', self.status)\r
 \r
-        self.writeKey(writeDict, 'status', self.status )\r
     # writeLogHeader\r
 \r
     def writeLogFooter(self, writeDict):\r
         writeDict['indentationLevel'] -= 1\r
-        self.writeKey(writeDict, 'process', None, 'stop' )\r
+        self.writeKey(writeDict, 'process', None, 'stop')\r
+\r
     # writeLogFooter\r
 \r
-    def writeLog(self, logHandle=sys.stdout, indentationLevel=0,format='xml'):\r
-        "Write logging information to the specified handle"\r
-        \r
+    def writeLog(self, logHandle=sys.stdout, indentationLevel=0, format='xml'):\r
+        """\r
+        Write logging information to the specified handle\r
+        """\r
+\r
         writeDict = {}\r
         writeDict['logHandle'] = logHandle\r
         writeDict['indentationLevel'] = indentationLevel\r
         writeDict['format'] = format\r
-        \r
+\r
         if logHandle:\r
             self.writeLogHeader(writeDict)\r
-            \r
+\r
             if self.log:\r
-                self.writeKey(writeDict, 'output', None, 'start' )\r
+                self.writeKey(writeDict, 'output', None, 'start')\r
                 if format == 'xml':\r
-                    logHandle.write( "<![CDATA[\n" )\r
+                    logHandle.write("<![CDATA[\n")\r
                 for line in self.log:\r
-                    logHandle.write( '%s%s\n' % ("", line) )\r
+                    logHandle.write('%s%s\n' % ("", line))\r
                 if format == 'xml':\r
-                    logHandle.write( "]]>\n" )\r
-                self.writeKey(writeDict, 'output', None, 'stop' )\r
+                    logHandle.write("]]>\n")\r
+                self.writeKey(writeDict, 'output', None, 'stop')\r
 \r
             self.writeLogFooter(writeDict)\r
+\r
     # writeLog\r
 \r
     def writeLogToDisk(self, logFilename=None, format='xml', header=None):\r
-        if logFilename: \r
+        if logFilename:\r
             try:\r
                 # This also doesn't seem like the best structure...\r
                 # 3.1\r
                 try:\r
-                    logHandle = open( logFilename, mode='wt', encoding="utf-8")\r
+                    logHandle = open(logFilename, mode='wt', encoding="utf-8")\r
                 # 2.6\r
                 except:\r
-                    logHandle = open( logFilename, mode='wt')\r
+                    logHandle = open(logFilename, mode='wt')\r
             except:\r
-                print( "Couldn't open log : %s" % logFilename )\r
+                print("Couldn't open log : %s" % logFilename)\r
                 logHandle = None\r
 \r
         if logHandle:\r
             if header:\r
                 if format == 'xml':\r
-                    logHandle.write( "<![CDATA[\n" )\r
-                logHandle.write( header )\r
+                    logHandle.write("<![CDATA[\n")\r
+                logHandle.write(header)\r
                 if format == 'xml':\r
-                    logHandle.write( "]]>\n" )\r
+                    logHandle.write("]]>\n")\r
             self.writeLog(logHandle)\r
             logHandle.close()\r
+\r
     # writeLogToDisk\r
 \r
     def logLine(self, line):\r
         "Add a line of text to the log"\r
-        self.log.append( line.rstrip() )\r
+        self.log.append(line.rstrip())\r
         if self.echo:\r
-            print( "%s" % line.rstrip() )\r
+            print("%s" % line.rstrip())\r
+\r
     # logLine\r
 \r
     def execute(self):\r
-        "Execute this process"\r
+        """\r
+        Execute this process\r
+        """\r
         import re\r
         import datetime\r
         import traceback\r
-        \r
+\r
         try:\r
             import subprocess as sp\r
         except:\r
@@ -201,12 +234,13 @@ class Process:
 \r
         cmdargs = [self.cmd]\r
         cmdargs.extend(self.args)\r
-        \r
+\r
         if self.echo:\r
             if sp:\r
-                print( "\n%s : %s\n" % (self.__class__, sp.list2cmdline(cmdargs)) )\r
+                print(\r
+                    "\n%s : %s\n" % (self.__class__, sp.list2cmdline(cmdargs)))\r
             else:\r
-                print( "\n%s : %s\n" % (self.__class__, " ".join(cmdargs)) )\r
+                print("\n%s : %s\n" % (self.__class__, " ".join(cmdargs)))\r
 \r
         # intialize a few variables that may or may not be set later\r
         process = None\r
@@ -223,37 +257,41 @@ class Process:
                     cmd = " ".join(cmdargs)\r
                     tmpWrapper = os.path.join(self.cwd, "process.bat")\r
                     writeText(cmd, tmpWrapper)\r
-                    print( "%s : Running process through wrapper %s\n" % (self.__class__, tmpWrapper) )\r
-                    process = sp.Popen([tmpWrapper], stdout=sp.PIPE, stderr=sp.STDOUT, \r
-                        cwd=self.cwd, env=self.env)\r
+                    print("%s : Running process through wrapper %s\n" % (\r
+                        self.__class__, tmpWrapper))\r
+                    process = sp.Popen([tmpWrapper], stdout=sp.PIPE,\r
+                                       stderr=sp.STDOUT,\r
+                                       cwd=self.cwd, env=self.env)\r
                 else:\r
-                    process = sp.Popen(cmdargs, stdout=sp.PIPE, stderr=sp.STDOUT, \r
-                        cwd=self.cwd, env=self.env)\r
+                    process = sp.Popen(cmdargs, stdout=sp.PIPE,\r
+                                       stderr=sp.STDOUT,\r
+                                       cwd=self.cwd, env=self.env)\r
 \r
             # using os.popen4\r
             else:\r
                 if self.env:\r
                     os.environ = self.env\r
                 if self.cwd:\r
-                    os.chdir( self.cwd )\r
-                \r
-                stdin, stdout = os.popen4( cmdargs, 'r')\r
+                    os.chdir(self.cwd)\r
+\r
+                stdin, stdout = os.popen4(cmdargs, 'r')\r
         except:\r
-            print( "Couldn't execute command : %s" % cmdargs[0] )\r
+            print("Couldn't execute command : %s" % cmdargs[0])\r
             traceback.print_exc()\r
 \r
         # Using subprocess\r
         if sp:\r
             if process != None:\r
-                #pid = process.pid\r
-                #log.logLine( "process id %s\n" % pid )\r
+                # pid = process.pid\r
+                # log.logLine("process id %s\n" % pid)\r
 \r
                 try:\r
-                    # This is more proper python, and resolves some issues with a process ending before all\r
-                    #  of its output has been processed, but it also seems to stall when the read buffer\r
-                    #  is near or over it's limit. this happens relatively frequently with processes\r
-                    #  that generate lots of print statements.\r
-                    #\r
+                    # This is more proper python, and resolves some issues with\r
+                    # a process ending before all of its output has been\r
+                    # processed, but it also seems to stall when the read\r
+                    # buffer is near or over it's limit. this happens\r
+                    # relatively frequently with processes that generate lots\r
+                    # of print statements.\r
                     for line in process.stdout:\r
                         self.logLine(line)\r
                     #\r
@@ -268,27 +306,27 @@ class Process:
                             break\r
                         # 3.1\r
                         try:\r
-                            self.logLine( str(line, encoding="utf-8") )\r
+                            self.logLine(str(line, encoding="utf-8"))\r
                         # 2.6\r
                         except:\r
-                            self.logLine( line )\r
+                            self.logLine(line)\r
                 except:\r
-                    self.logLine( "Logging error : %s" % sys.exc_info()[0] )\r
+                    self.logLine("Logging error : %s" % sys.exc_info()[0])\r
 \r
                 self.status = process.returncode\r
-                \r
+\r
                 if self.batchWrapper and tmpWrapper:\r
                     try:\r
                         os.remove(tmpWrapper)\r
                     except:\r
-                        print( "Couldn't remove temp wrapper : %s" % tmpWrapper )\r
+                        print("Couldn't remove temp wrapper : %s" % tmpWrapper)\r
                         traceback.print_exc()\r
 \r
         # Using os.popen4\r
         else:\r
             exitCode = -1\r
             try:\r
-                #print( "reading stdout lines" )\r
+                # print("reading stdout lines")\r
                 stdoutLines = stdout.readlines()\r
                 exitCode = stdout.close()\r
 \r
@@ -298,54 +336,63 @@ class Process:
                 if self.env:\r
                     os.environ = parentenv\r
                 if self.cwd:\r
-                    os.chdir( parentcwd )\r
-                \r
-                if len( stdoutLines ) > 0:\r
+                    os.chdir(parentcwd)\r
+\r
+                if len(stdoutLines) > 0:\r
                     for line in stdoutLines:\r
                         self.logLine(line)\r
 \r
                 if not exitCode:\r
                     exitCode = 0\r
             except:\r
-                self.logLine( "Logging error : %s" % sys.exc_info()[0] )\r
+                self.logLine("Logging error : %s" % sys.exc_info()[0])\r
 \r
             self.status = exitCode\r
-            \r
+\r
         self.end = datetime.datetime.now()\r
-    #execute\r
+        # execute\r
+\r
+\r
 # Process\r
 \r
 class ProcessList(Process):\r
-    "A list of processes with logged output"\r
+    """\r
+    A list of processes with logged output\r
+    """\r
 \r
     def __init__(self, description, blocking=True, cwd=None, env=None):\r
         Process.__init__(self, description, None, None, cwd, env)\r
         "Initialize the standard class variables"\r
         self.processes = []\r
         self.blocking = blocking\r
+\r
     # __init__\r
 \r
     def generateReport(self, writeDict):\r
-        "Generate a log based on the success of the child processes"\r
+        """\r
+        Generate a log based on the success of the child processes\r
+        """\r
         if self.processes:\r
             _status = True\r
-            indent = '\t'*(writeDict['indentationLevel']+1)\r
-            \r
+            indent = '\t' * (writeDict['indentationLevel'] + 1)\r
+\r
             self.log = []\r
-            \r
+\r
             for child in self.processes:\r
                 if isinstance(child, ProcessList):\r
                     child.generateReport(writeDict)\r
-                \r
+\r
                 childResult = ""\r
                 key = child.description\r
                 value = child.status\r
                 if writeDict['format'] == 'xml':\r
-                    childResult = ( "%s<result description=\"%s\">%s</result>" % (indent, key, value) )\r
-                else: # writeDict['format'] == 'txt':\r
-                    childResult = ( "%s%40s : %s" % (indent, key, value) )\r
-                self.log.append( childResult )\r
-                \r
+                    childResult = (\r
+                        "%s<result description=\"%s\">%s</result>" % (\r
+                            indent, key, value))\r
+                else:  # writeDict['format'] == 'txt':\r
+                    childResult = ("%s%40s : %s" % (indent, key, value))\r
+                self.log.append(childResult)\r
+\r
                 if child.status != 0:\r
                     _status = False\r
             if not _status:\r
@@ -357,52 +404,59 @@ class ProcessList(Process):
             self.status = -1\r
 \r
     def writeLogHeader(self, writeDict):\r
-        self.writeKey(writeDict, 'processList', None, 'start' )\r
+        self.writeKey(writeDict, 'processList', None, 'start')\r
         writeDict['indentationLevel'] += 1\r
 \r
-        self.writeKey(writeDict, 'description', self.description )\r
-        self.writeKey(writeDict, 'start', self.start )\r
-        self.writeKey(writeDict, 'end', self.end )\r
-        self.writeKey(writeDict, 'elapsed', self.getElapsedSeconds() )\r
+        self.writeKey(writeDict, 'description', self.description)\r
+        self.writeKey(writeDict, 'start', self.start)\r
+        self.writeKey(writeDict, 'end', self.end)\r
+        self.writeKey(writeDict, 'elapsed', self.getElapsedSeconds())\r
 \r
         self.generateReport(writeDict)\r
 \r
-        self.writeKey(writeDict, 'status', self.status )\r
+        self.writeKey(writeDict, 'status', self.status)\r
+\r
     # writeLogHeader\r
 \r
     def writeLogFooter(self, writeDict):\r
         writeDict['indentationLevel'] -= 1\r
-        self.writeKey(writeDict, 'processList', None, 'stop' )\r
+        self.writeKey(writeDict, 'processList', None, 'stop')\r
+\r
     # writeLogFooter\r
 \r
-    def writeLog(self, logHandle=sys.stdout, indentationLevel=0,format='xml'):\r
-        "Write logging information to the specified handle"\r
-        \r
+    def writeLog(self, logHandle=sys.stdout, indentationLevel=0, format='xml'):\r
+        """\r
+        Write logging information to the specified handle\r
+        """\r
+\r
         writeDict = {}\r
         writeDict['logHandle'] = logHandle\r
         writeDict['indentationLevel'] = indentationLevel\r
         writeDict['format'] = format\r
-        \r
+\r
         if logHandle:\r
             self.writeLogHeader(writeDict)\r
-            \r
+\r
             if self.log:\r
-                self.writeKey(writeDict, 'output', None, 'start' )\r
+                self.writeKey(writeDict, 'output', None, 'start')\r
                 for line in self.log:\r
-                    logHandle.write( '%s%s\n' % ("", line) )\r
-                self.writeKey(writeDict, 'output', None, 'stop' )\r
+                    logHandle.write('%s%s\n' % ("", line))\r
+                self.writeKey(writeDict, 'output', None, 'stop')\r
 \r
             if self.processes:\r
-                self.writeKey(writeDict, 'processes', None, 'start' )\r
+                self.writeKey(writeDict, 'processes', None, 'start')\r
                 for child in self.processes:\r
-                    child.writeLog( logHandle, indentationLevel + 1, format )\r
-                self.writeKey(writeDict, 'processes', None, 'stop' )\r
+                    child.writeLog(logHandle, indentationLevel + 1, format)\r
+                self.writeKey(writeDict, 'processes', None, 'stop')\r
 \r
             self.writeLogFooter(writeDict)\r
+\r
     # writeLog\r
 \r
     def execute(self):\r
-        "Execute this list of processes"\r
+        """\r
+        Execute this list of processes\r
+        """\r
         import datetime\r
 \r
         self.start = datetime.datetime.now()\r
@@ -414,26 +468,31 @@ class ProcessList(Process):
                     try:\r
                         child.execute()\r
                     except:\r
-                        print( "%s : caught exception in child class %s" % (self.__class__, child.__class__) )\r
+                        print("%s : caught exception in child class %s" % (\r
+                            self.__class__, child.__class__))\r
                         traceback.print_exc()\r
                         child.status = -1\r
 \r
                     if self.blocking and child.status != 0:\r
-                        print( "%s : child class %s finished with an error" % (self.__class__, child.__class__) )\r
+                        print("%s : child class %s finished with an error" % (\r
+                            self.__class__, child.__class__))\r
                         self.status = -1\r
                         break\r
 \r
         self.end = datetime.datetime.now()\r
-    # execute\r
+        # execute\r
+\r
+\r
 # ProcessList\r
 \r
 def main():\r
     import optparse\r
 \r
     p = optparse.OptionParser(description='A process logging script',\r
-                                prog='process',\r
-                                version='process 0.1',\r
-                                usage='%prog [options] [options for the logged process]')\r
+                              prog='process',\r
+                              version='process 0.1',\r
+                              usage=('%prog [options] '\r
+                                     '[options for the logged process]'))\r
     p.add_option('--cmd', '-c', default=None)\r
     p.add_option('--log', '-l', default=None)\r
 \r
@@ -449,26 +508,27 @@ def main():
         argsStart = sys.argv.index('--') + 1\r
         args = sys.argv[argsStart:]\r
     except:\r
-        argsStart = len(sys.argv)+1\r
+        argsStart = len(sys.argv) + 1\r
         args = []\r
 \r
     if cmd == None:\r
-        print( "process: No command specified" )\r
\r
+        print("process: No command specified")\r
+\r
     #\r
     # Test regular logging\r
     #\r
-    process = Process(description="a process",cmd=cmd, args=args)\r
+    process = Process(description="a process", cmd=cmd, args=args)\r
 \r
     #\r
     # Test report generation and writing a log\r
     #\r
     processList = ProcessList("a process list")\r
-    processList.processes.append( process )\r
+    processList.processes.append(process)\r
     processList.echo = True\r
     processList.execute()\r
-    \r
+\r
     processList.writeLogToDisk(logFilename)\r
+\r
 # main\r
 \r
 if __name__ == '__main__':\r
index fde3ef6..84b43e9 100644 (file)
@@ -10,37 +10,43 @@ import PyOpenColorIO as OCIO
 # Utility classes and functions
 #
 class ColorSpace:
-    "A container for data needed to define an OCIO 'Color Space' "
+    """
+    A container for data needed to define an OCIO 'Color Space'
+    """
 
     def __init__(self,
-        name,
-        description=None,
-        bitDepth=OCIO.Constants.BIT_DEPTH_F32,
-        equalityGroup=None,
-        family=None,
-        isData=False,
-        toReferenceTransforms=[],
-        fromReferenceTransforms=[],
-        allocationType=OCIO.Constants.ALLOCATION_UNIFORM,
-        allocationVars=[0.0, 1.0]):
-        "Initialize the standard class variables"
+                 name,
+                 description=None,
+                 bitDepth=OCIO.Constants.BIT_DEPTH_F32,
+                 equalityGroup=None,
+                 family=None,
+                 isData=False,
+                 toReferenceTransforms=[],
+                 fromReferenceTransforms=[],
+                 allocationType=OCIO.Constants.ALLOCATION_UNIFORM,
+                 allocationVars=[0.0, 1.0]):
+        """
+        Initialize the standard class variables
+        """
         self.name = name
-        self.bitDepth=bitDepth
+        self.bitDepth = bitDepth
         self.description = description
-        self.equalityGroup=equalityGroup
-        self.family=family
-        self.isData=isData
-        self.toReferenceTransforms=toReferenceTransforms
-        self.fromReferenceTransforms=fromReferenceTransforms
-        self.allocationType=allocationType
-        self.allocationVars=allocationVars
+        self.equalityGroup = equalityGroup
+        self.family = family
+        self.isData = isData
+        self.toReferenceTransforms = toReferenceTransforms
+        self.fromReferenceTransforms = fromReferenceTransforms
+        self.allocationType = allocationType
+        self.allocationVars = allocationVars
+
 
 # Create a 4x4 matrix (list) based on a 3x3 matrix (list) input
 def mat44FromMat33(mat33):
     return [mat33[0], mat33[1], mat33[2], 0.0,
             mat33[3], mat33[4], mat33[5], 0.0,
             mat33[6], mat33[7], mat33[8], 0.0,
-            0,0,0,1.0]
+            0, 0, 0, 1.0]
+
 
 # TODO: Worth moving to *util.py*.
 def filter_words(words, filters_in=None, filters_out=None, flags=0):