2 # -*- coding: utf-8 -*-
7 import PyOpenColorIO as OCIO
10 # Utility classes and functions
14 A container for data needed to define an OCIO 'Color Space'
20 bitDepth=OCIO.Constants.BIT_DEPTH_F32,
24 toReferenceTransforms=[],
25 fromReferenceTransforms=[],
26 allocationType=OCIO.Constants.ALLOCATION_UNIFORM,
27 allocationVars=[0.0, 1.0]):
29 Initialize the standard class variables
32 self.bitDepth = bitDepth
33 self.description = description
34 self.equalityGroup = equalityGroup
37 self.toReferenceTransforms = toReferenceTransforms
38 self.fromReferenceTransforms = fromReferenceTransforms
39 self.allocationType = allocationType
40 self.allocationVars = allocationVars
43 # Create a 4x4 matrix (list) based on a 3x3 matrix (list) input
44 def mat44FromMat33(mat33):
45 return [mat33[0], mat33[1], mat33[2], 0.0,
46 mat33[3], mat33[4], mat33[5], 0.0,
47 mat33[6], mat33[7], mat33[8], 0.0,
51 # TODO: Worth moving to *util.py*.
52 def filter_words(words, filters_in=None, filters_out=None, flags=0):
59 filter_matched = False
60 for filter in filters_in:
61 if re.search(filter, word, flags):
64 if not filter_matched:
68 filter_matched = False
69 for filter in filters_out:
70 if re.search(filter, word, flags):
75 filtered_words.append(word)
79 def files_walker(directory, filters_in=None, filters_out=None, flags=0):
83 for parent_directory, directories, files in os.walk(directory,
87 path = os.path.join(parent_directory, file)
88 if os.path.isfile(path):
89 if not filter_words((path,), filters_in, filters_out, flags):