Replaces template variables like {{SOME}} in the string using the dictionary values.
(string, dictionary)
| 179 | |
| 180 | |
| 181 | def replace_template_vars(string, dictionary): |
| 182 | """Replaces template variables like {{SOME}} in the string |
| 183 | using the dictionary values.""" |
| 184 | orig_string = string |
| 185 | for key, value in dictionary.items(): |
| 186 | string = string.replace("{{"+key+"}}", value) |
| 187 | if string == orig_string: |
| 188 | raise Exception("Nothing to format") |
| 189 | if re.search(r"{{[a-zA-Z0-9_]+}}", string): |
| 190 | raise Exception("Not all strings were formatted") |
| 191 | return string |
| 192 | |
| 193 | |
| 194 | def perform_copy_operations(operations): |
no outgoing calls
no test coverage detected