Skip to content

Commit

Permalink
refactor: renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino committed Dec 9, 2024
1 parent d4e242c commit 4c6f317
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cognite_toolkit/_cdf_tk/data_classes/_build_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,18 @@ def get_module_variables(self, module: ModuleLocation) -> list[BuildVariables]:
def replace(self, content: str, file_suffix: str = ".yaml") -> str:
for variable in self:
replace = variable.value_variable
_core_patter = rf"{{{{\s*{variable.key}\s*}}}}"
_core_pattern = rf"{{{{\s*{variable.key}\s*}}}}"
if file_suffix in {".yaml", ".yml", ".json"}:
# Preserve data types
pattern = _core_patter
pattern = _core_pattern
if isinstance(replace, str) and (replace.isdigit() or replace.endswith(":")):
replace = f'"{replace}"'
pattern = rf"'{_core_patter}'|{_core_patter}|" + rf'"{_core_patter}"'
pattern = rf"'{_core_pattern}'|{_core_pattern}|" + rf'"{_core_pattern}"'
elif replace is None:
replace = "null"
content = re.sub(pattern, str(replace), content)
else:
content = re.sub(_core_patter, str(replace), content)
content = re.sub(_core_pattern, str(replace), content)

return content

Expand Down

0 comments on commit 4c6f317

Please sign in to comment.