MCPcopy Create free account
hub / github.com/XiaoMi/mace / sanitize_load

Function sanitize_load

tools/python/utils/config_parser.py:52–59  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

50
51
52def sanitize_load(s):
53 # do not let yaml parse ON/OFF to boolean
54 for w in ["ON", "OFF", "on", "off"]:
55 s = re.sub(r":\s+" + w + "$", r": '" + w + "'", s)
56
57 # sub ${} to env value
58 s = re.sub(r"\${(\w+)}", lambda x: os.environ[x.group(1)], s)
59 return yaml.load(s)
60
61
62def parse(path):

Callers 1

parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected