Substitute common @ @ variables in the given file. Support for each substitution must be added explicitly.
(src_filename, dst_filename)
| 108 | |
| 109 | |
| 110 | def 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) |
nothing calls this directly
no test coverage detected