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',
27 class ColorSpace(object):
29 A container for data needed to define an *OCIO* *ColorSpace*.
35 bit_depth=OCIO.Constants.BIT_DEPTH_F32,
39 to_reference_transforms=[],
40 from_reference_transforms=[],
41 allocation_type=OCIO.Constants.ALLOCATION_UNIFORM,
42 allocation_vars=[0.0, 1.0]):
49 Parameter description.
54 Return value description.
58 self.bit_depth = bit_depth
59 self.description = description
60 self.equality_group = equality_group
62 self.is_data = is_data
63 self.to_reference_transforms = to_reference_transforms
64 self.from_reference_transforms = from_reference_transforms
65 self.allocation_type = allocation_type
66 self.allocation_vars = allocation_vars
69 def mat44_from_mat33(mat33):
71 Creates a 4x4 matrix from given 3x3 matrix.
76 Parameter description.
81 Return value description.
84 return [mat33[0], mat33[1], mat33[2], 0.0,
85 mat33[3], mat33[4], mat33[5], 0.0,
86 mat33[6], mat33[7], mat33[8], 0.0,
90 def filter_words(words, filters_in=None, filters_out=None, flags=0):
97 Parameter description.
102 Return value description.
108 filter_matched = False
109 for filter in filters_in:
110 if re.search(filter, word, flags):
111 filter_matched = True
113 if not filter_matched:
117 filter_matched = False
118 for filter in filters_out:
119 if re.search(filter, word, flags):
120 filter_matched = True
124 filtered_words.append(word)
125 return filtered_words
128 def files_walker(directory, filters_in=None, filters_out=None, flags=0):
135 Parameter description.
140 Return value description.
143 for parent_directory, directories, files in os.walk(directory,
147 path = os.path.join(parent_directory, file)
148 if os.path.isfile(path):
149 if not filter_words((path,), filters_in, filters_out, flags):
155 def sanitize_path(path):
162 Parameter description.
167 Return value description.
170 return path.replace(' ', '_').replace(')', '_').replace('(', '_')