You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.5 KiB
54 lines
1.5 KiB
# Copyright (C) 2005-2025 Splunk Inc. All Rights Reserved.
|
|
import collections
|
|
|
|
|
|
def get_nested(_dict, keys=[]):
|
|
if not isinstance(_dict, dict) or len(keys) == 0:
|
|
return None
|
|
key = keys.pop(0)
|
|
value = _dict.get(key)
|
|
if len(keys) == 0:
|
|
return value
|
|
return get_nested(value, keys)
|
|
|
|
|
|
def dict_merge(dct, merge_dct):
|
|
""" Recursive dict merge.
|
|
It recurses down into dicts nested to an arbitrary depth, updating keys.
|
|
:param dct: dict onto which the merge is executed
|
|
:param merge_dct: dct merged into dct
|
|
:return: None
|
|
"""
|
|
for k, v in merge_dct.items():
|
|
if (k in dct and isinstance(dct[k], dict)
|
|
and isinstance(merge_dct[k], collections.Mapping)):
|
|
dict_merge(dct[k], merge_dct[k])
|
|
else:
|
|
dct[k] = merge_dct[k]
|
|
|
|
|
|
def normalize_color(color_str):
|
|
"""
|
|
Normalizes the color value for the converter script from classic to UDF GT.
|
|
:param color_str: string value of the color
|
|
:return: normalized color value
|
|
"""
|
|
if not color_str or color_str == 'none':
|
|
return 'transparent'
|
|
return color_str
|
|
|
|
|
|
def normalize_integer(int_str, default_val):
|
|
"""
|
|
Normalizes the integer value for the converter script from classic to UDF GT.
|
|
:param int_str: string value of the integer
|
|
:return: normalized integer value
|
|
"""
|
|
if int_str in (None, ''):
|
|
return default_val
|
|
try:
|
|
return int(int_str)
|
|
# includes 'auto', 'fixed' and any other string value
|
|
except ValueError:
|
|
return default_val
|