2 # -*- coding: utf-8 -*-
7 import PyOpenColorIO as OCIO
10 # Utility classes and functions
13 "A container for data needed to define an OCIO 'Color Space' "
18 bitDepth=OCIO.Constants.BIT_DEPTH_F32,
22 toReferenceTransforms=[],
23 fromReferenceTransforms=[],
24 allocationType=OCIO.Constants.ALLOCATION_UNIFORM,
25 allocationVars=[0.0, 1.0]):
26 "Initialize the standard class variables"
28 self.bitDepth=bitDepth
29 self.description = description
30 self.equalityGroup=equalityGroup
33 self.toReferenceTransforms=toReferenceTransforms
34 self.fromReferenceTransforms=fromReferenceTransforms
35 self.allocationType=allocationType
36 self.allocationVars=allocationVars
38 # Create a 4x4 matrix (list) based on a 3x3 matrix (list) input
39 def mat44FromMat33(mat33):
40 return [mat33[0], mat33[1], mat33[2], 0.0,
41 mat33[3], mat33[4], mat33[5], 0.0,
42 mat33[6], mat33[7], mat33[8], 0.0,
45 # TODO: Worth moving to *util.py*.
46 def filter_words(words, filters_in=None, filters_out=None, flags=0):
53 filter_matched = False
54 for filter in filters_in:
55 if re.search(filter, word, flags):
58 if not filter_matched:
62 filter_matched = False
63 for filter in filters_out:
64 if re.search(filter, word, flags):
69 filtered_words.append(word)
73 def files_walker(directory, filters_in=None, filters_out=None, flags=0):
77 for parent_directory, directories, files in os.walk(directory,
81 path = os.path.join(parent_directory, file)
82 if os.path.isfile(path):
83 if not filter_words((path,), filters_in, filters_out, flags):