4 import PyOpenColorIO as OCIO
7 # Utility classes and functions
10 "A container for data needed to define an OCIO 'Color Space' "
15 bitDepth=OCIO.Constants.BIT_DEPTH_F32,
19 toReferenceTransforms=[],
20 fromReferenceTransforms=[],
21 allocationType=OCIO.Constants.ALLOCATION_UNIFORM,
22 allocationVars=[0.0, 1.0]):
23 "Initialize the standard class variables"
25 self.bitDepth=bitDepth
26 self.description = description
27 self.equalityGroup=equalityGroup
30 self.toReferenceTransforms=toReferenceTransforms
31 self.fromReferenceTransforms=fromReferenceTransforms
32 self.allocationType=allocationType
33 self.allocationVars=allocationVars
35 # Create a 4x4 matrix (list) based on a 3x3 matrix (list) input
36 def mat44FromMat33(mat33):
37 return [mat33[0], mat33[1], mat33[2], 0.0,
38 mat33[3], mat33[4], mat33[5], 0.0,
39 mat33[6], mat33[7], mat33[8], 0.0,
42 # TODO: Worth moving to *util.py*.
43 def filter_words(words, filters_in=None, filters_out=None, flags=0):
50 filter_matched = False
51 for filter in filters_in:
52 if re.search(filter, word, flags):
55 if not filter_matched:
59 filter_matched = False
60 for filter in filters_out:
61 if re.search(filter, word, flags):
66 filtered_words.append(word)
70 def files_walker(directory, filters_in=None, filters_out=None, flags=0):
74 for parent_directory, directories, files in os.walk(directory,
78 path = os.path.join(parent_directory, file)
79 if os.path.isfile(path):
80 if not filter_words((path,), filters_in, filters_out, flags):