MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / configure_file

Function configure_file

share/docs/configure_file.py:110–161  ·  view source on GitHub ↗

Substitute common @ @ variables in the given file. Support for each substitution must be added explicitly.

(src_filename, dst_filename)

Source from the content-addressed store, hash-verified

108
109
110def configure_file(src_filename, dst_filename):
111 """
112 Substitute common @<var>@ variables in the given file. Support for each
113 substitution must be added explicitly.
114 """
115 logger.info("Configuring file: {} -> {}".format(src_filename, dst_filename))
116
117 # PROJECT_SOURCE_DIR
118 # PROJECT_BINARY_DIR
119 source_dir = binary_dir = ROOT
120
121 # CMAKE_PROJECT_NAME
122 name = get_project_name()
123
124 # CMAKE_PROJECT_VERSION
125 # OpenColorIO_VERSION
126 # OpenColorIO_VERSION_MAJOR
127 # OpenColorIO_VERSION_MINOR
128 # OpenColorIO_VERSION_PATCH
129 version, major, minor, patch = get_project_version()
130
131 # CMAKE_PROJECT_DESCRIPTION
132 desc = get_project_description()
133
134 # OpenColorIO_VERSION_RELEASE_TYPE
135 release_type = get_ocio_version_release_type()
136
137 # OCIO_NAMESPACE
138 namespace = get_ocio_namespace(
139 major=major,
140 minor=minor,
141 release_type=release_type
142 )
143
144 with open(src_filename, "r") as f:
145 data = f.read()
146
147 data = data\
148 .replace("@PROJECT_SOURCE_DIR@", source_dir)\
149 .replace("@PROJECT_BINARY_DIR@", binary_dir)\
150 .replace("@CMAKE_PROJECT_NAME@", name)\
151 .replace("@CMAKE_PROJECT_VERSION@", version)\
152 .replace("@CMAKE_PROJECT_DESCRIPTION@", desc)\
153 .replace("@OpenColorIO_VERSION@", version)\
154 .replace("@OpenColorIO_VERSION_MAJOR@", major)\
155 .replace("@OpenColorIO_VERSION_MINOR@", minor)\
156 .replace("@OpenColorIO_VERSION_PATCH@", patch)\
157 .replace("@OpenColorIO_VERSION_RELEASE_TYPE@", release_type)\
158 .replace("@OCIO_NAMESPACE@", namespace)
159
160 with open(dst_filename, "w") as f:
161 f.write(data)

Callers

nothing calls this directly

Calls 8

get_project_nameFunction · 0.85
get_project_versionFunction · 0.85
get_project_descriptionFunction · 0.85
get_ocio_namespaceFunction · 0.85
formatMethod · 0.45
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected