2 # -*- coding: utf-8 -*-
5 Defines various package utilities objects.
11 import PyOpenColorIO as OCIO
13 __author__ = 'ACES Developers'
14 __copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers'
16 __maintainer__ = 'ACES Developers'
17 __email__ = 'aces@oscars.org'
18 __status__ = 'Production'
20 __all__ = ['ColorSpace',
26 # Utility classes and functions
29 class ColorSpace(object):
31 A container for data needed to define an *OCIO* *ColorSpace*.
37 bit_depth=OCIO.Constants.BIT_DEPTH_F32,
41 to_reference_transforms=[],
42 from_reference_transforms=[],
43 allocation_type=OCIO.Constants.ALLOCATION_UNIFORM,
44 allocation_vars=[0.0, 1.0]):
51 Parameter description.
56 Return value description.
60 self.bit_depth = bit_depth
61 self.description = description
62 self.equality_group = equality_group
64 self.is_data = is_data
65 self.to_reference_transforms = to_reference_transforms
66 self.from_reference_transforms = from_reference_transforms
67 self.allocation_type = allocation_type
68 self.allocation_vars = allocation_vars
71 def mat44_from_mat33(mat33):
73 Creates a 4x4 matrix from given 3x3 matrix.
78 Parameter description.
83 Return value description.
86 return [mat33[0], mat33[1], mat33[2], 0.0,
87 mat33[3], mat33[4], mat33[5], 0.0,
88 mat33[6], mat33[7], mat33[8], 0.0,
92 def filter_words(words, filters_in=None, filters_out=None, flags=0):
99 Parameter description.
104 Return value description.
110 filter_matched = False
111 for filter in filters_in:
112 if re.search(filter, word, flags):
113 filter_matched = True
115 if not filter_matched:
119 filter_matched = False
120 for filter in filters_out:
121 if re.search(filter, word, flags):
122 filter_matched = True
126 filtered_words.append(word)
127 return filtered_words
130 def files_walker(directory, filters_in=None, filters_out=None, flags=0):
137 Parameter description.
142 Return value description.
145 for parent_directory, directories, files in os.walk(directory,
149 path = os.path.join(parent_directory, file)
150 if os.path.isfile(path):
151 if not filter_words((path,), filters_in, filters_out, flags):