Skip to content

Commit c03aff1

Browse files
author
Jongmin Kim
committed
refactor: refactor dict utils
Signed-off-by: Jongmin Kim <whdalsrnt@megazone.com>
1 parent 7708281 commit c03aff1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/spaceone/core/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,11 @@ def _check_condition(match_option: str, val1, val2):
397397

398398

399399
def change_dict_value(
400-
data: dict, dotted_key: str, change_value, change_type="value"
400+
data: dict,
401+
dotted_key: str,
402+
change_value,
403+
change_type="value",
404+
is_new: bool = False,
401405
) -> dict:
402406
# change_value = func or value(any type)
403407
if "." in dotted_key:
@@ -423,7 +427,7 @@ def change_dict_value(
423427
data[key], rest, change_value, change_type
424428
)
425429
else:
426-
if dotted_key in data:
430+
if dotted_key in data or is_new:
427431
data[dotted_key] = _change_value_by_type(
428432
change_type, data[dotted_key], change_value
429433
)

0 commit comments

Comments
 (0)